Fodcha Is Coming Back, Raising A Wave of Ransom  DDoS
<!--kg-card-begin: markdown--><h1 id="background">Background</h1>
<p>On April 13, 2022, 360Netlab first disclosed the <code>Fodcha</code> botnet. After our article was published, Fodcha suffered a crackdown from the relevant authorities, and its authors quickly responded by leaving <code>&quot;Netlab pls leave me alone I surrender&quot;</code> in an updated sample.No surprise, Fodcha's authors didn't really stop updating after the fraudulent surrender, and soon a new version was released.</p>
<p>In the new version, the authors of Fodcha redesigned the communication protocol and started to use <code>xxtea</code> and <code>chacha20</code> algorithms to encrypt sensitive resources and network communications to avoid detection at the file &amp; traffic level; at the same time, a dual-C2 scheme with <code>OpenNIC domain</code> as the primary C2 and <code>ICANN domain</code> as the backup C2 was adopted.</p>
<p>Relying on the strong N-day vulnerability integration capabilities, the comeback of Focha is just as strong as the previous ones. In our data view, in terms of scale, Fodcha has once again developed into a massive botnet with more than <code>60K</code> daily active bots and <code>40+ C2 IPs</code>, we also observed it can easily launch more than 1Tbps DDos traffic; in terms of attacks, Fodcha has an average of <code>100+</code> daily attack targets and more than <code>20,000</code> cumulative attacks, on October 11, Fodcha hit its record and attacked <code>1,396</code> unique targets in that single day.</p>
<p>While Fodcha was busy attacking various targets, it has not forgot to mess with us, we saw it using <code>N3t1@bG@Y</code> in one of it scan payload.</p>
<h1 id="timeline">Timeline</h1>
<p>Backed by our <code>BotMon</code> systems, we have kept good track of Fodcha's sample evolution and DDoS attack instructions, and below are the sample evolution and some important DDoS attack events we have seen. (Note: The Fodcha sample itself does not have a specific flag to indicate its version, this is the version number we use internally for tracking purposes)</p>
<ul>
<li>
<p>On January 12, 2022, the first Fodcha botnet sample was captured.</p>
</li>
<li>
<p>April 13, 2022, Disclosure of the <a href="__GHOST_URL__/fodcha-a-new-ddos-botnet/">Fodcha</a> botnet, containing versions V1, V2.</p>
</li>
<li>
<p>April 19, 2022, captured version V2.x, using <code>OpenNIC's TLDs</code> style C2</p>
</li>
<li>
<p>April 24, 2022, version V3, using xxtea algorithm to encrypt configuration information, adding <code>ICANN's TLDs</code> style C2, adding <code>anti-sandbox</code> &amp; <code>anti-debugging</code> mechanism.</p>
</li>
<li>
<p>June 5, 2022, version V4, using structured configuration information, <code>anti-sandboxing</code> &amp; <code>anti-debugging</code> mechanism were removed.</p>
</li>
<li>
<p>July 7, 2022, version V4.x with an additional set of <code>ICANN C2</code>.</p>
</li>
<li>
<p>On September 21, 2022, a well-known cloud service provider was attacked with traffic exceeding <code>1Tbps</code>.</p>
</li>
</ul>
<h1 id="botnetsize">Botnet Size</h1>
<p>In April, we confirmed that the number of Fodcha's global daily live bots was about <code>60,000</code> <a href="__GHOST_URL__/fodcha-a-new-ddos-botnet/">(refer to our other article)</a>. We don’t have accurate number of the current size, but suspect that the number of current active bots has not dropped, maybe more than <code>60,000</code> now.</p>
<p>There is a positive relationship between the size of a botnet and the number of C2 IPs, and the most parsimonious view is that &quot;the larger the botnet, the more C2 infrastructure it requires. In April, there were <code>10 c2s</code> to control the <code>60,000</code> bots; After that, we observed that the IPs corresponding to its C2 domains continued to increase. Using a simple dig command to query the latest C2 domain name <code>yellowchinks.dyn</code>, we can see it resolves to <code>44 IPs</code>.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_c2infras.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_c2infras.png" class="kg-image"/></a></p>
<p>One likely reason for this is that their botnet is so large that they need to invest more IP resources in order to have a reasonable ratio between Bots and C2s to achieve load balancing.</p>
<h1 id="ddosstatistics">DDoS Statistics</h1>
<p>More C2 IPs cost more money, and it seems that the business is good as it has been very active launching ddos attacks.We have excerpted the data from June 29, 2022 to the present, and the attack trends and target area distribution are as follows.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/image--1-.png"><img src="__GHOST_URL__/content/images/2022/10/image.min-1.png" class="kg-image"/></a></p>
<p>We can see that the ddos attacks has been non-stop, and China and US have the most targets.</p>
<p>The time distribution of the attack instructions within 7 days is shown below, which shows that Fodcha launched DDoS attacks throughout 7 * 24 hours, without any obvious working time zone.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_instimezone.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_instimezone.png" class="kg-image"/></a></p>
<h1 id="sampleanalysis">Sample Analysis</h1>
<p>We have divided the captured samples into four major versions, of which V1and <code>V2</code> have been analyzed in the previous blog, here we select the latest <code>V4</code> series samples as the main object of analysis, their basic information is shown below.</p>
<pre><code>MD5: ea7945724837f019507fd613ba3e1da9
ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), stripped
LIB: uclibc
PACKER: None
version: V4

MD5: 899047ddf6f62f07150837aef0c1ebfb
ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped
Lib: uclibc
Packer: None
Version: V4.X
</code></pre>
<p>When Fodcha's Bot executes, it will first check <code>the operating parameters</code>, <code>network connectivity</code>, <code>whether the &quot;LD_PRELOAD&quot; environment variable is set</code>, and <code>whether it is debugged</code>. These checks can be seen as a simple countermeasure to the typical emulator &amp; sandbox.</p>
<p>When the requirements are met, it first decrypts the configuration information and print “snow slide” on the Console, then there are some common host behaviors, such as single instance, process name masquerading, manipulating watchdog, terminating specific port processes, reporting specific process information, etc. The following will focus on the decryption of configuration information, network communication, DDoS attacks and other aspects of Fodcha.</p>
<h2 id="decryptingconfigurationinformationconfig">Decrypting configuration information (Config)</h2>
<p>Fodcha uses a side-by-side Config organization in <code>V2.X</code> and <code>V3</code>, and a structured Config organization in <code>V4</code> and <code>V4.X</code>. The following figure clearly shows the difference.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_disconfig.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_disconfig.png" class="kg-image"/></a></p>
<p>Although the organization of Config is different, their encryption methods are the same. As we can see by the constants referenced in the code snippet below, they use the xxtea algorithm with the key <code>PJbiNbbeasddDfsc</code>.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_xxtea.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_xxtea.png" class="kg-image"/></a></p>
<p>After inversion, we wrote the following <code>IDAPYTHON</code> script to decrypt the configuration information.</p>
<pre><code># md5: ea7945724837f019507fd613ba3e1da9
# requirement: pip install xxtea-py
# test: ida7.6_python3

import ida_bytes
import xxtea

BufBase=0x1F2B0
ConfBase=0x0001F1A0
key=b&quot;PJbiNbbeasddDfsc&quot;
for i in range(17):
    offset=ida_bytes.get_word(i*16+ConfBase+2)
    leng=ida_bytes.get_word(i*16+ConfBase+4)-offset
    buf=ida_bytes.get_bytes(BufBase+offset,leng)
    print(&quot;index:%d, %s&quot; %(i,xxtea.decrypt(buf,key)))
</code></pre>
<p>The decrypted Config information is shown in the following table. You can see that index 11 still retains the aforementioned &quot;surrender&quot; egg, index 12 is worth mentioning, as it is the reporter server address to which Fodcha reports some process-specific information.</p>
<table>
<thead>
<tr>
<th>Index</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>snow slide</td>
</tr>
<tr>
<td>1</td>
<td>/proc/</td>
</tr>
<tr>
<td>2</td>
<td>/stat</td>
</tr>
<tr>
<td>3</td>
<td>/proc/self/exe</td>
</tr>
<tr>
<td>4</td>
<td>/cmdline</td>
</tr>
<tr>
<td>5</td>
<td>/maps</td>
</tr>
<tr>
<td>6</td>
<td>/exe</td>
</tr>
<tr>
<td>7</td>
<td>/lib</td>
</tr>
<tr>
<td>8</td>
<td>/usr/lib</td>
</tr>
<tr>
<td>9</td>
<td>.ri</td>
</tr>
<tr>
<td>10</td>
<td>GET /geoip/?res=10&amp;r HTTP/1.1\r\nHost: 1.1.1.1\r\nConnection: Close\r\n\r\n</td>
</tr>
<tr>
<td>11</td>
<td>Netlab pls leave me alone I surrender</td>
</tr>
<tr>
<td>12</td>
<td>kvsolutions.ru</td>
</tr>
<tr>
<td>13</td>
<td>api.opennicproject.org</td>
</tr>
<tr>
<td>14</td>
<td>watchdog</td>
</tr>
<tr>
<td>15</td>
<td>/dev/</td>
</tr>
<tr>
<td>16</td>
<td>TSource Engine Query</td>
</tr>
</tbody>
</table>
<h2 id="networkcommunication">Network communication</h2>
<p>Fodcha's network communication has a very fixed feature at the code level: a perpetual While loop, with switch-case processing at each stage, so that the CFG graphs generated by each version of Fodcha's network protocol processing functions are highly similar in IDA.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_cfg.png"  width="860px" /> 
<p>In summary, Fodcha's network communication goes through the following four steps.</p>
<ol>
<li>Decryption C2</li>
<li>DNS query</li>
<li>Establishing communication</li>
<li>Execute the command</li>
</ol>
<h3 id="0x1decryptingc2">0x1: Decrypting C2</h3>
<p>Different versions of Fodcha support different types of C2. V2.X has only 1 group of OpenNIC C2; V3 &amp; V4 have 1 group of OpenNIC C2 and 1 group of ICANN C2; and V4.X has the most, 1 group of OpenNIC C2 and 2 groups of ICANN C2, the following diagram shows the difference very clearly.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_c2_dis.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_c2_dis.png" class="kg-image"/></a></p>
<p>Although the types &amp; numbers of C2 are different, their processing logic is almost the same as shown in the figure below.</p>
<p>Firstly, a C2 domain name is obtained through the C2_GET function, and then the corresponding IP of C2 is obtained through the DNS_QUERY function, where the first parameter of C2_GET is the C2 ciphertext data, and the second parameter is the length, while the second parameter of DNS_QUERY implies the type of C2.</p>
<img src="__GHOST_URL__/content/images/2022/10/FODCHA_c2compose.png"  width="860px" /> 
<p>A valid C2 domain name can be obtained through C2_GET, and its internal implementation can be divided into 2 steps.</p>
<ul>
<li>First, the C2 ciphertext data must be decrypted.</li>
<li>Then they are constructed into a legitimate domain name.</li>
</ul>
<h3 id="decryptingc2ciphertextdata">Decrypting C2 ciphertext data</h3>
<p>The C2 ciphertext data uses the same encryption method as the configuration information, i.e. xxtea, and the key is also</p>
<p><code>PJbiNbbeasddDfsc</code>. The OpenNic C2 data can be decrypted by the following simple IDAPYTHON script.</p>
<pre><code>#md5: 899047DDF6F62F07150837AEF0C1EBFB
import xxtea
import ida_bytes
import hexdump
key=b&quot;PJbiNbbeasddDfsc&quot;
buf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2
plaintext=xxtea.decrypt(buf,key)
print(plaintext)
</code></pre>
<p>The decrypted C2 data is shown below, you can see that the C2 data consists of 2 parts, the front is the domain names, the back is the TLDs, they are separated by the &quot;<strong>/</strong>&quot; symbol in the red box.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_c2plaintext.png"  width="860px" /> 
<h3 id="constructingadomainname">Constructing a domain name</h3>
<p>Fodcha has a specific domain name construction method, and the equivalent Python implementation is shown below.</p>
<pre><code># md5: 899047ddf6f62f07150837aef0c1ebfb
# requirement: pip install xxtea-py
# test: ida7.6_python3

import xxtea
import ida_bytes

def getcnt(length):
    cnt=1
    while True:
        cnt +=1
        calc=2
        
        for i in range(1,cnt):
            calc+=2+12*i%cnt
                    
        if calc +cnt==length-1:
            return cnt

                        
key=b&quot;PJbiNbbeasddDfsc&quot;
buf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2
plaintext=xxtea.decrypt(buf,key)

domains,tlds=plaintext.split(b'/')
domainList=domains.split(b',')
tldList=tlds.split(b',')

cnt=getcnt(len(domainList))

print(&quot;------------There're %d C2------------&quot; %cnt)
coff=2
for i in range(0,cnt):
    if i ==0:
        c2Prefix=domainList[i+coff]
    else:
        coff+=12*i %cnt+2
        c2Prefix=domainList[i+coff]
    c2Tld=tldList[(cnt-i-1)*3]
    print(c2Prefix + b'.' + c2Tld)

</code></pre>
<p>Taking the C2 data obtained above as input, the following 14 OpenNIC C2s are finally constructed.</p>
<pre><code>techsupporthelpars.oss
yellowchinks.geek
yellowchinks.dyn
wearelegal.geek
funnyyellowpeople.libre
chinksdogeaters.dyn
blackpeeps.dyn
pepperfan.geek
chinkchink.libre
peepeepoo.libre
respectkkk.geek
bladderfull.indy
tsengtsing.libre
obamalover.pirate
</code></pre>
<p>Readers familiar with the ICANN domain name system may think at first glance that our decryption is wrong, because the ICANN domain name system does not support these TLDs, they would be &quot;unresolvable&quot;, but in fact they are the domain names under the OpenNIC system, OpenNIC is independent of the OpenNIC, which supports the TLDs shown in the figure below. The domain names of OpenNIC cannot be resolved by common DNS (such as <code>8.8.8.8</code>, <code>101.198.198.198</code>) and must use the specified NameServer. Readers can check out <a href="https://www.opennic.org/">OpenNIC’s official website</a> for more details.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_opennic.png"  width="860px" /> 
<p>Using the same method, we can get the following 4 ICANN C2s.</p>
<pre><code>cookiemonsterboob[.]com
forwardchinks[.]com
doodleching[.]com
milfsfors3x[.]com
</code></pre>
<h3 id="0x2dnslookup">0X2: DNS lookup</h3>
<p>When the C2 domain name is successfully obtained, Bot performs the domain name resolution through the function <code>DNS_QUERY</code>, its 2nd parameter is a FLAG, which implies the different processing of OpenNIC/ICANN C2, and the corresponding code snippet is shown below.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_disdns.png"  width="860px" /> 
<p>It can be seen that there are 2 options for the resolution of OpenNIC C2.</p>
<ul>
<li>Option 1: Request from <code>api.opennicproject.org</code> through API interface to get nameserver dynamically</li>
</ul>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_resolvns.png"  width="860px" /> 
<ul>
<li>Option 2: Use the hard-coded nameserver shown in the figure below</li>
</ul>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_opennicHard.png"  width="860px" /> 
<p>For ICANN C2, there is only one option, i.e., use the hard-coded nameserver shown in the figure below.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_iccanHard.png"  width="860px" /> 
<p>The actual resolution of C2 <code>techsupporthelpars.oss</code>, for example, is reflected in the network traffic as follows.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_opendnsexample.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_opendnsexample.png" class="kg-image"/></a></p>
<h3 id="whyuseopennicicanndualc2">Why use OpenNIC / ICANN dual C2?</h3>
<p>Fodcha's author has built a redundant OpenNIC / ICANN dual-C2 architecture, why did he do so?</p>
<p>From a C2 infrastructure perspective, after Fodcha was exposed, its C2 was added to various security lists. <code>Quad9DNS (9.9.9.9)</code>, for example, had sent a tweet about Fodcha domain traffic spike</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_quad.png"  width="860px" /> 
<p>After Fodcha was cracked down, its author, when reselecting the C2 infrastructure, looked at the <code>DNS Neutrality</code> feature touted by OpenNIC to eliminate the possibility of C2 being regulated &amp; taken over.</p>
<p>At the same time, OpenNIC based C2 has it own problems, such as the NameServer of OpenNIC may not be accessible in some regions, or there are efficiency or stability problems in domain name resolution. For the sake of robustness, Fodcha authors re-added ICANN C2 as the backup C2 after V3 to form a redundant structure with the main C2.</p>
<h3 id="0x3establishingcommunication">0x3: Establishing communication</h3>
<p>Fodcha Bot establishes a connection to C2 through the following code snippet, which has a total of 22 ports.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_establishConn.png"  width="860px" /> 
<p>Once the connection with C2 is successfully established, the Bot and C2 must go through 3 phases of interaction before communication is actually established.</p>
<ul>
<li>
<p>Stage 1: Bot requests the key&amp;nonce of the chacha20 encryption algorithm from C2.</p>
</li>
<li>
<p>Stage 2: Bot and C2 use the key&amp;nonce from stage 1 for identity confirmation.</p>
</li>
<li>
<p>Stage 3: Bot sends the encrypted upline &amp; group information to C2.</p>
</li>
</ul>
<p>To aid in the analysis, we ran the Bot sample within a restricted environment and used <code>fsdsaD</code> as the packet string to generate the network traffic shown in the figure below, and the details of how this traffic was generated are described below.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_prapacket.png"  width="860px" /> 
<h4 id="stage1botc2formattedashead7bytesbodyrandom2040bytes">Stage 1: Bot ---&gt; C2 ,formatted as head(7 bytes) + body( random 20-40 bytes)</h4>
<p>Bot actively sends an initialization message with <code>netstage=6</code> to C2, this message has the format of head+body, and the meaning of each field is shown below.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageOneb2c.png"  width="860px" /> 
<h4 id="head">head</h4>
<p>The length of head is 7 bytes, and the format is shown below.</p>
<pre><code>06     		----&gt;netstage,1byte,06 means init
f0 70       ----&gt;tcpip checksum, 2byte, 
00 16		----&gt;length of body, 2 bytes
</code></pre>
<h4 id="checksum">checksum</h4>
<p>checksum<br>
The checksum in head uses the tcp/ip checksum, which is calculated for the whole payload, and the original value of the checksum offset is <code>\x00\x00</code>, and the python implementation of the checksum is as follows.</p>
<pre><code class="language-python">def checksum(data):
    s = 0
    n = len(data) % 2
    for i in range(0, len(data)-n, 2):
        s+= ord(data[i]) + (ord(data[i+1]) &lt;&lt; 8)
    if n:
        s+= ord(data[-1])
    while (s &gt;&gt; 16):
        s = (s &amp; 0xFFFF) + (s &gt;&gt; 16)
        s = ~s &amp; 0xffff
    return s

buf=&quot;\x06\x00\x00\x00\x00\x00\x16\x36\x93\x93\xb7\x27\x5c\x9a\x2a\x16\x09\xd8\x13\x32\x01\xd2\x69\x1d\x25\xf3\x42\x00\x32&quot;
print(hex(checksum(buf)))

#hex(checksum(buf))
#0x70f0
</code></pre>
<h4 id="body">body</h4>
<p>body is a randomly generated content, meaningless.</p>
<pre><code>00000000  36 93 93 b7 27 5c 9a 2a 16 09 d8 13 32 01 d2 69
00000010  1d 25 f3 42 00 32
</code></pre>
<h4 id="stage1c2bot2rounds">Stage 1: C2--&gt;Bot, 2 rounds</h4>
<p>When C2 receives the message <code>netstage=6</code> from Bot, it will send 2 rounds of data to BOT.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageOne.png"  width="860px" /> 
<ul>
<li>
<p>The first round, 36 bytes , the original message is encrypted by xxtea and decrypted as the key of chacha20, with the length of 32bytes</p>
<pre><code class="language-python">import hexdump
import xxtea
key=b&quot;PJbiNbbeasddDfsc&quot;
keyBuf=bytes.fromhex(&quot;806d8806cd5460d8996339fbf7bac34ba1e20f792872ba0e05d096ad92a5535e60e55b8d&quot;)
chaKey=xxtea.decrypt(keyBuf,key)
hexdump.hexdump(chaKey)

#chaKey
00000000: E6 7B 1A E3 A4 4B 13 7F  14 15 5E 99 31 F2 5E 3A
00000010: D7 7B AB 0A 4D 5F 00 EF  0C 01 9F 86 94 A4 9D 4B

</code></pre>
</li>
<li>
<p>Second round, 16 bytes , the original message is encrypted by xxtea, decrypted as the nonce of chacha20, length 12bytes</p>
<pre><code class="language-python">import hexdump
import xxtea
key=b&quot;PJbiNbbeasddDfsc&quot;
nonBuf=bytes.fromhex(&quot;22c803bb310c5b2512e76a472418f9ee&quot;)
chaNonce=xxtea.decrypt(nonBuf,key)
hexdump.hexdump(chaNonce)

#chaNonce
00000000: 98 79 59 57 A8 BA 7E 13  59 9F 59 6F
</code></pre>
</li>
</ul>
<h4 id="stage2botc2chacha20encryption">Stage 2: Bot---&gt;C2, chacha20 encryption</h4>
<p>Once Bot receives the key and nonce of chacha20, it sends the message <code>netstage=4</code> to C2, this time the message is encrypted using chacha20, the key&amp;nonce is obtained from the previous stage, the number of rounds encrypted is 1.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageTwob2c.png"  width="860px" /> 
<p>We can decrypt the above traffic using the following python code that</p>
<pre><code>from Crypto.Cipher import ChaCha20
cha=ChaCha20.new(key=chaKey,nonce=chaNonce)
cha.seek(64)
tmp=bytes.fromhex('dc23c56943431018b61262481ce5a219da9480930f08714e017edc56bf903d32ac5daeb8314f1bf7e6')
rnd3=cha.decrypt(tmp)
</code></pre>
<p>The decrypted traffic is shown below, it still has the format of head (7 bytes) + body as described before, where the value of the netstage field of head is 04, which represents the authentication.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netplainb2c.png"  width="860px" /> 
<h4 id="stage2c2botchacha20encryption">Stage 2: C2 ---&gt; Bot, chacha20 encryption</h4>
<p>After receiving the authentication message from Bot, C2 also sends a message with <code>netstage=4</code> to Bot's data, also using chacha20 encryption, and the key,nonce,round number is the same as that used by Bot.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageTwoc2b.png"  width="860px" /> 
<p>Using the same code as Bot to decrypt the traffic, we can see that its format is also head+body, and the value of netstage is also 04.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netplainc2b.png"  width="860px" /> 
<p>After Bot and C2 send each other the message <code>netstage=4</code>, the chacha20 key&amp;nonce representing stage 1 is recognized by both parties, and the authentication of each other is completed, and Bot enters the next stage to prepare to go online.</p>
<h4 id="stage3botc22roundschachaencryption">Stage 3: Bot---&gt;C2, 2 rounds, chacha encryption</h4>
<p>Bot sends netstage=5 message to C2 to indicate that it is ready to go online, and then reports its own grouping information to C2, these 2 rounds of messages also use chacha20 encryption.</p>
<ul>
<li>
<p>First round<br>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageThrReg.png"  width="860px" /></p>
</li>
<li>
<p>Second round</p>
 <img src="__GHOST_URL__/content/images/2022/10/fodcha_netStageThrGroup.png"  width="860px" /> 
</li>
</ul>
<p>After the above two rounds of data decryption, we can see that the content of the group is exactly the preset <code>fsdsaD</code>, which means our analysis is correct, so the Bot is successfully online and starts to wait for the execution of the command sent by C2.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_netplainb2cReg.png"  width="860px" /> 
<h3 id="0x4executecommand">0x4: Execute command</h3>
<p>Bot successfully online, support the netstage number, as shown in the figure below, the most important is the <code>netstage = 1</code> on behalf of the DDoS task, Fodcha reuse a large number of Mirai attack code, a total of <code>17</code> kinds of attack methods are supported.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_afterreg.png"  width="860px" /> 
<p>Take the following <code>DDos_Task</code> traffic <code>(netstage=01)</code> as an example.</p>
<img src="__GHOST_URL__/content/images/2022/10/fodcha_taskddos.png"  width="860px" /> 
<p>The attack instructions are still encrypted using <code>chacha20</code>, and the decrypted instructions are shown below, which might ring a bell for readers who are familiar with <code>Mirai</code>.</p>
<pre><code>00000000: 00 00 00 3C 07 01 xx 14  93 01 20 02 00 00 02 01
00000010: BB 01 00 02 00 01
</code></pre>
<p>The format and parsing of the above attack instructions are shown in the following table.</p>
<table>
<thead>
<tr>
<th>offset</th>
<th>len (bytes)</th>
<th>value</th>
<th>meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td>0x00</td>
<td>4</td>
<td>00 00 00 3c</td>
<td>Duration</td>
</tr>
<tr>
<td>0x04</td>
<td>1</td>
<td>07</td>
<td>Attack Vector，07</td>
</tr>
<tr>
<td>0x05</td>
<td>1</td>
<td>1</td>
<td>Attack Target Cnt</td>
</tr>
<tr>
<td>0x06</td>
<td>4</td>
<td>xx 14  93 01</td>
<td>Attack Target，xx.20.147.1</td>
</tr>
<tr>
<td>0x0a</td>
<td>1</td>
<td>20</td>
<td>Netmask</td>
</tr>
<tr>
<td>0x0b</td>
<td>1</td>
<td>02</td>
<td>Option Cnt</td>
</tr>
<tr>
<td>0x0c</td>
<td>5</td>
<td>00 00 02 01 bb</td>
<td>OptionId 0，len 2, value 0x01bb ---&gt; (port 443)</td>
</tr>
<tr>
<td>0x11</td>
<td>5</td>
<td>01 00 02 00 01</td>
<td>OptionId 1, len 2, value 0x0001---&gt; (payload len 1 byte)</td>
</tr>
</tbody>
</table>
<p>When Bot receives the above instruction, it will use the tcp message with a payload of 1 byte to conduct a DDoS attack on the target <code>xx.20.147.1:443</code>, which corresponds to the actual packet capture traffic.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_ddospacket.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_ddospacket.png" class="kg-image"/></a></p>
<h1 id="misc">Misc</h1>
<h3 id="0x01racism">0x01: Racism</h3>
<p>From some of the OpenNIC C2 constructs, it seems that the author of Fodcha is more hostile to people from some regions.</p>
<pre><code>yellowchinks.geek
wearelegal.geek
funnyyellowpeople.libre
chinksdogeaters.dyn
blackpeeps.dyn
bladderfull.indy

wehateyellow
</code></pre>
<h3 id="0x02ransomddos">0x02: Ransom DDoS</h3>
<p>Fodcha had the following string attached to the UDP attack command it issued.</p>
<pre><code>send 10 xmr to 49UnJhpvRRxDXJHYczoUEiK3EKCQZorZWaV6HD7axKGQd5xpUQeNp7Xg9RATFpL4u8dzPfAnuMYqs2Kch1soaf5B5mdfJ1b or we will shutdown your business
</code></pre>
<p>The corresponding attack traffic is shown below, the wallet address appears to be illegal, perhaps the operators behind Fodcha are experimenting with the attack-as-ransom business model, we will see how it evolve.</p>
<p><a href="__GHOST_URL__/content/images/2022/10/fodcha_ddosransom.png"><img src="__GHOST_URL__/content/images/2022/10/fodcha_ddosransom.png" class="kg-image"/></a></p>
<h1 id="contactus">Contact us</h1>
<p>Readers are always welcomed to reach us on <a href="https://twitter.com/360Netlab">twitter</a> or email us to netlab[at]360.cn.</p>
<h1 id="ioc">IoC</h1>
<h3 id="c2">C2</h3>
<pre><code>v1,v2:
folded[.]in
fridgexperts[.]cc

ICANN C2:
forwardchinks[.]com
doodleching[.]com
cookiemonsterboob[.]com
milfsfors3x[.]com

OpenNIC C2:

yellowchinks.geek
yellowchinks.dyn
wearelegal.geek
tsengtsing.libre
techsupporthelpars.oss
respectkkk.geek
pepperfan.geek
peepeepoo.libre
obamalover.pirate
funnyyellowpeople.libre
chinksdogeaters.dyn
chinkchink.libre
bladderfull.indy
blackpeeps.dyn
91.206.93.243
91.149.232.129
91.149.232.128
91.149.222.133
91.149.222.132
67.207.84.82
54.37.243.73
51.89.239.122
51.89.238.199
51.89.176.228
51.89.171.33
51.161.98.214
46.17.47.212
46.17.41.79
45.88.221.143
45.61.139.116
45.41.240.145
45.147.200.168
45.140.169.122
45.135.135.33
3.70.127.241
3.65.206.229
3.122.255.225
3.121.234.237
3.0.58.143
23.183.83.171
207.154.206.0
207.154.199.110
195.211.96.142
195.133.53.157
195.133.53.148
194.87.197.3
194.53.108.94
194.53.108.159
194.195.117.167
194.156.224.102
194.147.87.242
194.147.86.22
193.233.253.93
193.233.253.220
193.203.12.157
193.203.12.156
193.203.12.155
193.203.12.154
193.203.12.151
193.203.12.123
193.124.24.42
192.46.225.170
185.45.192.96
185.45.192.227
185.45.192.212
185.45.192.124
185.45.192.103
185.198.57.95
185.198.57.105
185.183.98.205
185.183.96.7
185.143.221.129
185.143.220.75
185.141.27.238
185.141.27.234
185.117.75.45
185.117.75.34
185.117.75.119
185.117.73.52
185.117.73.147
185.117.73.115
185.117.73.109
18.185.188.32
18.136.209.2
178.62.204.81
176.97.210.176
172.105.59.204
172.105.55.131
172.104.108.53
170.187.187.99
167.114.124.77
165.227.19.36
159.65.158.148
159.223.39.133
157.230.15.82
15.204.18.232
15.204.18.203
15.204.128.25
149.56.42.246
139.99.166.217
139.99.153.49
139.99.142.215
139.162.69.4
138.68.10.149
137.74.65.164
13.229.98.186
107.181.160.173
107.181.160.172
</code></pre>
<h3 id="reporter">Reporter</h3>
<pre><code>kvsolutions[.]ru
icarlyfanss[.]com
</code></pre>
<h3 id="samples">Samples</h3>
<pre><code>ea7945724837f019507fd613ba3e1da9
899047ddf6f62f07150837aef0c1ebfb
0f781868d4b9203569357b2dbc46ef10
</code></pre>
<!--kg-card-end: markdown-->
Background


On April 13, 2022, 360Netlab first disclosed the Fodcha botnet. After our article was published, Fodcha suffered a crackdown from the relevant authorities, and its authors quickly responded by leaving "Netlab pls leave me alone I surrender" in an updated sample.No surprise, Fodcha's authors didn't really stop updating after the fraudulent surrender, and soon a new version was released.


In the new version, the authors of Fodcha redesigned the communication protocol and started to use xxtea and chacha20 algorithms to encrypt sensitive resources and network communications to avoid detection at the file & traffic level; at the same time, a dual-C2 scheme with OpenNIC domain as the primary C2 and ICANN domain as the backup C2 was adopted.


Relying on the strong N-day vulnerability integration capabilities, the comeback of Focha is just as strong as the previous ones. In our data view, in terms of scale, Fodcha has once again developed into a massive botnet with more than 60K daily active bots and 40+ C2 IPs, we also observed it can easily launch more than 1Tbps DDos traffic; in terms of attacks, Fodcha has an average of 100+ daily attack targets and more than 20,000 cumulative attacks, on October 11, Fodcha hit its record and attacked 1,396 unique targets in that single day.


While Fodcha was busy attacking various targets, it has not forgot to mess with us, we saw it using N3t1@bG@Y in one of it scan payload.



Timeline


Backed by our BotMon systems, we have kept good track of Fodcha's sample evolution and DDoS attack instructions, and below are the sample evolution and some important DDoS attack events we have seen. (Note: The Fodcha sample itself does not have a specific flag to indicate its version, this is the version number we use internally for tracking purposes)


 * 
   
   
   On January 12, 2022, the first Fodcha botnet sample was captured.
   

 * 
   
   
   April 13, 2022, Disclosure of the Fodcha botnet, containing versions V1, V2.
   

 * 
   
   
   April 19, 2022, captured version V2.x, using OpenNIC's TLDs style C2
   

 * 
   
   
   April 24, 2022, version V3, using xxtea algorithm to encrypt configuration information, adding ICANN's TLDs style C2, adding anti-sandbox & anti-debugging mechanism.
   

 * 
   
   
   June 5, 2022, version V4, using structured configuration information, anti-sandboxing & anti-debugging mechanism were removed.
   

 * 
   
   
   July 7, 2022, version V4.x with an additional set of ICANN C2.
   

 * 
   
   
   On September 21, 2022, a well-known cloud service provider was attacked with traffic exceeding 1Tbps.
   



Botnet Size


In April, we confirmed that the number of Fodcha's global daily live bots was about 60,000 (refer to our other article). We don’t have accurate number of the current size, but suspect that the number of current active bots has not dropped, maybe more than 60,000 now.


There is a positive relationship between the size of a botnet and the number of C2 IPs, and the most parsimonious view is that "the larger the botnet, the more C2 infrastructure it requires. In April, there were 10 c2s to control the 60,000 bots; After that, we observed that the IPs corresponding to its C2 domains continued to increase. Using a simple dig command to query the latest C2 domain name yellowchinks.dyn, we can see it resolves to 44 IPs.





One likely reason for this is that their botnet is so large that they need to invest more IP resources in order to have a reasonable ratio between Bots and C2s to achieve load balancing.



DDoS Statistics


More C2 IPs cost more money, and it seems that the business is good as it has been very active launching ddos attacks.We have excerpted the data from June 29, 2022 to the present, and the attack trends and target area distribution are as follows.





We can see that the ddos attacks has been non-stop, and China and US have the most targets.


The time distribution of the attack instructions within 7 days is shown below, which shows that Fodcha launched DDoS attacks throughout 7 * 24 hours, without any obvious working time zone.






Sample Analysis


We have divided the captured samples into four major versions, of which V1and V2 have been analyzed in the previous blog, here we select the latest V4 series samples as the main object of analysis, their basic information is shown below.


MD5: ea7945724837f019507fd613ba3e1da9
ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), stripped
LIB: uclibc
PACKER: None
version: V4

MD5: 899047ddf6f62f07150837aef0c1ebfb
ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped
Lib: uclibc
Packer: None
Version: V4.X



When Fodcha's Bot executes, it will first check the operating parameters, network connectivity, whether the "LD_PRELOAD" environment variable is set, and whether it is debugged. These checks can be seen as a simple countermeasure to the typical emulator & sandbox.


When the requirements are met, it first decrypts the configuration information and print “snow slide” on the Console, then there are some common host behaviors, such as single instance, process name masquerading, manipulating watchdog, terminating specific port processes, reporting specific process information, etc. The following will focus on the decryption of configuration information, network communication, DDoS attacks and other aspects of Fodcha.



Decrypting configuration information (Config)


Fodcha uses a side-by-side Config organization in V2.X and V3, and a structured Config organization in V4 and V4.X. The following figure clearly shows the difference.





Although the organization of Config is different, their encryption methods are the same. As we can see by the constants referenced in the code snippet below, they use the xxtea algorithm with the key PJbiNbbeasddDfsc.





After inversion, we wrote the following IDAPYTHON script to decrypt the configuration information.


# md5: ea7945724837f019507fd613ba3e1da9
# requirement: pip install xxtea-py
# test: ida7.6_python3

import ida_bytes
import xxtea

BufBase=0x1F2B0
ConfBase=0x0001F1A0
key=b"PJbiNbbeasddDfsc"
for i in range(17):
    offset=ida_bytes.get_word(i*16+ConfBase+2)
    leng=ida_bytes.get_word(i*16+ConfBase+4)-offset
    buf=ida_bytes.get_bytes(BufBase+offset,leng)
    print("index:%d, %s" %(i,xxtea.decrypt(buf,key)))



The decrypted Config information is shown in the following table. You can see that index 11 still retains the aforementioned "surrender" egg, index 12 is worth mentioning, as it is the reporter server address to which Fodcha reports some process-specific information.





Index
Value




0
snow slide


1
/proc/


2
/stat


3
/proc/self/exe


4
/cmdline


5
/maps


6
/exe


7
/lib


8
/usr/lib


9
.ri


10
GET /geoip/?res=10&r HTTP/1.1\r\nHost: 1.1.1.1\r\nConnection: Close\r\n\r\n


11
Netlab pls leave me alone I surrender


12
kvsolutions.ru


13
api.opennicproject.org


14
watchdog


15
/dev/


16
TSource Engine Query






Network communication


Fodcha's network communication has a very fixed feature at the code level: a perpetual While loop, with switch-case processing at each stage, so that the CFG graphs generated by each version of Fodcha's network protocol processing functions are highly similar in IDA.



In summary, Fodcha's network communication goes through the following four steps.


 1. Decryption C2
 2. DNS query
 3. Establishing communication
 4. Execute the command



0x1: Decrypting C2


Different versions of Fodcha support different types of C2. V2.X has only 1 group of OpenNIC C2; V3 & V4 have 1 group of OpenNIC C2 and 1 group of ICANN C2; and V4.X has the most, 1 group of OpenNIC C2 and 2 groups of ICANN C2, the following diagram shows the difference very clearly.





Although the types & numbers of C2 are different, their processing logic is almost the same as shown in the figure below.


Firstly, a C2 domain name is obtained through the C2_GET function, and then the corresponding IP of C2 is obtained through the DNS_QUERY function, where the first parameter of C2_GET is the C2 ciphertext data, and the second parameter is the length, while the second parameter of DNS_QUERY implies the type of C2.



A valid C2 domain name can be obtained through C2_GET, and its internal implementation can be divided into 2 steps.


 * First, the C2 ciphertext data must be decrypted.
 * Then they are constructed into a legitimate domain name.



Decrypting C2 ciphertext data


The C2 ciphertext data uses the same encryption method as the configuration information, i.e. xxtea, and the key is also


PJbiNbbeasddDfsc. The OpenNic C2 data can be decrypted by the following simple IDAPYTHON script.


#md5: 899047DDF6F62F07150837AEF0C1EBFB
import xxtea
import ida_bytes
import hexdump
key=b"PJbiNbbeasddDfsc"
buf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2
plaintext=xxtea.decrypt(buf,key)
print(plaintext)



The decrypted C2 data is shown below, you can see that the C2 data consists of 2 parts, the front is the domain names, the back is the TLDs, they are separated by the "/" symbol in the red box.




Constructing a domain name


Fodcha has a specific domain name construction method, and the equivalent Python implementation is shown below.


# md5: 899047ddf6f62f07150837aef0c1ebfb
# requirement: pip install xxtea-py
# test: ida7.6_python3

import xxtea
import ida_bytes

def getcnt(length):
    cnt=1
    while True:
        cnt +=1
        calc=2
        
        for i in range(1,cnt):
            calc+=2+12*i%cnt
                    
        if calc +cnt==length-1:
            return cnt

                        
key=b"PJbiNbbeasddDfsc"
buf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2
plaintext=xxtea.decrypt(buf,key)

domains,tlds=plaintext.split(b'/')
domainList=domains.split(b',')
tldList=tlds.split(b',')

cnt=getcnt(len(domainList))

print("------------There're %d C2------------" %cnt)
coff=2
for i in range(0,cnt):
    if i ==0:
        c2Prefix=domainList[i+coff]
    else:
        coff+=12*i %cnt+2
        c2Prefix=domainList[i+coff]
    c2Tld=tldList[(cnt-i-1)*3]
    print(c2Prefix + b'.' + c2Tld)




Taking the C2 data obtained above as input, the following 14 OpenNIC C2s are finally constructed.


techsupporthelpars.oss
yellowchinks.geek
yellowchinks.dyn
wearelegal.geek
funnyyellowpeople.libre
chinksdogeaters.dyn
blackpeeps.dyn
pepperfan.geek
chinkchink.libre
peepeepoo.libre
respectkkk.geek
bladderfull.indy
tsengtsing.libre
obamalover.pirate



Readers familiar with the ICANN domain name system may think at first glance that our decryption is wrong, because the ICANN domain name system does not support these TLDs, they would be "unresolvable", but in fact they are the domain names under the OpenNIC system, OpenNIC is independent of the OpenNIC, which supports the TLDs shown in the figure below. The domain names of OpenNIC cannot be resolved by common DNS (such as 8.8.8.8, 101.198.198.198) and must use the specified NameServer. Readers can check out OpenNIC’s official website for more details.



Using the same method, we can get the following 4 ICANN C2s.


cookiemonsterboob[.]com
forwardchinks[.]com
doodleching[.]com
milfsfors3x[.]com




0X2: DNS lookup


When the C2 domain name is successfully obtained, Bot performs the domain name resolution through the function DNS_QUERY, its 2nd parameter is a FLAG, which implies the different processing of OpenNIC/ICANN C2, and the corresponding code snippet is shown below.



It can be seen that there are 2 options for the resolution of OpenNIC C2.


 * Option 1: Request from api.opennicproject.org through API interface to get nameserver dynamically



 * Option 2: Use the hard-coded nameserver shown in the figure below



For ICANN C2, there is only one option, i.e., use the hard-coded nameserver shown in the figure below.



The actual resolution of C2 techsupporthelpars.oss, for example, is reflected in the network traffic as follows.






Why use OpenNIC / ICANN dual C2?


Fodcha's author has built a redundant OpenNIC / ICANN dual-C2 architecture, why did he do so?


From a C2 infrastructure perspective, after Fodcha was exposed, its C2 was added to various security lists. Quad9DNS (9.9.9.9), for example, had sent a tweet about Fodcha domain traffic spike



After Fodcha was cracked down, its author, when reselecting the C2 infrastructure, looked at the DNS Neutrality feature touted by OpenNIC to eliminate the possibility of C2 being regulated & taken over.


At the same time, OpenNIC based C2 has it own problems, such as the NameServer of OpenNIC may not be accessible in some regions, or there are efficiency or stability problems in domain name resolution. For the sake of robustness, Fodcha authors re-added ICANN C2 as the backup C2 after V3 to form a redundant structure with the main C2.



0x3: Establishing communication


Fodcha Bot establishes a connection to C2 through the following code snippet, which has a total of 22 ports.



Once the connection with C2 is successfully established, the Bot and C2 must go through 3 phases of interaction before communication is actually established.


 * 
   
   
   Stage 1: Bot requests the key&nonce of the chacha20 encryption algorithm from C2.
   

 * 
   
   
   Stage 2: Bot and C2 use the key&nonce from stage 1 for identity confirmation.
   

 * 
   
   
   Stage 3: Bot sends the encrypted upline & group information to C2.
   


To aid in the analysis, we ran the Bot sample within a restricted environment and used fsdsaD as the packet string to generate the network traffic shown in the figure below, and the details of how this traffic was generated are described below.



Stage 1: Bot ---> C2 ,formatted as head(7 bytes) + body( random 20-40 bytes)


Bot actively sends an initialization message with netstage=6 to C2, this message has the format of head+body, and the meaning of each field is shown below.



head


The length of head is 7 bytes, and the format is shown below.


06     		---->netstage,1byte,06 means init
f0 70       ---->tcpip checksum, 2byte, 
00 16		---->length of body, 2 bytes



checksum


checksum

The checksum in head uses the tcp/ip checksum, which is calculated for the whole payload, and the original value of the checksum offset is \x00\x00, and the python implementation of the checksum is as follows.


def checksum(data):
    s = 0
    n = len(data) % 2
    for i in range(0, len(data)-n, 2):
        s+= ord(data[i]) + (ord(data[i+1]) << 8)
    if n:
        s+= ord(data[-1])
    while (s >> 16):
        s = (s & 0xFFFF) + (s >> 16)
        s = ~s & 0xffff
    return s

buf="\x06\x00\x00\x00\x00\x00\x16\x36\x93\x93\xb7\x27\x5c\x9a\x2a\x16\x09\xd8\x13\x32\x01\xd2\x69\x1d\x25\xf3\x42\x00\x32"
print(hex(checksum(buf)))

#hex(checksum(buf))
#0x70f0



body


body is a randomly generated content, meaningless.


00000000  36 93 93 b7 27 5c 9a 2a 16 09 d8 13 32 01 d2 69
00000010  1d 25 f3 42 00 32



Stage 1: C2-->Bot, 2 rounds


When C2 receives the message netstage=6 from Bot, it will send 2 rounds of data to BOT.



 * 
   
   
   The first round, 36 bytes , the original message is encrypted by xxtea and decrypted as the key of chacha20, with the length of 32bytes
   
   
   import hexdump
   import xxtea
   key=b"PJbiNbbeasddDfsc"
   keyBuf=bytes.fromhex("806d8806cd5460d8996339fbf7bac34ba1e20f792872ba0e05d096ad92a5535e60e55b8d")
   chaKey=xxtea.decrypt(keyBuf,key)
   hexdump.hexdump(chaKey)
   
   #chaKey
   00000000: E6 7B 1A E3 A4 4B 13 7F  14 15 5E 99 31 F2 5E 3A
   00000010: D7 7B AB 0A 4D 5F 00 EF  0C 01 9F 86 94 A4 9D 4B
   
   
   

 * 
   
   
   Second round, 16 bytes , the original message is encrypted by xxtea, decrypted as the nonce of chacha20, length 12bytes
   
   
   import hexdump
   import xxtea
   key=b"PJbiNbbeasddDfsc"
   nonBuf=bytes.fromhex("22c803bb310c5b2512e76a472418f9ee")
   chaNonce=xxtea.decrypt(nonBuf,key)
   hexdump.hexdump(chaNonce)
   
   #chaNonce
   00000000: 98 79 59 57 A8 BA 7E 13  59 9F 59 6F
   
   


Stage 2: Bot--->C2, chacha20 encryption


Once Bot receives the key and nonce of chacha20, it sends the message netstage=4 to C2, this time the message is encrypted using chacha20, the key&nonce is obtained from the previous stage, the number of rounds encrypted is 1.



We can decrypt the above traffic using the following python code that


from Crypto.Cipher import ChaCha20
cha=ChaCha20.new(key=chaKey,nonce=chaNonce)
cha.seek(64)
tmp=bytes.fromhex('dc23c56943431018b61262481ce5a219da9480930f08714e017edc56bf903d32ac5daeb8314f1bf7e6')
rnd3=cha.decrypt(tmp)



The decrypted traffic is shown below, it still has the format of head (7 bytes) + body as described before, where the value of the netstage field of head is 04, which represents the authentication.



Stage 2: C2 ---> Bot, chacha20 encryption


After receiving the authentication message from Bot, C2 also sends a message with netstage=4 to Bot's data, also using chacha20 encryption, and the key,nonce,round number is the same as that used by Bot.



Using the same code as Bot to decrypt the traffic, we can see that its format is also head+body, and the value of netstage is also 04.



After Bot and C2 send each other the message netstage=4, the chacha20 key&nonce representing stage 1 is recognized by both parties, and the authentication of each other is completed, and Bot enters the next stage to prepare to go online.


Stage 3: Bot--->C2, 2 rounds, chacha encryption


Bot sends netstage=5 message to C2 to indicate that it is ready to go online, and then reports its own grouping information to C2, these 2 rounds of messages also use chacha20 encryption.


 * 
   
   
   First round
   
   
   

 * 
   
   
   Second round
   
   


After the above two rounds of data decryption, we can see that the content of the group is exactly the preset fsdsaD, which means our analysis is correct, so the Bot is successfully online and starts to wait for the execution of the command sent by C2.




0x4: Execute command


Bot successfully online, support the netstage number, as shown in the figure below, the most important is the netstage = 1 on behalf of the DDoS task, Fodcha reuse a large number of Mirai attack code, a total of 17 kinds of attack methods are supported.



Take the following DDos_Task traffic (netstage=01) as an example.



The attack instructions are still encrypted using chacha20, and the decrypted instructions are shown below, which might ring a bell for readers who are familiar with Mirai.


00000000: 00 00 00 3C 07 01 xx 14  93 01 20 02 00 00 02 01
00000010: BB 01 00 02 00 01



The format and parsing of the above attack instructions are shown in the following table.





offset
len (bytes)
value
meaning




0x00
4
00 00 00 3c
Duration


0x04
1
07
Attack Vector，07


0x05
1
1
Attack Target Cnt


0x06
4
xx 14 93 01
Attack Target，xx.20.147.1


0x0a
1
20
Netmask


0x0b
1
02
Option Cnt


0x0c
5
00 00 02 01 bb
OptionId 0，len 2, value 0x01bb ---> (port 443)


0x11
5
01 00 02 00 01
OptionId 1, len 2, value 0x0001---> (payload len 1 byte)





When Bot receives the above instruction, it will use the tcp message with a payload of 1 byte to conduct a DDoS attack on the target xx.20.147.1:443, which corresponds to the actual packet capture traffic.






Misc



0x01: Racism


From some of the OpenNIC C2 constructs, it seems that the author of Fodcha is more hostile to people from some regions.


yellowchinks.geek
wearelegal.geek
funnyyellowpeople.libre
chinksdogeaters.dyn
blackpeeps.dyn
bladderfull.indy

wehateyellow




0x02: Ransom DDoS


Fodcha had the following string attached to the UDP attack command it issued.


send 10 xmr to 49UnJhpvRRxDXJHYczoUEiK3EKCQZorZWaV6HD7axKGQd5xpUQeNp7Xg9RATFpL4u8dzPfAnuMYqs2Kch1soaf5B5mdfJ1b or we will shutdown your business



The corresponding attack traffic is shown below, the wallet address appears to be illegal, perhaps the operators behind Fodcha are experimenting with the attack-as-ransom business model, we will see how it evolve.






Contact us


Readers are always welcomed to reach us on twitter or email us to netlab[at]360.cn.



IoC



C2


v1,v2:
folded[.]in
fridgexperts[.]cc

ICANN C2:
forwardchinks[.]com
doodleching[.]com
cookiemonsterboob[.]com
milfsfors3x[.]com

OpenNIC C2:

yellowchinks.geek
yellowchinks.dyn
wearelegal.geek
tsengtsing.libre
techsupporthelpars.oss
respectkkk.geek
pepperfan.geek
peepeepoo.libre
obamalover.pirate
funnyyellowpeople.libre
chinksdogeaters.dyn
chinkchink.libre
bladderfull.indy
blackpeeps.dyn
91.206.93.243
91.149.232.129
91.149.232.128
91.149.222.133
91.149.222.132
67.207.84.82
54.37.243.73
51.89.239.122
51.89.238.199
51.89.176.228
51.89.171.33
51.161.98.214
46.17.47.212
46.17.41.79
45.88.221.143
45.61.139.116
45.41.240.145
45.147.200.168
45.140.169.122
45.135.135.33
3.70.127.241
3.65.206.229
3.122.255.225
3.121.234.237
3.0.58.143
23.183.83.171
207.154.206.0
207.154.199.110
195.211.96.142
195.133.53.157
195.133.53.148
194.87.197.3
194.53.108.94
194.53.108.159
194.195.117.167
194.156.224.102
194.147.87.242
194.147.86.22
193.233.253.93
193.233.253.220
193.203.12.157
193.203.12.156
193.203.12.155
193.203.12.154
193.203.12.151
193.203.12.123
193.124.24.42
192.46.225.170
185.45.192.96
185.45.192.227
185.45.192.212
185.45.192.124
185.45.192.103
185.198.57.95
185.198.57.105
185.183.98.205
185.183.96.7
185.143.221.129
185.143.220.75
185.141.27.238
185.141.27.234
185.117.75.45
185.117.75.34
185.117.75.119
185.117.73.52
185.117.73.147
185.117.73.115
185.117.73.109
18.185.188.32
18.136.209.2
178.62.204.81
176.97.210.176
172.105.59.204
172.105.55.131
172.104.108.53
170.187.187.99
167.114.124.77
165.227.19.36
159.65.158.148
159.223.39.133
157.230.15.82
15.204.18.232
15.204.18.203
15.204.128.25
149.56.42.246
139.99.166.217
139.99.153.49
139.99.142.215
139.162.69.4
138.68.10.149
137.74.65.164
13.229.98.186
107.181.160.173
107.181.160.172




Reporter


kvsolutions[.]ru
icarlyfanss[.]com




Samples


ea7945724837f019507fd613ba3e1da9
899047ddf6f62f07150837aef0c1ebfb
0f781868d4b9203569357b2dbc46ef10


{"version":"0.3.1","atoms":[],"cards":[["markdown",{"markdown":"# Background\n\nOn April 13, 2022, 360Netlab first disclosed the `Fodcha` botnet. After our article was published, Fodcha suffered a crackdown from the relevant authorities, and its authors quickly responded by leaving `\"Netlab pls leave me alone I surrender\"` in an updated sample.No surprise, Fodcha's authors didn't really stop updating after the fraudulent surrender, and soon a new version was released.\n\nIn the new version, the authors of Fodcha redesigned the communication protocol and started to use `xxtea` and `chacha20` algorithms to encrypt sensitive resources and network communications to avoid detection at the file & traffic level; at the same time, a dual-C2 scheme with `OpenNIC domain` as the primary C2 and `ICANN domain` as the backup C2 was adopted.\n\nRelying on the strong N-day vulnerability integration capabilities, the comeback of Focha is just as strong as the previous ones. In our data view, in terms of scale, Fodcha has once again developed into a massive botnet with more than `60K` daily active bots and `40+ C2 IPs`, we also observed it can easily launch more than 1Tbps DDos traffic; in terms of attacks, Fodcha has an average of `100+` daily attack targets and more than `20,000` cumulative attacks, on October 11, Fodcha hit its record and attacked `1,396` unique targets in that single day.\n\nWhile Fodcha was busy attacking various targets, it has not forgot to mess with us, we saw it using `N3t1@bG@Y` in one of it scan payload.\n\n# Timeline\n\nBacked by our `BotMon` systems, we have kept good track of Fodcha's sample evolution and DDoS attack instructions, and below are the sample evolution and some important DDoS attack events we have seen. (Note: The Fodcha sample itself does not have a specific flag to indicate its version, this is the version number we use internally for tracking purposes)\n\n* On January 12, 2022, the first Fodcha botnet sample was captured.\n\n* April 13, 2022, Disclosure of the [Fodcha](__GHOST_URL__/fodcha-a-new-ddos-botnet/) botnet, containing versions V1, V2.\n\n* April 19, 2022, captured version V2.x, using `OpenNIC's TLDs` style C2\n\n* April 24, 2022, version V3, using xxtea algorithm to encrypt configuration information, adding `ICANN's TLDs` style C2, adding `anti-sandbox` & `anti-debugging` mechanism.\n\n* June 5, 2022, version V4, using structured configuration information, `anti-sandboxing` & `anti-debugging` mechanism were removed.\n\n* July 7, 2022, version V4.x with an additional set of `ICANN C2`.\n\n* On September 21, 2022, a well-known cloud service provider was attacked with traffic exceeding `1Tbps`.\n  \n\n# Botnet Size\n\nIn April, we confirmed that the number of Fodcha's global daily live bots was about `60,000` [(refer to our other article)](__GHOST_URL__/fodcha-a-new-ddos-botnet/). We don’t have accurate number of the current size, but suspect that the number of current active bots has not dropped, maybe more than `60,000` now.\n\nThere is a positive relationship between the size of a botnet and the number of C2 IPs, and the most parsimonious view is that \"the larger the botnet, the more C2 infrastructure it requires. In April, there were `10 c2s` to control the `60,000` bots; After that, we observed that the IPs corresponding to its C2 domains continued to increase. Using a simple dig command to query the latest C2 domain name `yellowchinks.dyn`, we can see it resolves to `44 IPs`.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_c2infras.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_c2infras.png\" class=\"kg-image\"/></a>\n\nOne likely reason for this is that their botnet is so large that they need to invest more IP resources in order to have a reasonable ratio between Bots and C2s to achieve load balancing.\n\n# DDoS Statistics\n\nMore C2 IPs cost more money, and it seems that the business is good as it has been very active launching ddos attacks.We have excerpted the data from June 29, 2022 to the present, and the attack trends and target area distribution are as follows.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/image--1-.png\"><img src=\"__GHOST_URL__/content/images/2022/10/image.min-1.png\" class=\"kg-image\"/></a>\n\nWe can see that the ddos attacks has been non-stop, and China and US have the most targets. \n\nThe time distribution of the attack instructions within 7 days is shown below, which shows that Fodcha launched DDoS attacks throughout 7 * 24 hours, without any obvious working time zone.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_instimezone.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_instimezone.png\" class=\"kg-image\"/></a>\n\n\n# Sample Analysis\n\nWe have divided the captured samples into four major versions, of which V1and `V2` have been analyzed in the previous blog, here we select the latest `V4` series samples as the main object of analysis, their basic information is shown below.\n\n```\nMD5: ea7945724837f019507fd613ba3e1da9\nELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), stripped\nLIB: uclibc\nPACKER: None\nversion: V4\n\nMD5: 899047ddf6f62f07150837aef0c1ebfb\nELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped\nLib: uclibc\nPacker: None\nVersion: V4.X\n```\n\nWhen Fodcha's Bot executes, it will first check ``the operating parameters``, ``network connectivity``, ``whether the \"LD_PRELOAD\" environment variable is set``, and ``whether it is debugged``. These checks can be seen as a simple countermeasure to the typical emulator & sandbox.\n\nWhen the requirements are met, it first decrypts the configuration information and print “snow slide” on the Console, then there are some common host behaviors, such as single instance, process name masquerading, manipulating watchdog, terminating specific port processes, reporting specific process information, etc. The following will focus on the decryption of configuration information, network communication, DDoS attacks and other aspects of Fodcha.\n\n\n\n## Decrypting configuration information (Config)\n\nFodcha uses a side-by-side Config organization in `V2.X` and `V3`, and a structured Config organization in `V4` and `V4.X`. The following figure clearly shows the difference.\n\n\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_disconfig.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_disconfig.png\" class=\"kg-image\"/></a>\n\n\n\nAlthough the organization of Config is different, their encryption methods are the same. As we can see by the constants referenced in the code snippet below, they use the xxtea algorithm with the key `PJbiNbbeasddDfsc`.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_xxtea.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_xxtea.png\" class=\"kg-image\"/></a>\n\nAfter inversion, we wrote the following `IDAPYTHON` script to decrypt the configuration information.\n\n```\n# md5: ea7945724837f019507fd613ba3e1da9\n# requirement: pip install xxtea-py\n# test: ida7.6_python3\n\nimport ida_bytes\nimport xxtea\n\nBufBase=0x1F2B0\nConfBase=0x0001F1A0\nkey=b\"PJbiNbbeasddDfsc\"\nfor i in range(17):\n    offset=ida_bytes.get_word(i*16+ConfBase+2)\n    leng=ida_bytes.get_word(i*16+ConfBase+4)-offset\n    buf=ida_bytes.get_bytes(BufBase+offset,leng)\n    print(\"index:%d, %s\" %(i,xxtea.decrypt(buf,key)))\n```\n\nThe decrypted Config information is shown in the following table. You can see that index 11 still retains the aforementioned \"surrender\" egg, index 12 is worth mentioning, as it is the reporter server address to which Fodcha reports some process-specific information.\n\n| Index | Value                                                        |\n| ----- | ------------------------------------------------------------ |\n| 0     | snow slide                                                   |\n| 1     | /proc/                                                       |\n| 2     | /stat                                                        |\n| 3     | /proc/self/exe                                               |\n| 4     | /cmdline                                                     |\n| 5     | /maps                                                        |\n| 6     | /exe                                                         |\n| 7     | /lib                                                         |\n| 8     | /usr/lib                                                     |\n| 9     | .ri                                                          |\n| 10    | GET /geoip/?res=10&r HTTP/1.1\\r\\nHost: 1.1.1.1\\r\\nConnection: Close\\r\\n\\r\\n |\n| 11    | Netlab pls leave me alone I surrender                        |\n| 12    | kvsolutions.ru                                               |\n| 13    | api.opennicproject.org                                       |\n| 14    | watchdog                                                     |\n| 15    | /dev/                                                        |\n| 16    | TSource Engine Query                                         |\n\n\n\n## Network communication\n\nFodcha's network communication has a very fixed feature at the code level: a perpetual While loop, with switch-case processing at each stage, so that the CFG graphs generated by each version of Fodcha's network protocol processing functions are highly similar in IDA.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_cfg.png\"  width=\"860px\" /> \n\nIn summary, Fodcha's network communication goes through the following four steps.\n\n1. Decryption C2\n2. DNS query\n3. Establishing communication\n4. Execute the command\n\n\n\n###　0x1: Decrypting C2\n\nDifferent versions of Fodcha support different types of C2. V2.X has only 1 group of OpenNIC C2; V3 & V4 have 1 group of OpenNIC C2 and 1 group of ICANN C2; and V4.X has the most, 1 group of OpenNIC C2 and 2 groups of ICANN C2, the following diagram shows the difference very clearly.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_c2_dis.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_c2_dis.png\" class=\"kg-image\"/></a>\n\nAlthough the types & numbers of C2 are different, their processing logic is almost the same as shown in the figure below.\n\nFirstly, a C2 domain name is obtained through the C2_GET function, and then the corresponding IP of C2 is obtained through the DNS_QUERY function, where the first parameter of C2_GET is the C2 ciphertext data, and the second parameter is the length, while the second parameter of DNS_QUERY implies the type of C2.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/FODCHA_c2compose.png\"  width=\"860px\" /> \n\nA valid C2 domain name can be obtained through C2_GET, and its internal implementation can be divided into 2 steps.\n* First, the C2 ciphertext data must be decrypted.\n* Then they are constructed into a legitimate domain name.\n\n### Decrypting C2 ciphertext data\n\nThe C2 ciphertext data uses the same encryption method as the configuration information, i.e. xxtea, and the key is also \n\n`PJbiNbbeasddDfsc`. The OpenNic C2 data can be decrypted by the following simple IDAPYTHON script.\n\n```\n#md5: 899047DDF6F62F07150837AEF0C1EBFB\nimport xxtea\nimport ida_bytes\nimport hexdump\nkey=b\"PJbiNbbeasddDfsc\"\nbuf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2\nplaintext=xxtea.decrypt(buf,key)\nprint(plaintext)\n```\n\nThe decrypted C2 data is shown below, you can see that the C2 data consists of 2 parts, the front is the domain names, the back is the TLDs, they are separated by the \"**/**\" symbol in the red box.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_c2plaintext.png\"  width=\"860px\" /> \n\n### Constructing a domain name\n\nFodcha has a specific domain name construction method, and the equivalent Python implementation is shown below.\n\n```\n# md5: 899047ddf6f62f07150837aef0c1ebfb\n# requirement: pip install xxtea-py\n# test: ida7.6_python3\n\nimport xxtea\nimport ida_bytes\n\ndef getcnt(length):\n    cnt=1\n    while True:\n        cnt +=1\n        calc=2\n        \n        for i in range(1,cnt):\n            calc+=2+12*i%cnt\n                    \n        if calc +cnt==length-1:\n            return cnt\n\n                        \nkey=b\"PJbiNbbeasddDfsc\"\nbuf=ida_bytes.get_bytes(0x0001CA6C,1568)  # Ciphertext of OpenNic C2\nplaintext=xxtea.decrypt(buf,key)\n\ndomains,tlds=plaintext.split(b'/')\ndomainList=domains.split(b',')\ntldList=tlds.split(b',')\n\ncnt=getcnt(len(domainList))\n\nprint(\"------------There're %d C2------------\" %cnt)\ncoff=2\nfor i in range(0,cnt):\n    if i ==0:\n        c2Prefix=domainList[i+coff]\n    else:\n        coff+=12*i %cnt+2\n        c2Prefix=domainList[i+coff]\n    c2Tld=tldList[(cnt-i-1)*3]\n    print(c2Prefix + b'.' + c2Tld)\n\n```\n\nTaking the C2 data obtained above as input, the following 14 OpenNIC C2s are finally constructed.\n\n```\ntechsupporthelpars.oss\nyellowchinks.geek\nyellowchinks.dyn\nwearelegal.geek\nfunnyyellowpeople.libre\nchinksdogeaters.dyn\nblackpeeps.dyn\npepperfan.geek\nchinkchink.libre\npeepeepoo.libre\nrespectkkk.geek\nbladderfull.indy\ntsengtsing.libre\nobamalover.pirate\n```\n\nReaders familiar with the ICANN domain name system may think at first glance that our decryption is wrong, because the ICANN domain name system does not support these TLDs, they would be \"unresolvable\", but in fact they are the domain names under the OpenNIC system, OpenNIC is independent of the OpenNIC, which supports the TLDs shown in the figure below. The domain names of OpenNIC cannot be resolved by common DNS (such as `8.8.8.8`, `101.198.198.198`) and must use the specified NameServer. Readers can check out [OpenNIC’s official website](https://www.opennic.org/) for more details.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_opennic.png\"  width=\"860px\" /> \n\nUsing the same method, we can get the following 4 ICANN C2s.\n\n```\ncookiemonsterboob[.]com\nforwardchinks[.]com\ndoodleching[.]com\nmilfsfors3x[.]com\n```\n\n### 0X2: DNS lookup\n\nWhen the C2 domain name is successfully obtained, Bot performs the domain name resolution through the function `DNS_QUERY`, its 2nd parameter is a FLAG, which implies the different processing of OpenNIC/ICANN C2, and the corresponding code snippet is shown below.\n\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_disdns.png\"  width=\"860px\" /> \n\nIt can be seen that there are 2 options for the resolution of OpenNIC C2.\n\n* Option 1: Request from `api.opennicproject.org` through API interface to get nameserver dynamically\n\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_resolvns.png\"  width=\"860px\" /> \n\n\n* Option 2: Use the hard-coded nameserver shown in the figure below\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_opennicHard.png\"  width=\"860px\" /> \n\n\nFor ICANN C2, there is only one option, i.e., use the hard-coded nameserver shown in the figure below.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_iccanHard.png\"  width=\"860px\" /> \n\n\n\nThe actual resolution of C2 `techsupporthelpars.oss`, for example, is reflected in the network traffic as follows.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_opendnsexample.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_opendnsexample.png\" class=\"kg-image\"/></a>\n\n### Why use OpenNIC / ICANN dual C2?\n\nFodcha's author has built a redundant OpenNIC / ICANN dual-C2 architecture, why did he do so?\n\nFrom a C2 infrastructure perspective, after Fodcha was exposed, its C2 was added to various security lists. `Quad9DNS (9.9.9.9)`, for example, had sent a tweet about Fodcha domain traffic spike\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_quad.png\"  width=\"860px\" /> \n\nAfter Fodcha was cracked down, its author, when reselecting the C2 infrastructure, looked at the `DNS Neutrality` feature touted by OpenNIC to eliminate the possibility of C2 being regulated & taken over.\n\nAt the same time, OpenNIC based C2 has it own problems, such as the NameServer of OpenNIC may not be accessible in some regions, or there are efficiency or stability problems in domain name resolution. For the sake of robustness, Fodcha authors re-added ICANN C2 as the backup C2 after V3 to form a redundant structure with the main C2.\n\n\n### 0x3: Establishing communication\n\nFodcha Bot establishes a connection to C2 through the following code snippet, which has a total of 22 ports.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_establishConn.png\"  width=\"860px\" /> \n\n\n\nOnce the connection with C2 is successfully established, the Bot and C2 must go through 3 phases of interaction before communication is actually established.\n\n* Stage 1: Bot requests the key&nonce of the chacha20 encryption algorithm from C2.\n\n* Stage 2: Bot and C2 use the key&nonce from stage 1 for identity confirmation.\n\n* Stage 3: Bot sends the encrypted upline & group information to C2.\n\n\nTo aid in the analysis, we ran the Bot sample within a restricted environment and used `fsdsaD` as the packet string to generate the network traffic shown in the figure below, and the details of how this traffic was generated are described below.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_prapacket.png\"  width=\"860px\" /> \n\n####　Stage 1: Bot ---> C2 ,formatted as head(7 bytes) + body( random 20-40 bytes)\n\nBot actively sends an initialization message with `netstage=6` to C2, this message has the format of head+body, and the meaning of each field is shown below.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageOneb2c.png\"  width=\"860px\" /> \n\n####　head\n\nThe length of head is 7 bytes, and the format is shown below.\n\n```\n06     \t\t---->netstage,1byte,06 means init\nf0 70       ---->tcpip checksum, 2byte, \n00 16\t\t---->length of body, 2 bytes\n```\n\n#### checksum\n\nchecksum\nThe checksum in head uses the tcp/ip checksum, which is calculated for the whole payload, and the original value of the checksum offset is `\\x00\\x00`, and the python implementation of the checksum is as follows.\n\n```python\ndef checksum(data):\n    s = 0\n    n = len(data) % 2\n    for i in range(0, len(data)-n, 2):\n        s+= ord(data[i]) + (ord(data[i+1]) << 8)\n    if n:\n        s+= ord(data[-1])\n    while (s >> 16):\n        s = (s & 0xFFFF) + (s >> 16)\n        s = ~s & 0xffff\n    return s\n\nbuf=\"\\x06\\x00\\x00\\x00\\x00\\x00\\x16\\x36\\x93\\x93\\xb7\\x27\\x5c\\x9a\\x2a\\x16\\x09\\xd8\\x13\\x32\\x01\\xd2\\x69\\x1d\\x25\\xf3\\x42\\x00\\x32\"\nprint(hex(checksum(buf)))\n\n#hex(checksum(buf))\n#0x70f0\n```\n\n#### body\n\nbody is a randomly generated content, meaningless.\n\n```\n00000000  36 93 93 b7 27 5c 9a 2a 16 09 d8 13 32 01 d2 69\n00000010  1d 25 f3 42 00 32\n```\n\n\n\n\n\n#### Stage 1: C2-->Bot, 2 rounds\n\nWhen C2 receives the message `netstage=6` from Bot, it will send 2 rounds of data to BOT.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageOne.png\"  width=\"860px\" /> \n\n* The first round, 36 bytes , the original message is encrypted by xxtea and decrypted as the key of chacha20, with the length of 32bytes\n\n  ```python\n  import hexdump\n  import xxtea\n  key=b\"PJbiNbbeasddDfsc\"\n  keyBuf=bytes.fromhex(\"806d8806cd5460d8996339fbf7bac34ba1e20f792872ba0e05d096ad92a5535e60e55b8d\")\n  chaKey=xxtea.decrypt(keyBuf,key)\n  hexdump.hexdump(chaKey)\n  \n  #chaKey\n  00000000: E6 7B 1A E3 A4 4B 13 7F  14 15 5E 99 31 F2 5E 3A\n  00000010: D7 7B AB 0A 4D 5F 00 EF  0C 01 9F 86 94 A4 9D 4B\n  \n  ```\n\n  \n\n* Second round, 16 bytes , the original message is encrypted by xxtea, decrypted as the nonce of chacha20, length 12bytes\n\n  ```python\n  import hexdump\n  import xxtea\n  key=b\"PJbiNbbeasddDfsc\"\n  nonBuf=bytes.fromhex(\"22c803bb310c5b2512e76a472418f9ee\")\n  chaNonce=xxtea.decrypt(nonBuf,key)\n  hexdump.hexdump(chaNonce)\n  \n  #chaNonce\n  00000000: 98 79 59 57 A8 BA 7E 13  59 9F 59 6F\n  ```\n\n  \n\n#### Stage 2: Bot--->C2, chacha20 encryption\n\nOnce Bot receives the key and nonce of chacha20, it sends the message `netstage=4` to C2, this time the message is encrypted using chacha20, the key&nonce is obtained from the previous stage, the number of rounds encrypted is 1.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageTwob2c.png\"  width=\"860px\" /> \n\n\nWe can decrypt the above traffic using the following python code that\n\n```\nfrom Crypto.Cipher import ChaCha20\ncha=ChaCha20.new(key=chaKey,nonce=chaNonce)\ncha.seek(64)\ntmp=bytes.fromhex('dc23c56943431018b61262481ce5a219da9480930f08714e017edc56bf903d32ac5daeb8314f1bf7e6')\nrnd3=cha.decrypt(tmp)\n```\n\nThe decrypted traffic is shown below, it still has the format of head (7 bytes) + body as described before, where the value of the netstage field of head is 04, which represents the authentication.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netplainb2c.png\"  width=\"860px\" /> \n\n\n#### Stage 2: C2 ---> Bot, chacha20 encryption\n\nAfter receiving the authentication message from Bot, C2 also sends a message with `netstage=4` to Bot's data, also using chacha20 encryption, and the key,nonce,round number is the same as that used by Bot.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageTwoc2b.png\"  width=\"860px\" /> \n\n\nUsing the same code as Bot to decrypt the traffic, we can see that its format is also head+body, and the value of netstage is also 04.\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netplainc2b.png\"  width=\"860px\" /> \n\n\nAfter Bot and C2 send each other the message `netstage=4`, the chacha20 key&nonce representing stage 1 is recognized by both parties, and the authentication of each other is completed, and Bot enters the next stage to prepare to go online.\n\n#### Stage 3: Bot--->C2, 2 rounds, chacha encryption\n\nBot sends netstage=5 message to C2 to indicate that it is ready to go online, and then reports its own grouping information to C2, these 2 rounds of messages also use chacha20 encryption.\n\n\n* First round\n   <img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageThrReg.png\"  width=\"860px\" /> \n  \n\n* Second round\n\n   <img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netStageThrGroup.png\"  width=\"860px\" /> \n  \n\n\n\nAfter the above two rounds of data decryption, we can see that the content of the group is exactly the preset `fsdsaD`, which means our analysis is correct, so the Bot is successfully online and starts to wait for the execution of the command sent by C2.\n\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_netplainb2cReg.png\"  width=\"860px\" /> \n\n\n### 0x4: Execute command\n\nBot successfully online, support the netstage number, as shown in the figure below, the most important is the `netstage = 1` on behalf of the DDoS task, Fodcha reuse a large number of Mirai attack code, a total of `17` kinds of attack methods are supported.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_afterreg.png\"  width=\"860px\" /> \n\nTake the following `DDos_Task` traffic `(netstage=01)` as an example.\n\n\n<img src=\"__GHOST_URL__/content/images/2022/10/fodcha_taskddos.png\"  width=\"860px\" /> \n\nThe attack instructions are still encrypted using `chacha20`, and the decrypted instructions are shown below, which might ring a bell for readers who are familiar with `Mirai`.\n\n```\n00000000: 00 00 00 3C 07 01 xx 14  93 01 20 02 00 00 02 01\n00000010: BB 01 00 02 00 01\n```\n\nThe format and parsing of the above attack instructions are shown in the following table.\n\n\n| offset | len (bytes) | value          | meaning                                                  |\n| ------ | ----------- | -------------- | -------------------------------------------------------- |\n| 0x00   | 4           | 00 00 00 3c    | Duration                                                 |\n| 0x04   | 1           | 07             | Attack Vector，07                                        |\n| 0x05   | 1           | 1              | Attack Target Cnt                                        |\n| 0x06   | 4           | xx 14  93 01   | Attack Target，xx.20.147.1                               |\n| 0x0a   | 1           | 20             | Netmask                                                  |\n| 0x0b   | 1           | 02             | Option Cnt                                               |\n| 0x0c   | 5           | 00 00 02 01 bb | OptionId 0，len 2, value 0x01bb ---> (port 443)          |\n| 0x11   | 5           | 01 00 02 00 01 | OptionId 1, len 2, value 0x0001---> (payload len 1 byte) |\n\nWhen Bot receives the above instruction, it will use the tcp message with a payload of 1 byte to conduct a DDoS attack on the target `xx.20.147.1:443`, which corresponds to the actual packet capture traffic.\n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_ddospacket.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_ddospacket.png\" class=\"kg-image\"/></a>\n\n# Misc\n\n### 0x01: Racism\n\nFrom some of the OpenNIC C2 constructs, it seems that the author of Fodcha is more hostile to people from some regions.\n\n```\nyellowchinks.geek\nwearelegal.geek\nfunnyyellowpeople.libre\nchinksdogeaters.dyn\nblackpeeps.dyn\nbladderfull.indy\n\nwehateyellow\n```\n\n### 0x02: Ransom DDoS\n\nFodcha had the following string attached to the UDP attack command it issued.\n\n```\nsend 10 xmr to 49UnJhpvRRxDXJHYczoUEiK3EKCQZorZWaV6HD7axKGQd5xpUQeNp7Xg9RATFpL4u8dzPfAnuMYqs2Kch1soaf5B5mdfJ1b or we will shutdown your business\n```\n\nThe corresponding attack traffic is shown below, the wallet address appears to be illegal, perhaps the operators behind Fodcha are experimenting with the attack-as-ransom business model, we will see how it evolve. \n\n<a href=\"__GHOST_URL__/content/images/2022/10/fodcha_ddosransom.png\"><img src=\"__GHOST_URL__/content/images/2022/10/fodcha_ddosransom.png\" class=\"kg-image\"/></a>\n\n# Contact us\n\nReaders are always welcomed to reach us on [twitter](https://twitter.com/360Netlab) or email us to netlab[at]360.cn.\n\n# IoC\n### C2\n\n```\nv1,v2:\nfolded[.]in\nfridgexperts[.]cc\n\nICANN C2:\nforwardchinks[.]com\ndoodleching[.]com\ncookiemonsterboob[.]com\nmilfsfors3x[.]com\n\nOpenNIC C2:\n\nyellowchinks.geek\nyellowchinks.dyn\nwearelegal.geek\ntsengtsing.libre\ntechsupporthelpars.oss\nrespectkkk.geek\npepperfan.geek\npeepeepoo.libre\nobamalover.pirate\nfunnyyellowpeople.libre\nchinksdogeaters.dyn\nchinkchink.libre\nbladderfull.indy\nblackpeeps.dyn\n91.206.93.243\n91.149.232.129\n91.149.232.128\n91.149.222.133\n91.149.222.132\n67.207.84.82\n54.37.243.73\n51.89.239.122\n51.89.238.199\n51.89.176.228\n51.89.171.33\n51.161.98.214\n46.17.47.212\n46.17.41.79\n45.88.221.143\n45.61.139.116\n45.41.240.145\n45.147.200.168\n45.140.169.122\n45.135.135.33\n3.70.127.241\n3.65.206.229\n3.122.255.225\n3.121.234.237\n3.0.58.143\n23.183.83.171\n207.154.206.0\n207.154.199.110\n195.211.96.142\n195.133.53.157\n195.133.53.148\n194.87.197.3\n194.53.108.94\n194.53.108.159\n194.195.117.167\n194.156.224.102\n194.147.87.242\n194.147.86.22\n193.233.253.93\n193.233.253.220\n193.203.12.157\n193.203.12.156\n193.203.12.155\n193.203.12.154\n193.203.12.151\n193.203.12.123\n193.124.24.42\n192.46.225.170\n185.45.192.96\n185.45.192.227\n185.45.192.212\n185.45.192.124\n185.45.192.103\n185.198.57.95\n185.198.57.105\n185.183.98.205\n185.183.96.7\n185.143.221.129\n185.143.220.75\n185.141.27.238\n185.141.27.234\n185.117.75.45\n185.117.75.34\n185.117.75.119\n185.117.73.52\n185.117.73.147\n185.117.73.115\n185.117.73.109\n18.185.188.32\n18.136.209.2\n178.62.204.81\n176.97.210.176\n172.105.59.204\n172.105.55.131\n172.104.108.53\n170.187.187.99\n167.114.124.77\n165.227.19.36\n159.65.158.148\n159.223.39.133\n157.230.15.82\n15.204.18.232\n15.204.18.203\n15.204.128.25\n149.56.42.246\n139.99.166.217\n139.99.153.49\n139.99.142.215\n139.162.69.4\n138.68.10.149\n137.74.65.164\n13.229.98.186\n107.181.160.173\n107.181.160.172\n```\n\n### Reporter\n```\nkvsolutions[.]ru\nicarlyfanss[.]com\n```\n### Samples\n```\nea7945724837f019507fd613ba3e1da9\n899047ddf6f62f07150837aef0c1ebfb\n0f781868d4b9203569357b2dbc46ef10\n```"}]],"markups":[],"sections":[[10,0],[1,"p",[]]],"ghostVersion":"3.0"}