{"id":354,"date":"2013-03-07T17:45:54","date_gmt":"2013-03-07T17:45:54","guid":{"rendered":"http:\/\/www.gironsec.com\/blog\/?p=354"},"modified":"2013-03-07T17:45:54","modified_gmt":"2013-03-07T17:45:54","slug":"reversing-a-botnet","status":"publish","type":"post","link":"https:\/\/www.gironsec.com\/blog\/2013\/03\/reversing-a-botnet\/","title":{"rendered":"Reversing a Botnet"},"content":{"rendered":"<p>Howdy fellow crackers and hackers alike! Have I got a treat for you? A live botnet. <\/p>\n<p>The other day at work, I encountered a number of machines all attacking other hosts. Normally its just one machine, but this there were several. <\/p>\n<p>We isolated the exe responsible because it was eating up 100% CPU (not exactly subtle). I was curious about what made it tick, so I disassembled it and this is what I found. Normally where I work, we&#8217;re hit by botnets, and never get to catch them in the act as tracking down the mothership is difficult. <\/p>\n<p>First things first, I want to know more about the executable, like if its packed, or what have you.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet1-300x276.png\" alt=\"reversing botnet1\" width=\"300\" height=\"276\" class=\"alignnone size-medium wp-image-355\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet1-300x276.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet1.png 679w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nAs the picture shows, the executable is NOT packed, rather just your standard run of the mill PE (portable executable) file. The 2 extra sectioned highlighted tell is the type of compiler used &#8211; GCC for windows aka mingw, meaning either CodeBlocks was used or Devcpp. I say this because the .bss and .idata sections are specific to GCC and remind me of ELF (executable linker format) used by Linux.<\/p>\n<p>Since I don&#8217;t want to join said botnet, I&#8217;m sticking to static analysis. Opening the thing up in IDA, we find exactly what kind of malware we&#8217;re dealing with &#8211; amaturish.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet2-300x168.png\" alt=\"reversing botnet2\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-356\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet2-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet2-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet2.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nThe strings are not encoded, nor are they hidden. The first thing I noticed was the IP address. For those curious, a quick search on ARIN reveals the IP address as belonging to some collocation service in Atlanta: http:\/\/whois.arin.net\/rest\/net\/NET-199-229-248-0-1\/pft<br \/>\nThe next thing we see is the channel name #test(more on that in a sec), then the passwords. The &#8216;Operation Dildos&#8217; name deduces that our malware writers are either 14, or immature. I still chuckled though.<\/p>\n<p>The next thing I determined was the type of bot we were dealing with. Scrolling further through revealed IRC instructions. You&#8217;ve read RF C1459 right? http:\/\/www.irchelp.org\/irchelp\/rfc\/rfc.html<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet3.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet3-300x168.png\" alt=\"reversing botnet3\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-357\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet3-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet3-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet3.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nJOIN, PING, PONG, NICK, PRIVMSG &#8211; these are all IRC commands. <\/p>\n<p>Further inspection of the bot revealed the commands the that can be issued to the bot by its master.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet4.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet4-300x168.png\" alt=\"reversing botnet4\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-358\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet4-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet4-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet4.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nThe commands are<br \/>\n&#8216;help&#8217; &#8211; derp.<br \/>\n&#8216;version&#8217; &#8211; derrrr.<br \/>\n&#8216;speedtest&#8217; &#8211; perform a speed test by performing  web request to 68.11.12.242  which traced this to Louisiana. I have a feeling our malware writer lives in that area because of the botnet server resides in Georgia. Just a guess \ud83d\ude42<br \/>\n&#8216;exec&#8217; &#8211; Execute a command.<br \/>\n&#8216;dle&#8217; &#8211; Download and execute a file.<br \/>\n&#8216;udp&#8217; &#8211; Do a udp flood.<br \/>\n&#8216;openurl&#8217; &#8211; Open a hidden window of a URL.<br \/>\n&#8216;syn&#8217; &#8211; Do s syn flood.<br \/>\n&#8216;stop&#8217; &#8211; Stops execution.<br \/>\nIf you&#8217;re curious how the bot performs the lookup on the command, here it is. What you can&#8217;t see is the stub at the top which belongs to the subroutine responsible for the IRC connection to the server.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet_command_list.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet_command_list-300x168.png\" alt=\"reversing botnet_command_list\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-359\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet_command_list-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet_command_list-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet_command_list.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Next thing I found scrolling through was the error handler data section &#8211; messages sent to alert the master that said command completed.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet5.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet5-300x168.png\" alt=\"reversing botnet5\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-360\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet5-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet5-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-botnet5.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The last thing in this reversing session I&#8217;d like to point out is just before the command listing &#8211; the password check.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-1botnet6.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-1botnet6-300x168.png\" alt=\"reversing 1botnet6\" width=\"300\" height=\"168\" class=\"alignnone size-medium wp-image-363\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-1botnet6-300x168.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-1botnet6-1024x576.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/reversing-1botnet6.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nThe assembly instruction &#8216;repne scasb&#8217; is a string operation. It means scan string for NULL decrementing the ecx (extended counter register) for each char. I see it primarily with string comparison operations. <\/p>\n<p>Enough about the bot itself, lets learn more about the botnet.<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet-300x188.png\" alt=\"botnet\" width=\"300\" height=\"188\" class=\"alignnone size-medium wp-image-364\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet-300x188.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet.png 675w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nA quick ping shows us its still online. You may also notice <\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet2-300x188.png\" alt=\"botnet2\" width=\"300\" height=\"188\" class=\"alignnone size-medium wp-image-365\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet2-300x188.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/botnet2.png 675w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nConnecting to it seems to work, so its still operational. The botnet itself seems to be growing because when I looked last night, there were only 400 hosts. Checking now, I see &#8216;There are 3 users and 1131 invisible on 2 servers&#8217;<\/p>\n<p>When i connected, I was called out by the server admin within minutes whom I saw the first time I connected. Since I don&#8217;t want to throw rocks at a hornest&#8217;s nest (get my server DDOS&#8217;d off the net), I decided not to further pursue. My readers on the other hand, go nuts. You have the password to issue commands, you have the irc server address, you have the channel where the bots reside (#test). <\/p>\n<p>Perhaps I may try again tonight at like 1 am when the admins are probably asleep. Until then, keep on cracking.<\/p>\n<p>For those of you who are curious, you can download the bot here, complete with IDA 6 compatible db file:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/zz_botnet.7z\">The Bot.<\/a><\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/1330480069115.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/1330480069115-269x300.jpg\" alt=\"1330480069115\" width=\"269\" height=\"300\" class=\"alignnone size-medium wp-image-367\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/1330480069115-269x300.jpg 269w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/03\/1330480069115.jpg 460w\" sizes=\"(max-width: 269px) 100vw, 269px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Howdy fellow crackers and hackers alike! Have I got a treat for you? A live botnet. The other day at work, I encountered a number of machines all attacking other hosts. Normally its just one machine, but this there were several. We isolated the exe responsible because it was eating up 100% CPU (not exactly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,7],"tags":[49,105,51,27,9,48,50],"_links":{"self":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/354"}],"collection":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":2,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions\/368"}],"wp:attachment":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}