An Analysis of Godlua Backdoor
<!--kg-card-begin: markdown--><h3 id="background">Background</h3>
<p>On April 24, 2019, our Unknown Threat Detection System highlighted a suspicious ELF file which was marked by a few vendors as mining related trojan on VT. We cannot confirm it has mining related module, but we do see it starts to perform DDoS function recently.</p>
<p>The file itself is a Lua-based Backdoor, we named it Godlua Backdoor as the Lua byte-code file loaded by this sample has a magic number of “God”.</p>
<p>Godlua Backdoor has a redundant communication mechanism for  C2 connection, a combination of hardcoded dns name, Pastebin.com, GitHub.com as well as DNS TXT are used to store the C2 address, which is not something we see often. At the same time, it uses HTTPS to download Lua byte-code files, and uses DNS over HTTPS to get the C2 name to ensure secure communication between the bots, the Web Server and the C2.</p>
<p>We noticed that there are already 2 versions of Godlua Backdoor and there are ongoing updates. We also observed that attackers has been using Lua command to run Lua code dynamically and initiate HTTP Flood attacks targeting some websites.</p>
<h3 id="overview">Overview</h3>
<p>At present, we see that there are two versions of Godlua. Version 201811051556 is obtained by traversing Godlua download servers and there has been no update on it. Version 20190415103713 ~ 2019062117473 is active and is actively being updated. They are all written in C, but the active one supports more computer platforms and more features. The following is a comparison.<br>
<a href="__GHOST_URL__/content/images/2019/06/brief.PNG"><img src="__GHOST_URL__/content/images/2019/06/brief.PNG" class="kg-image"/></a></p>
<h3 id="godluabackdoorreverseanalysis">Godlua Backdoor Reverse Analysis</h3>
<h3 id="version201811051556">version 201811051556</h3>
<p>This is the version we found earlier (201811051556). It focuses on the Linux platform and supports two kinds of C2 instructions, to execute Linux system commands and to run custom files.</p>
<h4 id="sampleinformation">Sample information</h4>
<ul>
<li>MD5: 870319967dba4bd02c7a7f8be8ece94f</li>
</ul>
<blockquote>
<p>ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.32, dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped</p>
</blockquote>
<h4 id="c2redundantmechanism">C2 redundant mechanism</h4>
<p>This version perform C2 communications in two ways,  hardcoded domain name and Github link.<br>
<a href="__GHOST_URL__/content/images/2019/06/v1.PNG"><img src="__GHOST_URL__/content/images/2019/06/v1.PNG" class="kg-image"/></a></p>
<p>Its hardcoded C2 domain is: d.heheda.tk<br>
<a href="__GHOST_URL__/content/images/2019/06/1-1.PNG"><img src="__GHOST_URL__/content/images/2019/06/1-1.PNG" class="kg-image"/></a></p>
<p>It also has a Github page and the real C2 address is in the project description.<br>
<a href="__GHOST_URL__/content/images/2019/06/2-4.PNG"><img src="__GHOST_URL__/content/images/2019/06/2-4.PNG" class="kg-image"/></a></p>
<h4 id="c2instruction">C2 instruction</h4>
<p>cmd_call, execute Linux system commands<br>
<a href="__GHOST_URL__/content/images/2019/06/3-3.PNG"><img src="__GHOST_URL__/content/images/2019/06/3-3.PNG" class="kg-image"/></a></p>
<p>cmd_shell, execute custom file<br>
<a href="__GHOST_URL__/content/images/2019/06/4-3.PNG"><img src="__GHOST_URL__/content/images/2019/06/4-3.PNG" class="kg-image"/></a></p>
<h4 id="c2protocolanalysis">C2 protocol analysis</h4>
<h6 id="packetformat">Packet format</h6>
<table>
<thead>
<tr>
<th>Length</th>
<th>Type</th>
<th>Data</th>
</tr>
</thead>
<tbody>
<tr>
<td>Little endian,2 bytes</td>
<td>1 bytes</td>
<td>(Length -3) bytes</td>
</tr>
</tbody>
</table>
<h6 id="encryptionalgorithm">Encryption Algorithm</h6>
<p>XOR’s Key is randomly generated of 16 bytes of data, the algorithm is as follow:<br>
<a href="__GHOST_URL__/content/images/2019/06/5-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/5-2.PNG" class="kg-image"/></a></p>
<h4 id="packetoverview">Packet Overview</h4>
<h6 id="cmd_handshake">cmd_handshake</h6>
<pre><code class="language-bash">packet[0:31]:
24 00 02 ec 86 a3 23 fb d0 d1 e9 e8 5f 23 6f 6d
70 b5 95 24 44 e0 fc 2e 00 00 00 6c 69 6e 75 78
2d 78 38 36

Length:	packet[0:1]               ---&gt;0x0024
Type:	packet[2]                 ---&gt;0x02,handshake
Data:	packet[3:31]
            Data
            Data[0:15]                  ----&gt;xor key
            Data[16:23]                 ----&gt;version,hardcoded,little endian.
            Data[24:31]                 ----&gt;arch,hardcoded.

</code></pre>
<h6 id="cmd_heartbeat">cmd_heartbeat</h6>
<pre><code class="language-bash">packet[0:10]:
0b 00 03 87 19 45 cb 91 d1 d1 a9

Length:		  packet[0:1]                 ---&gt;0x000b
Type:		  packet[2]                   ---&gt;0x03,heartbeat
Data:		  packet[3:10]                ---&gt;xored clock64()
</code></pre>
<h3 id="version2019041510371320190621174731">version 20190415103713 ~ 20190621174731</h3>
<p>This active version runs on both Windows and Linux.<br>
The control module is implemented in Lua and five C2 commands are supported</p>
<h4 id="sampleinformation">Sample information</h4>
<h6 id="version20190415103713">version 20190415103713</h6>
<ul>
<li>MD5: c9b712f6c347edde22836fb43b927633</li>
</ul>
<blockquote>
<p>ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped</p>
</blockquote>
<h6 id="version20190621174731">version 20190621174731</h6>
<ul>
<li>MD5: 75902cf93397d2e2d1797cd115f8347a</li>
</ul>
<blockquote>
<p>ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped</p>
</blockquote>
<h4 id="c2redundantmechanism">C2 redundant mechanism</h4>
<p><a href="__GHOST_URL__/content/images/2019/06/godlua.PNG"><img src="__GHOST_URL__/content/images/2019/06/godlua.PNG" class="kg-image"/></a></p>
<h4 id="stage1url">Stage-1 URL</h4>
<p>The backdoor uses 3 different ways to store the Stage-1 URL. hardcoded ciphertext, Github project description, and Pastebin text.<br>
After the Stage-1 URL is retrieved and decrypted, a start.png file will be downloaded, which is actually a Lua bytecode.<br>
The Bot then loads it into memory and executes it to get the Stage-2 URL.</p>
<h6 id="encryptionalgorithm">Encryption Algorithm</h6>
<ul>
<li>AES，CBC Mode</li>
<li>key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A</li>
<li>iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C</li>
</ul>
<h6 id="hardcodedciphertext">Hard coded ciphertext</h6>
<p><strong>version 20190415103713</strong></p>
<ul>
<li>AES ciphertext：03 13 84 29 CC 8B A5 CA AB 05 9E 2F CB AF 5E E6 02 5A 5F 17 74 34 64 EA 5B F1 38 5B 8D B9 A5 3E</li>
<li>Stage-1 URL plaintext：<code>https://d.heheda.tk/%s.png</code></li>
</ul>
<p><strong>version 20190621174731</strong></p>
<ul>
<li>AES ciphertext：F1 40 DB B4 E1 29 D9 DC 8D 78 45 B9 37 2F 83 47 F1 32 3A 11 01 41 07 CD DB A3 7B 1F 44 A7 DE 6C 2C 81 0E 10 E9 D8 E1 03 38 68 FC 51 81 62 11 DD</li>
<li>Stage-1 URL plaintext：<code>https://img0.cloudappconfig.com/%s.png</code></li>
</ul>
<h6 id="githubprojectdescription">Github project description</h6>
<ul>
<li>AES ciphertext：EC 76 44 29 59 3D F7 EE B3 01 90 A9 9C 47 C8 96 53 DE 86 CB DF 36 68 41 60 5C FA F5 64 60 5A E4 AE 95 C3 F5 A6 04 47 CB 26 47 A2 23 80 C6 5F 92</li>
<li>Github URL plaintext：<code>https://api.github.com/repos/helegedada/heihei</code></li>
<li>Decryption Process:<br>
<a href="__GHOST_URL__/content/images/2019/06/8-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/8-2.PNG" class="kg-image"/></a></li>
<li>Project description ciphertext: oTre1RVbmjqRn2kRrv4SF/l2WfMRn2gEHpqJz77btaDPlO0R9CdQtMM82uAes+Fb</li>
<li>Stage-1 URL plaintext：<code>https://img1.cloudappconfig.com/%s.png</code></li>
</ul>
<h6 id="pastebintext">Pastebin text</h6>
<ul>
<li>AES ciphertext：19 31 21 32 BF E8 29 A8 92 F7 7C 0B DF DC 06 8E 8E 49 F0 50 9A 45 6C 53 77 69 2F 68 48<br>
DC 7F 28 16 EB 86 B3 50 20 D3 01 9D 23 6C A1 33 62 EC 15</li>
<li>Pastebin URL plaintext：<code>https://pastebin.com/raw/vSDzq3Md</code></li>
<li>Decryption Process:<br>
<a href="__GHOST_URL__/content/images/2019/06/9.PNG"><img src="__GHOST_URL__/content/images/2019/06/9.PNG" class="kg-image"/></a></li>
<li>Pastebin Ciphertext: G/tbLY0TsMUnC+iO9aYm9yS2eayKlKLQyFPOaNxSCnZpBw4RLGnJOPcZXHaf/aoj</li>
<li>Stage-1 URL plaintext：<code>https://img2.cloudappconfig.com/%s.png</code></li>
</ul>
<h4 id="stage2url">Stage-2 URL</h4>
<p>Here at stage-2, two mechanisms are being used for storing the Stage-2 URL, Github project file and DNS over HTTPS.<br>
After the Stage-2 URL is retrieved and decrypted, a run.png file, also a Lua bytecode, will be downloaded.<br>
Bot will load this file into memory and run it to get Stage-3 C2.</p>
<h6 id="encryptionalgorithm">Encryption Algorithm</h6>
<ul>
<li>AES，CBC Mode</li>
<li>key：22 85 16 13 57 2d 17 90 2f 00 49 18 5f 17 2b 0a</li>
<li>iv：0d 43 36 41 86 41 21 d2 41 4e 62 00 41 19 4a 5c</li>
</ul>
<h6 id="githubprojectfile">Github project file</h6>
<ul>
<li>Github URL is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：<br>
<a href="__GHOST_URL__/content/images/2019/06/a-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/a-2.PNG" class="kg-image"/></a></li>
<li>Github project file ciphertext: kI7xf+Q/fXC0UT6hCUNimtcH45gPgG9i+YbNnuDyHyh2HJqzBFQStPvHGCZH8Yoz9w02njr41wdl5VNlPCq18qTZUVco5WrA1EIg3zVOcY8=</li>
<li>Stage-2 URL plaintext：<code>{&quot;u&quot;:&quot;https:\/\/dd.heheda.tk\/%s.png&quot;,&quot;c&quot;:&quot;dd.heheda.tk::198.204.231.250:&quot;}</code></li>
</ul>
<h6 id="dnstxt">DNS TXT</h6>
<ul>
<li>DNS TXT is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：<br>
<a href="__GHOST_URL__/content/images/2019/06/b-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/b-2.PNG" class="kg-image"/></a></li>
<li>DNS over HTTPS Request：<br>
<a href="__GHOST_URL__/content/images/2019/06/dnstxt.PNG"><img src="__GHOST_URL__/content/images/2019/06/dnstxt.PNG" class="kg-image"/></a></li>
<li>DNS TXT ciphertext: 6TmRMwDw5R/sNSEhjCByEw0Vb44nZhEUyUpUR4LcijfIukjdAv+vqqMuYOFAoOpC7Ktyyr6nUOqO9XnDpudVmbGoTeJD6hYrw72YmiOS9dX5M/sPNmsw/eY/XDYYzx5/</li>
<li>Stage-2 URL plaintext：<code>{&quot;u&quot;:&quot;http:\/\/img1.cloudappconfig.com\/%s.png&quot;,&quot;c&quot;:&quot;img1.cloudappconfig.com::43.224.225.220:&quot;}</code></li>
</ul>
<h4 id="stage3c2">Stage-3 C2</h4>
<p>Stage-3 C2 is hardcoded in the Lua byte-code file (run.png). We disassembled it to get the following information.</p>
<p><strong>version 20190415103713</strong><br>
<a href="__GHOST_URL__/content/images/2019/06/c-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/c-2.PNG" class="kg-image"/></a></p>
<p><strong>version 20190621174731</strong><br>
<a href="__GHOST_URL__/content/images/2019/06/d-2.PNG"><img src="__GHOST_URL__/content/images/2019/06/d-2.PNG" class="kg-image"/></a></p>
<h6 id="dnsoverhttpsrequest">DNS Over HTTPS Request</h6>
<p><a href="__GHOST_URL__/content/images/2019/06/e.PNG"><img src="__GHOST_URL__/content/images/2019/06/e.PNG" class="kg-image"/></a></p>
<h6 id="c2instruction">C2 instruction</h6>
<pre><code>| CMD       | Type |
| --------- | ---- |
| HANDSHAKE | 1    |
| HEARTBEAT | 2    |
| LUA       | 3    |
| SHELL     | 4    |
| UPGRADE   | 5    |
| QUIT      | 6    |
| SHELL2    | 7    |
| PROXY     | 8    |
</code></pre>
<h6 id="c2protocolanalysis">C2 protocol analysis</h6>
<p>Packet format</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Length</th>
<th>Data</th>
</tr>
</thead>
<tbody>
<tr>
<td>1byte</td>
<td>Big endian,2 bytes</td>
<td>Length bytes</td>
</tr>
</tbody>
</table>
<h6 id="packetoverview">Packet overview</h6>
<ul>
<li>HANDSHAKE<br>
<a href="__GHOST_URL__/content/images/2019/06/f.PNG"><img src="__GHOST_URL__/content/images/2019/06/f.PNG" class="kg-image"/></a></li>
</ul>
<pre><code>Type:	packet[0]		---&gt;0x01,HANDSHAKE
LENGTH:	packet[1:2]		---&gt;0x0010
Data:	packet[3:end]
            data[0:7]			---&gt;Session
            data[8:end]			---&gt;version,0x00125cfecd8bcb-&gt;20190621174731
</code></pre>
<ul>
<li>
<p>HEARTBEAT<br>
<a href="__GHOST_URL__/content/images/2019/06/g.PNG"><img src="__GHOST_URL__/content/images/2019/06/g.PNG" class="kg-image"/></a></p>
<pre><code>Send:
	Type: 			packet[0]        ---&gt;0x02,HEARTBEAT
	Length:			packet[1:2]      ---&gt;0x4
	Data:			packet[3:end]    ---&gt;time,0x5d13779b,1561556891
Replay:
	Type:			packet[0]        ---&gt;0x02,HEARTBEAT
	Length:			packet[1:2]      ---&gt;0x4
	Data:			packet[3:end]    ---&gt;1561556891
</code></pre>
</li>
<li>
<p>LUA Payload<br>
<a href="__GHOST_URL__/content/images/2019/06/h.PNG"><img src="__GHOST_URL__/content/images/2019/06/h.PNG" class="kg-image"/></a></p>
<pre><code>Type:     packet[0]            ---&gt;0x03,LUA
Length:   packet[1:2]          ---&gt;0x00ab
Data:     packet[3:end]        ---&gt;Lua script
</code></pre>
</li>
</ul>
<p>We observe the attacker performing a HTTP Flood attack against www.liuxiaobei.com.<br>
<a href="__GHOST_URL__/content/images/2019/06/j.PNG"><img src="__GHOST_URL__/content/images/2019/06/j.PNG" class="kg-image"/></a></p>
<h4 id="luascriptanalysis">Lua script analysis</h4>
<p>The Bot sample downloads many Lua scripts when executing, and the scripts can be broken down to three categories: execute, auxiliary, and attack.</p>
<ul>
<li>execute: start.png,run.png,quit.png,watch.png,upgrade.png,proxy.png</li>
<li>auxiliary: packet.png,curl.png,util.png,utils.png</li>
<li>attack: VM.png,CC.png</li>
</ul>
<h6 id="encryptionalgorithm">Encryption Algorithm</h6>
<ul>
<li>AES，CBC Mode</li>
<li>key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A</li>
<li>iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C</li>
</ul>
<h6 id="luamagicnumber">Lua magic number</h6>
<p>The decrypted files are all pre-compiled, take upgrade.png as an example, note the highlighted part is the file header.<br>
<a href="__GHOST_URL__/content/images/2019/06/k.PNG"><img src="__GHOST_URL__/content/images/2019/06/k.PNG" class="kg-image"/></a>You can see that the magic number has changed from “Lua” to “God”.</p>
<p>The malware author also seems to set a trap for researcher here by manually changing the LuaVerion number in the sample to 5.1.4 ($LuaVersion: God 5.1.4 C$$LuaAuthors: R. $). We think the real version should be definitely newer than 5.2.</p>
<h6 id="decompile">Decompile</h6>
<p>In order to decompile the above script, we have to know what changes have been made to Lua. After some analysis, we concluded that the modification can be divided into two major sections: Lua Header and Lua Opcode.</p>
<p>Decompiled by Luadec[<a href="https://github.com/viruscamp/luadec">1]</a><br>
<a href="__GHOST_URL__/content/images/2019/06/l.PNG"><img src="__GHOST_URL__/content/images/2019/06/l.PNG" class="kg-image"/></a></p>
<h2 id="suggestions">Suggestions</h2>
<p>We have yet to see the whole picture of how exactly the Godlua backdoor infects the targets, at this point we know at least some linux users were infected via the Confluence exploit(CVE-2019-3396), if our readers have more information, feel free to contact us.</p>
<p>We suggest that at least to monitor and block the relevant IP, URL and domain name of Godlua Backdoor on your network.</p>
<h4 id="contactus">Contact us</h4>
<p>Readers are always welcomed to reach us on <a href="https://twitter.com/360Netlab"><strong>twitter</strong></a>, WeChat 360Netlab or email to netlab at 360 dot cn.</p>
<h4 id="ioclist">IoC list</h4>
<p>Sample MD5</p>
<pre><code>870319967dba4bd02c7a7f8be8ece94f
c9b712f6c347edde22836fb43b927633
75902cf93397d2e2d1797cd115f8347a
</code></pre>
<p>URL</p>
<pre><code>https://helegedada.github.io/test/test
https://api.github.com/repos/helegedada/heihei
http://198.204.231.250/linux-x64
http://198.204.231.250/linux-x86
https://dd.heheda.tk/i.jpg
https://dd.heheda.tk/i.sh
https://dd.heheda.tk/x86_64-static-linux-uclibc.jpg
https://dd.heheda.tk/i686-static-linux-uclibc.jpg
https://dd.cloudappconfig.com/i.jpg
https://dd.cloudappconfig.com/i.sh
https://dd.cloudappconfig.com/x86_64-static-linux-uclibc.jpg
https://dd.cloudappconfig.com/arm-static-linux-uclibcgnueabi.jpg
https://dd.cloudappconfig.com/i686-static-linux-uclibc.jpg
http://d.cloudappconfig.com/i686-w64-mingw32/Satan.exe
http://d.cloudappconfig.com/x86_64-static-linux-uclibc/Satan
http://d.cloudappconfig.com/i686-static-linux-uclibc/Satan
http://d.cloudappconfig.com/arm-static-linux-uclibcgnueabi/Satan
https://d.cloudappconfig.com/mipsel-static-linux-uclibc/Satan
</code></pre>
<p>C2 Domain</p>
<pre><code>d.heheda.tk
dd.heheda.tk
c.heheda.tk
d.cloudappconfig.com
dd.cloudappconfig.com
c.cloudappconfig.com
f.cloudappconfig.com
t.cloudappconfig.com
v.cloudappconfig.com
img0.cloudappconfig.com
img1.cloudappconfig.com
img2.cloudappconfig.com
</code></pre>
<p>IP</p>
<pre><code>198.204.231.250     	United States       	ASN 33387           	DataShack, LC       
104.238.151.101     	Japan               	ASN 20473           	Choopa, LLC         
43.224.225.220      	Hong Kong           	ASN 22769           	DDOSING NETWORK     
</code></pre>
<!--kg-card-end: markdown-->
Background


On April 24, 2019, our Unknown Threat Detection System highlighted a suspicious ELF file which was marked by a few vendors as mining related trojan on VT. We cannot confirm it has mining related module, but we do see it starts to perform DDoS function recently.


The file itself is a Lua-based Backdoor, we named it Godlua Backdoor as the Lua byte-code file loaded by this sample has a magic number of “God”.


Godlua Backdoor has a redundant communication mechanism for C2 connection, a combination of hardcoded dns name, Pastebin.com, GitHub.com as well as DNS TXT are used to store the C2 address, which is not something we see often. At the same time, it uses HTTPS to download Lua byte-code files, and uses DNS over HTTPS to get the C2 name to ensure secure communication between the bots, the Web Server and the C2.


We noticed that there are already 2 versions of Godlua Backdoor and there are ongoing updates. We also observed that attackers has been using Lua command to run Lua code dynamically and initiate HTTP Flood attacks targeting some websites.



Overview


At present, we see that there are two versions of Godlua. Version 201811051556 is obtained by traversing Godlua download servers and there has been no update on it. Version 20190415103713 ~ 2019062117473 is active and is actively being updated. They are all written in C, but the active one supports more computer platforms and more features. The following is a comparison.





Godlua Backdoor Reverse Analysis



version 201811051556


This is the version we found earlier (201811051556). It focuses on the Linux platform and supports two kinds of C2 instructions, to execute Linux system commands and to run custom files.


Sample information


 * MD5: 870319967dba4bd02c7a7f8be8ece94f





ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.32, dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped



C2 redundant mechanism


This version perform C2 communications in two ways, hardcoded domain name and Github link.




Its hardcoded C2 domain is: d.heheda.tk




It also has a Github page and the real C2 address is in the project description.




C2 instruction


cmd_call, execute Linux system commands




cmd_shell, execute custom file




C2 protocol analysis


Packet format





Length
Type
Data




Little endian,2 bytes
1 bytes
(Length -3) bytes





Encryption Algorithm


XOR’s Key is randomly generated of 16 bytes of data, the algorithm is as follow:




Packet Overview


cmd_handshake


packet[0:31]:
24 00 02 ec 86 a3 23 fb d0 d1 e9 e8 5f 23 6f 6d
70 b5 95 24 44 e0 fc 2e 00 00 00 6c 69 6e 75 78
2d 78 38 36

Length:	packet[0:1]               --->0x0024
Type:	packet[2]                 --->0x02,handshake
Data:	packet[3:31]
            Data
            Data[0:15]                  ---->xor key
            Data[16:23]                 ---->version,hardcoded,little endian.
            Data[24:31]                 ---->arch,hardcoded.




cmd_heartbeat


packet[0:10]:
0b 00 03 87 19 45 cb 91 d1 d1 a9

Length:		  packet[0:1]                 --->0x000b
Type:		  packet[2]                   --->0x03,heartbeat
Data:		  packet[3:10]                --->xored clock64()




version 20190415103713 ~ 20190621174731


This active version runs on both Windows and Linux.

The control module is implemented in Lua and five C2 commands are supported


Sample information


version 20190415103713


 * MD5: c9b712f6c347edde22836fb43b927633





ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped



version 20190621174731


 * MD5: 75902cf93397d2e2d1797cd115f8347a





ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped



C2 redundant mechanism





Stage-1 URL


The backdoor uses 3 different ways to store the Stage-1 URL. hardcoded ciphertext, Github project description, and Pastebin text.

After the Stage-1 URL is retrieved and decrypted, a start.png file will be downloaded, which is actually a Lua bytecode.

The Bot then loads it into memory and executes it to get the Stage-2 URL.


Encryption Algorithm


 * AES，CBC Mode
 * key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A
 * iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C


Hard coded ciphertext


version 20190415103713


 * AES ciphertext：03 13 84 29 CC 8B A5 CA AB 05 9E 2F CB AF 5E E6 02 5A 5F 17 74 34 64 EA 5B F1 38 5B 8D B9 A5 3E
 * Stage-1 URL plaintext：https://d.heheda.tk/%s.png


version 20190621174731


 * AES ciphertext：F1 40 DB B4 E1 29 D9 DC 8D 78 45 B9 37 2F 83 47 F1 32 3A 11 01 41 07 CD DB A3 7B 1F 44 A7 DE 6C 2C 81 0E 10 E9 D8 E1 03 38 68 FC 51 81 62 11 DD
 * Stage-1 URL plaintext：https://img0.cloudappconfig.com/%s.png


Github project description


 * AES ciphertext：EC 76 44 29 59 3D F7 EE B3 01 90 A9 9C 47 C8 96 53 DE 86 CB DF 36 68 41 60 5C FA F5 64 60 5A E4 AE 95 C3 F5 A6 04 47 CB 26 47 A2 23 80 C6 5F 92
 * Github URL plaintext：https://api.github.com/repos/helegedada/heihei
 * Decryption Process:
   
   
 * Project description ciphertext: oTre1RVbmjqRn2kRrv4SF/l2WfMRn2gEHpqJz77btaDPlO0R9CdQtMM82uAes+Fb
 * Stage-1 URL plaintext：https://img1.cloudappconfig.com/%s.png


Pastebin text


 * AES ciphertext：19 31 21 32 BF E8 29 A8 92 F7 7C 0B DF DC 06 8E 8E 49 F0 50 9A 45 6C 53 77 69 2F 68 48
   
   DC 7F 28 16 EB 86 B3 50 20 D3 01 9D 23 6C A1 33 62 EC 15
 * Pastebin URL plaintext：https://pastebin.com/raw/vSDzq3Md
 * Decryption Process:
   
   
 * Pastebin Ciphertext: G/tbLY0TsMUnC+iO9aYm9yS2eayKlKLQyFPOaNxSCnZpBw4RLGnJOPcZXHaf/aoj
 * Stage-1 URL plaintext：https://img2.cloudappconfig.com/%s.png


Stage-2 URL


Here at stage-2, two mechanisms are being used for storing the Stage-2 URL, Github project file and DNS over HTTPS.

After the Stage-2 URL is retrieved and decrypted, a run.png file, also a Lua bytecode, will be downloaded.

Bot will load this file into memory and run it to get Stage-3 C2.


Encryption Algorithm


 * AES，CBC Mode
 * key：22 85 16 13 57 2d 17 90 2f 00 49 18 5f 17 2b 0a
 * iv：0d 43 36 41 86 41 21 d2 41 4e 62 00 41 19 4a 5c


Github project file


 * Github URL is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：
   
   
 * Github project file ciphertext: kI7xf+Q/fXC0UT6hCUNimtcH45gPgG9i+YbNnuDyHyh2HJqzBFQStPvHGCZH8Yoz9w02njr41wdl5VNlPCq18qTZUVco5WrA1EIg3zVOcY8=
 * Stage-2 URL plaintext：{"u":"https:\/\/dd.heheda.tk\/%s.png","c":"dd.heheda.tk::198.204.231.250:"}


DNS TXT


 * DNS TXT is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：
   
   
 * DNS over HTTPS Request：
   
   
 * DNS TXT ciphertext: 6TmRMwDw5R/sNSEhjCByEw0Vb44nZhEUyUpUR4LcijfIukjdAv+vqqMuYOFAoOpC7Ktyyr6nUOqO9XnDpudVmbGoTeJD6hYrw72YmiOS9dX5M/sPNmsw/eY/XDYYzx5/
 * Stage-2 URL plaintext：{"u":"http:\/\/img1.cloudappconfig.com\/%s.png","c":"img1.cloudappconfig.com::43.224.225.220:"}


Stage-3 C2


Stage-3 C2 is hardcoded in the Lua byte-code file (run.png). We disassembled it to get the following information.


version 20190415103713




version 20190621174731




DNS Over HTTPS Request





C2 instruction


| CMD       | Type |
| --------- | ---- |
| HANDSHAKE | 1    |
| HEARTBEAT | 2    |
| LUA       | 3    |
| SHELL     | 4    |
| UPGRADE   | 5    |
| QUIT      | 6    |
| SHELL2    | 7    |
| PROXY     | 8    |



C2 protocol analysis


Packet format





Type
Length
Data




1byte
Big endian,2 bytes
Length bytes





Packet overview


 * HANDSHAKE
   
   


Type:	packet[0]		--->0x01,HANDSHAKE
LENGTH:	packet[1:2]		--->0x0010
Data:	packet[3:end]
            data[0:7]			--->Session
            data[8:end]			--->version,0x00125cfecd8bcb->20190621174731



 * 
   
   
   HEARTBEAT
   
   
   
   
   Send:
   	Type: 			packet[0]        --->0x02,HEARTBEAT
   	Length:			packet[1:2]      --->0x4
   	Data:			packet[3:end]    --->time,0x5d13779b,1561556891
   Replay:
   	Type:			packet[0]        --->0x02,HEARTBEAT
   	Length:			packet[1:2]      --->0x4
   	Data:			packet[3:end]    --->1561556891
   
   

 * 
   
   
   LUA Payload
   
   
   
   
   Type:     packet[0]            --->0x03,LUA
   Length:   packet[1:2]          --->0x00ab
   Data:     packet[3:end]        --->Lua script
   
   


We observe the attacker performing a HTTP Flood attack against www.liuxiaobei.com.




Lua script analysis


The Bot sample downloads many Lua scripts when executing, and the scripts can be broken down to three categories: execute, auxiliary, and attack.


 * execute: start.png,run.png,quit.png,watch.png,upgrade.png,proxy.png
 * auxiliary: packet.png,curl.png,util.png,utils.png
 * attack: VM.png,CC.png


Encryption Algorithm


 * AES，CBC Mode
 * key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A
 * iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C


Lua magic number


The decrypted files are all pre-compiled, take upgrade.png as an example, note the highlighted part is the file header.

You can see that the magic number has changed from “Lua” to “God”.


The malware author also seems to set a trap for researcher here by manually changing the LuaVerion number in the sample to 5.1.4 ($LuaVersion: God 5.1.4 C$$LuaAuthors: R. $). We think the real version should be definitely newer than 5.2.


Decompile


In order to decompile the above script, we have to know what changes have been made to Lua. After some analysis, we concluded that the modification can be divided into two major sections: Lua Header and Lua Opcode.


Decompiled by Luadec[1]





Suggestions


We have yet to see the whole picture of how exactly the Godlua backdoor infects the targets, at this point we know at least some linux users were infected via the Confluence exploit(CVE-2019-3396), if our readers have more information, feel free to contact us.


We suggest that at least to monitor and block the relevant IP, URL and domain name of Godlua Backdoor on your network.


Contact us


Readers are always welcomed to reach us on twitter, WeChat 360Netlab or email to netlab at 360 dot cn.


IoC list


Sample MD5


870319967dba4bd02c7a7f8be8ece94f
c9b712f6c347edde22836fb43b927633
75902cf93397d2e2d1797cd115f8347a



URL


https://helegedada.github.io/test/test
https://api.github.com/repos/helegedada/heihei
http://198.204.231.250/linux-x64
http://198.204.231.250/linux-x86
https://dd.heheda.tk/i.jpg
https://dd.heheda.tk/i.sh
https://dd.heheda.tk/x86_64-static-linux-uclibc.jpg
https://dd.heheda.tk/i686-static-linux-uclibc.jpg
https://dd.cloudappconfig.com/i.jpg
https://dd.cloudappconfig.com/i.sh
https://dd.cloudappconfig.com/x86_64-static-linux-uclibc.jpg
https://dd.cloudappconfig.com/arm-static-linux-uclibcgnueabi.jpg
https://dd.cloudappconfig.com/i686-static-linux-uclibc.jpg
http://d.cloudappconfig.com/i686-w64-mingw32/Satan.exe
http://d.cloudappconfig.com/x86_64-static-linux-uclibc/Satan
http://d.cloudappconfig.com/i686-static-linux-uclibc/Satan
http://d.cloudappconfig.com/arm-static-linux-uclibcgnueabi/Satan
https://d.cloudappconfig.com/mipsel-static-linux-uclibc/Satan



C2 Domain


d.heheda.tk
dd.heheda.tk
c.heheda.tk
d.cloudappconfig.com
dd.cloudappconfig.com
c.cloudappconfig.com
f.cloudappconfig.com
t.cloudappconfig.com
v.cloudappconfig.com
img0.cloudappconfig.com
img1.cloudappconfig.com
img2.cloudappconfig.com



IP


198.204.231.250     	United States       	ASN 33387           	DataShack, LC       
104.238.151.101     	Japan               	ASN 20473           	Choopa, LLC         
43.224.225.220      	Hong Kong           	ASN 22769           	DDOSING NETWORK     


{"version":"0.3.1","atoms":[],"cards":[["markdown",{"markdown":"### Background\n\nOn April 24, 2019, our Unknown Threat Detection System highlighted a suspicious ELF file which was marked by a few vendors as mining related trojan on VT. We cannot confirm it has mining related module, but we do see it starts to perform DDoS function recently.\n\nThe file itself is a Lua-based Backdoor, we named it Godlua Backdoor as the Lua byte-code file loaded by this sample has a magic number of “God”.\n\nGodlua Backdoor has a redundant communication mechanism for  C2 connection, a combination of hardcoded dns name, Pastebin.com, GitHub.com as well as DNS TXT are used to store the C2 address, which is not something we see often. At the same time, it uses HTTPS to download Lua byte-code files, and uses DNS over HTTPS to get the C2 name to ensure secure communication between the bots, the Web Server and the C2.\n\nWe noticed that there are already 2 versions of Godlua Backdoor and there are ongoing updates. We also observed that attackers has been using Lua command to run Lua code dynamically and initiate HTTP Flood attacks targeting some websites.\n\n\n\n### Overview\nAt present, we see that there are two versions of Godlua. Version 201811051556 is obtained by traversing Godlua download servers and there has been no update on it. Version 20190415103713 ~ 2019062117473 is active and is actively being updated. They are all written in C, but the active one supports more computer platforms and more features. The following is a comparison.\n<a href=\"__GHOST_URL__/content/images/2019/06/brief.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/brief.PNG\" class=\"kg-image\"/></a>\n\n\n### Godlua Backdoor Reverse Analysis\n\n### version 201811051556 \nThis is the version we found earlier (201811051556). It focuses on the Linux platform and supports two kinds of C2 instructions, to execute Linux system commands and to run custom files.\n\n#### Sample information\n\n* MD5: 870319967dba4bd02c7a7f8be8ece94f \n> ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.32, dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped \n\n#### C2 redundant mechanism\nThis version perform C2 communications in two ways,  hardcoded domain name and Github link.\n<a href=\"__GHOST_URL__/content/images/2019/06/v1.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/v1.PNG\" class=\"kg-image\"/></a>\n\nIts hardcoded C2 domain is: d.heheda.tk\n<a href=\"__GHOST_URL__/content/images/2019/06/1-1.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/1-1.PNG\" class=\"kg-image\"/></a>\n\nIt also has a Github page and the real C2 address is in the project description.\n<a href=\"__GHOST_URL__/content/images/2019/06/2-4.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/2-4.PNG\" class=\"kg-image\"/></a>\n\n#### C2 instruction\n\ncmd_call, execute Linux system commands\n <a href=\"__GHOST_URL__/content/images/2019/06/3-3.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/3-3.PNG\" class=\"kg-image\"/></a>\n\ncmd_shell, execute custom file\n<a href=\"__GHOST_URL__/content/images/2019/06/4-3.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/4-3.PNG\" class=\"kg-image\"/></a>\n\n#### C2 protocol analysis\n\n###### Packet format\n| Length                | Type    | Data              |\n| --------------------- | ------- | ----------------- |\n| Little endian,2 bytes | 1 bytes | (Length -3) bytes |\n###### Encryption Algorithm\nXOR’s Key is randomly generated of 16 bytes of data, the algorithm is as follow:\n<a href=\"__GHOST_URL__/content/images/2019/06/5-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/5-2.PNG\" class=\"kg-image\"/></a>\n\n#### Packet Overview\n\n###### cmd_handshake\n\n```bash\npacket[0:31]:\n24 00 02 ec 86 a3 23 fb d0 d1 e9 e8 5f 23 6f 6d\n70 b5 95 24 44 e0 fc 2e 00 00 00 6c 69 6e 75 78\n2d 78 38 36\n\nLength:\tpacket[0:1]               --->0x0024\nType:\tpacket[2]                 --->0x02,handshake\nData:\tpacket[3:31]\n            Data\n            Data[0:15]                  ---->xor key\n            Data[16:23]                 ---->version,hardcoded,little endian.\n            Data[24:31]                 ---->arch,hardcoded.\n\n```\n\n###### cmd_heartbeat\n\n```bash\npacket[0:10]:\n0b 00 03 87 19 45 cb 91 d1 d1 a9\n\nLength:\t\t  packet[0:1]                 --->0x000b\nType:\t\t  packet[2]                   --->0x03,heartbeat\nData:\t\t  packet[3:10]                --->xored clock64()\n```\n\n### version 20190415103713 ~ 20190621174731\nThis active version runs on both Windows and Linux.\nThe control module is implemented in Lua and five C2 commands are supported\n\n#### Sample information\n\n###### version 20190415103713 \n* MD5: c9b712f6c347edde22836fb43b927633\n> ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped\n\n###### version 20190621174731\n* MD5: 75902cf93397d2e2d1797cd115f8347a\n> ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, stripped\n> \n#### C2 redundant mechanism\n<a href=\"__GHOST_URL__/content/images/2019/06/godlua.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/godlua.PNG\" class=\"kg-image\"/></a>\n\n\n#### Stage-1 URL\n\nThe backdoor uses 3 different ways to store the Stage-1 URL. hardcoded ciphertext, Github project description, and Pastebin text.\nAfter the Stage-1 URL is retrieved and decrypted, a start.png file will be downloaded, which is actually a Lua bytecode.\nThe Bot then loads it into memory and executes it to get the Stage-2 URL.\n\n###### Encryption Algorithm\n\n* AES，CBC Mode\n* key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A \n* iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C \n\n###### Hard coded ciphertext\n\n**version 20190415103713**\n  * AES ciphertext：03 13 84 29 CC 8B A5 CA AB 05 9E 2F CB AF 5E E6 02 5A 5F 17 74 34 64 EA 5B F1 38 5B 8D B9 A5 3E\n  * Stage-1 URL plaintext：```https://d.heheda.tk/%s.png``` \n\n**version 20190621174731**\n  * AES ciphertext：F1 40 DB B4 E1 29 D9 DC 8D 78 45 B9 37 2F 83 47 F1 32 3A 11 01 41 07 CD DB A3 7B 1F 44 A7 DE 6C 2C 81 0E 10 E9 D8 E1 03 38 68 FC 51 81 62 11 DD\n  * Stage-1 URL plaintext：```https://img0.cloudappconfig.com/%s.png``` \n\n###### Github project description\n  * AES ciphertext：EC 76 44 29 59 3D F7 EE B3 01 90 A9 9C 47 C8 96 53 DE 86 CB DF 36 68 41 60 5C FA F5 64 60 5A E4 AE 95 C3 F5 A6 04 47 CB 26 47 A2 23 80 C6 5F 92 \n  * Github URL plaintext：```https://api.github.com/repos/helegedada/heihei``` \n  * Decryption Process:\n    <a href=\"__GHOST_URL__/content/images/2019/06/8-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/8-2.PNG\" class=\"kg-image\"/></a>\n  * Project description ciphertext: oTre1RVbmjqRn2kRrv4SF/l2WfMRn2gEHpqJz77btaDPlO0R9CdQtMM82uAes+Fb\n  * Stage-1 URL plaintext：```https://img1.cloudappconfig.com/%s.png```\n\n\n###### Pastebin text\n  * AES ciphertext：19 31 21 32 BF E8 29 A8 92 F7 7C 0B DF DC 06 8E 8E 49 F0 50 9A 45 6C 53 77 69 2F 68 48\n    DC 7F 28 16 EB 86 B3 50 20 D3 01 9D 23 6C A1 33 62 EC 15 \n  * Pastebin URL plaintext：```https://pastebin.com/raw/vSDzq3Md``` \n  * Decryption Process:\n<a href=\"__GHOST_URL__/content/images/2019/06/9.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/9.PNG\" class=\"kg-image\"/></a>\n  * Pastebin Ciphertext: G/tbLY0TsMUnC+iO9aYm9yS2eayKlKLQyFPOaNxSCnZpBw4RLGnJOPcZXHaf/aoj\n  * Stage-1 URL plaintext：```https://img2.cloudappconfig.com/%s.png```\n\n\n#### Stage-2 URL\nHere at stage-2, two mechanisms are being used for storing the Stage-2 URL, Github project file and DNS over HTTPS.\nAfter the Stage-2 URL is retrieved and decrypted, a run.png file, also a Lua bytecode, will be downloaded.\nBot will load this file into memory and run it to get Stage-3 C2.\n\n###### Encryption Algorithm\n* AES，CBC Mode\n* key：22 85 16 13 57 2d 17 90 2f 00 49 18 5f 17 2b 0a  \n* iv：0d 43 36 41 86 41 21 d2 41 4e 62 00 41 19 4a 5c  \n\n###### Github project file\n* Github URL is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：\n<a href=\"__GHOST_URL__/content/images/2019/06/a-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/a-2.PNG\" class=\"kg-image\"/></a>\n* Github project file ciphertext: kI7xf+Q/fXC0UT6hCUNimtcH45gPgG9i+YbNnuDyHyh2HJqzBFQStPvHGCZH8Yoz9w02njr41wdl5VNlPCq18qTZUVco5WrA1EIg3zVOcY8=\n* Stage-2 URL plaintext：```{\"u\":\"https:\\/\\/dd.heheda.tk\\/%s.png\",\"c\":\"dd.heheda.tk::198.204.231.250:\"}```\n\n###### DNS TXT\n* DNS TXT is stored in the Lua byte-code file (start.png) in plaintext. We get the following information by disassembling it：\n<a href=\"__GHOST_URL__/content/images/2019/06/b-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/b-2.PNG\" class=\"kg-image\"/></a>\n* DNS over HTTPS Request：\n<a href=\"__GHOST_URL__/content/images/2019/06/dnstxt.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/dnstxt.PNG\" class=\"kg-image\"/></a>\n* DNS TXT ciphertext: 6TmRMwDw5R/sNSEhjCByEw0Vb44nZhEUyUpUR4LcijfIukjdAv+vqqMuYOFAoOpC7Ktyyr6nUOqO9XnDpudVmbGoTeJD6hYrw72YmiOS9dX5M/sPNmsw/eY/XDYYzx5/\n* Stage-2 URL plaintext：```{\"u\":\"http:\\/\\/img1.cloudappconfig.com\\/%s.png\",\"c\":\"img1.cloudappconfig.com::43.224.225.220:\"}```\n\n#### Stage-3 C2\nStage-3 C2 is hardcoded in the Lua byte-code file (run.png). We disassembled it to get the following information.\n\n**version 20190415103713**\n<a href=\"__GHOST_URL__/content/images/2019/06/c-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/c-2.PNG\" class=\"kg-image\"/></a>\n\n**version 20190621174731**\n<a href=\"__GHOST_URL__/content/images/2019/06/d-2.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/d-2.PNG\" class=\"kg-image\"/></a>\n\n###### DNS Over HTTPS Request\n<a href=\"__GHOST_URL__/content/images/2019/06/e.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/e.PNG\" class=\"kg-image\"/></a>\n\n###### C2 instruction\n```\n| CMD       | Type |\n| --------- | ---- |\n| HANDSHAKE | 1    |\n| HEARTBEAT | 2    |\n| LUA       | 3    |\n| SHELL     | 4    |\n| UPGRADE   | 5    |\n| QUIT      | 6    |\n| SHELL2    | 7    |\n| PROXY     | 8    |\n```\n###### C2 protocol analysis\nPacket format\n| Type  | Length             | Data         |\n| ----- | ------------------ | ------------ |\n| 1byte | Big endian,2 bytes | Length bytes |\n\n###### Packet overview\n* HANDSHAKE\n<a href=\"__GHOST_URL__/content/images/2019/06/f.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/f.PNG\" class=\"kg-image\"/></a>\n\n```\nType:\tpacket[0]\t\t--->0x01,HANDSHAKE\nLENGTH:\tpacket[1:2]\t\t--->0x0010\nData:\tpacket[3:end]\n            data[0:7]\t\t\t--->Session\n            data[8:end]\t\t\t--->version,0x00125cfecd8bcb->20190621174731\n```\n\n* HEARTBEAT\n<a href=\"__GHOST_URL__/content/images/2019/06/g.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/g.PNG\" class=\"kg-image\"/></a>\n\n  ```\n  Send:\n  \tType: \t\t\tpacket[0]        --->0x02,HEARTBEAT\n  \tLength:\t\t\tpacket[1:2]      --->0x4\n  \tData:\t\t\tpacket[3:end]    --->time,0x5d13779b,1561556891\n  Replay:\n  \tType:\t\t\tpacket[0]        --->0x02,HEARTBEAT\n  \tLength:\t\t\tpacket[1:2]      --->0x4\n  \tData:\t\t\tpacket[3:end]    --->1561556891\n  ```\n\n* LUA Payload\n<a href=\"__GHOST_URL__/content/images/2019/06/h.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/h.PNG\" class=\"kg-image\"/></a>\n\n  ```\n  Type:     packet[0]            --->0x03,LUA\n  Length:   packet[1:2]          --->0x00ab\n  Data:     packet[3:end]        --->Lua script\n  ```\nWe observe the attacker performing a HTTP Flood attack against www.liuxiaobei.com.\n<a href=\"__GHOST_URL__/content/images/2019/06/j.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/j.PNG\" class=\"kg-image\"/></a>\n\n#### Lua script analysis \nThe Bot sample downloads many Lua scripts when executing, and the scripts can be broken down to three categories: execute, auxiliary, and attack.\n\n* execute: start.png,run.png,quit.png,watch.png,upgrade.png,proxy.png\n* auxiliary: packet.png,curl.png,util.png,utils.png\n* attack: VM.png,CC.png\n\n###### Encryption Algorithm\n* AES，CBC Mode\n* key：13 21 02 00 31 21 94 E2 F2 F1 35 61 93 4C 4D 6A \n* iv：2B 7E 15 16 28 AE D2 01 AB F7 15 02 00 CF 4F 3C \n\n###### Lua magic number\nThe decrypted files are all pre-compiled, take upgrade.png as an example, note the highlighted part is the file header.\n<a href=\"__GHOST_URL__/content/images/2019/06/k.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/k.PNG\" class=\"kg-image\"/></a>You can see that the magic number has changed from “Lua” to “God”.\n\nThe malware author also seems to set a trap for researcher here by manually changing the LuaVerion number in the sample to 5.1.4 ($LuaVersion: God 5.1.4 C$$LuaAuthors: R. $). We think the real version should be definitely newer than 5.2.\n\n###### Decompile\nIn order to decompile the above script, we have to know what changes have been made to Lua. After some analysis, we concluded that the modification can be divided into two major sections: Lua Header and Lua Opcode.\n\nDecompiled by Luadec[[1\\]](https://github.com/viruscamp/luadec)\n<a href=\"__GHOST_URL__/content/images/2019/06/l.PNG\"><img src=\"__GHOST_URL__/content/images/2019/06/l.PNG\" class=\"kg-image\"/></a>\n\n\n## Suggestions\nWe have yet to see the whole picture of how exactly the Godlua backdoor infects the targets, at this point we know at least some linux users were infected via the Confluence exploit(CVE-2019-3396), if our readers have more information, feel free to contact us.\n\nWe suggest that at least to monitor and block the relevant IP, URL and domain name of Godlua Backdoor on your network.\n\n\n#### Contact us\n\nReaders are always welcomed to reach us on [**twitter**](https://twitter.com/360Netlab), WeChat 360Netlab or email to netlab at 360 dot cn.\n\n\n#### IoC list\nSample MD5\n```\n870319967dba4bd02c7a7f8be8ece94f\nc9b712f6c347edde22836fb43b927633\n75902cf93397d2e2d1797cd115f8347a\n```\n\nURL\n```\nhttps://helegedada.github.io/test/test\nhttps://api.github.com/repos/helegedada/heihei\nhttp://198.204.231.250/linux-x64\nhttp://198.204.231.250/linux-x86\nhttps://dd.heheda.tk/i.jpg\nhttps://dd.heheda.tk/i.sh\nhttps://dd.heheda.tk/x86_64-static-linux-uclibc.jpg\nhttps://dd.heheda.tk/i686-static-linux-uclibc.jpg\nhttps://dd.cloudappconfig.com/i.jpg\nhttps://dd.cloudappconfig.com/i.sh\nhttps://dd.cloudappconfig.com/x86_64-static-linux-uclibc.jpg\nhttps://dd.cloudappconfig.com/arm-static-linux-uclibcgnueabi.jpg\nhttps://dd.cloudappconfig.com/i686-static-linux-uclibc.jpg\nhttp://d.cloudappconfig.com/i686-w64-mingw32/Satan.exe\nhttp://d.cloudappconfig.com/x86_64-static-linux-uclibc/Satan\nhttp://d.cloudappconfig.com/i686-static-linux-uclibc/Satan\nhttp://d.cloudappconfig.com/arm-static-linux-uclibcgnueabi/Satan\nhttps://d.cloudappconfig.com/mipsel-static-linux-uclibc/Satan\n```\n\nC2 Domain\n```\nd.heheda.tk\ndd.heheda.tk\nc.heheda.tk\nd.cloudappconfig.com\ndd.cloudappconfig.com\nc.cloudappconfig.com\nf.cloudappconfig.com\nt.cloudappconfig.com\nv.cloudappconfig.com\nimg0.cloudappconfig.com\nimg1.cloudappconfig.com\nimg2.cloudappconfig.com\n```\n\nIP\n```\n198.204.231.250     \tUnited States       \tASN 33387           \tDataShack, LC       \n104.238.151.101     \tJapan               \tASN 20473           \tChoopa, LLC         \n43.224.225.220      \tHong Kong           \tASN 22769           \tDDOSING NETWORK     \n```"}]],"markups":[],"sections":[[10,0],[1,"p",[]]],"ghostVersion":"3.0"}