
{"id":52,"date":"2013-12-20T00:19:20","date_gmt":"2013-12-19T22:19:20","guid":{"rendered":"http:\/\/remchp.com\/blog\/?p=52"},"modified":"2017-02-17T15:38:39","modified_gmt":"2017-02-17T13:38:39","slug":"analysis-of-a-linux-malware","status":"publish","type":"post","link":"https:\/\/futex.re\/blog\/?p=52","title":{"rendered":"Analysis of a Linux Malware"},"content":{"rendered":"<p>A few days ago, i receive a weird connection on my kippo honeypot.<br \/>\nAn guy as connected on, download a binary file and try to lauch it, but, not succesfully.<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Small_Kippo_capture.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Small_Kippo_capture-300x88.png\" alt=\"Small_Kippo_capture\" width=\"300\" height=\"88\" class=\"alignnone size-medium wp-image-59\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Small_Kippo_capture-300x88.png 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Small_Kippo_capture-500x147.png 500w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Small_Kippo_capture.png 963w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/command_capture.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/command_capture-300x121.jpg\" alt=\"command_capture\" width=\"300\" height=\"121\" class=\"alignnone size-medium wp-image-62\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/command_capture-300x121.jpg 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/command_capture-500x202.jpg 500w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/command_capture.jpg 966w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>So after some checks, i can download this binary :), so, go to analysis it!<br \/>\n<code><br \/>\n$ file disknyp<br \/>\ndisknyp: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU\/Linux 2.2.5, not stripped<\/p>\n<p>$ du -sk disknyp<br \/>\n1460\tdisknyp<br \/>\n<\/code><\/p>\n<p>It&#8217;s statically linked, that&#8217;s explain is big size, and it&#8217;s not stripped \ud83d\ude42<\/p>\n<p>Hash:<br \/>\nMD5: 260533ebd353c3075c9dddf7784e86f9<br \/>\nSHA1: 9a40f162e5bcaac2d58c0363ef2baf7b4c1a9710<\/p>\n<p>Look at the main function in IDA.<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/main.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/main-300x195.png\" alt=\"main\" width=\"300\" height=\"195\" class=\"alignnone size-medium wp-image-64\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/main-300x195.png 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/main-459x300.png 459w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/main.png 990w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Coded in C++, it run as a daemon, after, it lauch _ZN9CStatBase10InitializeEv who get some system infos.<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize-300x233.jpg\" alt=\"Initialize\" width=\"300\" height=\"233\" class=\"alignnone size-medium wp-image-66\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize-300x233.jpg 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize-385x300.jpg 385w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize.jpg 764w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>_ZN9CStatBase13GetSysVersionEv do a uname command.<br \/>\n_ZN9CStatBase9GetCpuSpdEv get cpu info to \/proc\/cpuinfo and extract frequency.<br \/>\n__ZN9CStatBase13InitGetCPUUseEv open \/proc\/stat file and check cpu usage.<br \/>\n_ZN9CStatBase13InitGetNetUseEv open \/proc\/net\/dev and get network informations.<\/p>\n<p>After that it initialize the server:<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server-300x139.jpg\" alt=\"Initialize_server\" width=\"300\" height=\"139\" class=\"alignnone size-medium wp-image-71\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server-300x139.jpg 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server-1024x474.jpg 1024w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server-500x231.jpg 500w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Initialize_server.jpg 1374w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Lock at the decrypt fonction:<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Decrypt.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Decrypt-238x300.jpg\" alt=\"Decrypt\" width=\"238\" height=\"300\" class=\"alignnone size-medium wp-image-72\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Decrypt-238x300.jpg 238w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/Decrypt.jpg 494w\" sizes=\"(max-width: 238px) 100vw, 238px\" \/><\/a><\/p>\n<p>Decrypt fonction as call twice, one with the argument 281-206-3\/\/18 (the C&#038;C ip adress?), decrypt value is 190.115.20.27, and after with 68961 as the port number 59870.<\/p>\n<p>Not necesseray to make a script to reverse this fonction, we can see decrypt values in memory, but this function is easy to understand, it make one ascii addition of the crypted value, after ascii soustraction and loops.<br \/>\n<code><br \/>\n# netstat -laputen<br \/>\nConnexions Internet actives (serveurs et \u00c3\u00a9tablies)<br \/>\nProto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        User       Inode       PID\/Program name<br \/>\ntcp        4      0 192.168.1.69:46730      190.115.20.27:59870     ESTABLISHED 1000       138545      18345\/disknyp<br \/>\n<\/code><\/p>\n<p>Localisation of the c&#038;c:<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/geoloca.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/geoloca-300x217.png\" alt=\"geoloca\" width=\"300\" height=\"217\" class=\"alignnone size-medium wp-image-76\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/geoloca-300x217.png 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/geoloca-413x300.png 413w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/geoloca.png 798w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Belize, it&#8217;s not the right place for make malware, but rather to jump into the see and drink mojitos \ud83d\ude42<\/p>\n<p>After, it call _ZN8CManager15StartNetProcessEv fonction, who create a thread, initialize a socket, and send information.<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2-300x126.jpg\" alt=\"start_server2\" width=\"300\" height=\"126\" class=\"alignnone size-medium wp-image-103\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2-300x126.jpg 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2-1024x430.jpg 1024w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2-500x210.jpg 500w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/start_server2.jpg 1523w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And it create an fake.cfg file, it&#8217;s containt the ip adress of my hosts, corresponding for me to the local adress.<br \/>\n<code><br \/>\n$ cat fake.cfg<br \/>\n0<br \/>\n127.0.1.1:127.0.1.1<br \/>\n10000:60000<br \/>\n<\/code><\/p>\n<p>After it read \/proc\/stat and \/proc\/net\/dev file and just send kernel version to the c&#038;c in loop.<\/p>\n<p><a href=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/tcp_flow.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/tcp_flow-300x233.jpg\" alt=\"tcp_flow\" width=\"300\" height=\"233\" class=\"alignnone size-medium wp-image-86\" srcset=\"https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/tcp_flow-300x233.jpg 300w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/tcp_flow-384x300.jpg 384w, https:\/\/futex.re\/blog\/wp-content\/uploads\/2013\/12\/tcp_flow.jpg 752w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days ago, i receive a weird connection on my kippo honeypot. An guy as connected on, download a binary file and try to lauch it, but, not succesfully. So after some checks, i can download this binary :), &hellip; <a href=\"https:\/\/futex.re\/blog\/?p=52\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52"}],"collection":[{"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":52,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions\/227"}],"wp:attachment":[{"href":"https:\/\/futex.re\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/futex.re\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}