A new botnet Orchard Generates DGA Domains with Bitcoin Transaction Information
<p>DGA is one of the classic techniques for botnets to hide their C2s, attacker only needs to selectively register a very small number of C2 domains, while for the defenders, it is difficult to determine in advance which domain names will be generated and registered.</p><p>360 netlab has long focused on the research of botnet attack and defense technology, we maintain a free <a href="https://data.netlab.360.com/dga/">DGA feed</a> and share the research results with the industry. </p><p>Recently we discovered a new botnet that uses Satoshi Nakamoto's Bitcoin account transaction information to generate DGA domain name. Because of the uncertainty of Bitcoin transactions, this technique is more unpredictable than using the common time-generated DGAs, and thus more difficult to defend against.</p><p>The technique was discovered in a family of botnets we called Orchard. Since February 2021, this botnet has gone through 3 versions, and even switched programming languages in between.</p><!--kg-card-begin: markdown--><p>Key points are as follow:</p>
<ul>
<li>Orchard is a botnet family that uses DGA technology with the core function of installing various malware on the victim's machine.</li>
<li>From February 2021 to the present, we have detected 3 versions of Orchard samples, all using the DGA technique.</li>
<li>Orchard's DGA algorithm has remained unchanged, but the use of dates has been changing, and the latest version also supports the use of bitcoin account information to generate separate DGA domains.</li>
<li>In addition to DGA, Orchard also hardcodes C2 domains.</li>
<li>Orchard is still active and dedicated to Monroe coin mining.</li>
</ul>
<!--kg-card-end: markdown--><h1 id="overview">Overview</h1><p>Orchard uses a redundant C2 mechanism of "hardcoded domain + DGA", and each version hardcodes a unique DuckDNS dynamic domain name as C2.</p><pre><code>v1, orcharddns.duckdns.org
v2，orchardmaster.duckdns.org
v3, ojena.duckdns.org
</code></pre><p>A timeline is as follow</p><pre><code>* 2021.3, v1, use C++. Combined with historical data, we found that the earliest appearance in January 2021
* 2021.9, v2, use Golang and C++
* 2022.7, v3, use C++
</code></pre><p>All three versions support propagation by infecting USB disks, much like traditional viruses, as described in the later section of "USB Infection Logic". Theoretically, Orchard can be spread in other ways as well.</p><p>Using our graph system in combination with PDNS and other dimensional data, we found that there is a clear case of shared IPs between the C2 of v1 and v2, as shown in the figure below.</p><figure class="kg-card kg-image-card"><img src="__GHOST_URL__/content/images/2022/08/-------.png" class="kg-image" alt loading="lazy"></figure><p>The graph system helped us find more C2 IPs and domains, and the domains here are characterized by all ending in duckdns.org. v3 is relatively new and has fewer associated domains, and here is the active situation of v3 domains.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v3----.png" class="kg-image" alt="v3----" loading="lazy"></figure><p>We can see that it was launched in May this year, and then gradually became active, and it should still be in the active period.</p><p>Based on our PDNS data, we evaluated the infection scale of the three versions, among which v1 and v2 have thousands of nodes, and v3 has less because of its late appearance, and the following is the detailed resolution number of each version of domain name to specific IP(note the numbers do not reflect all the bots as as our PDNS visibility focus mainly in China)</p><pre><code># v1, orcharddns.duckdns.org
37, 45.61.185.36
413,  45.61.186.52
1301,  45.61.187.240
207, 205.185.124.143

# v2, orchardmaster.duckdns.org
45,  45.61.185.36
104, 45.61.186.52
659,  45.61.187.240

# v3, ojena.duckdns.org
418, 45.61.185.231
</code></pre><h1 id="sample-analysis">Sample Analysis</h1><p>Loader is used for counter analysis and self-protection. Currently Orchard loader is not fixed, even a single version can have a variety of loaders, for example, v1 version of Orchard is  base64 encoded in the loader, v2/v3 version of the sample in the form of resource files stored in the loader in some cases. Each version has also used virtualization packers such as VMP, Enigma, etc. to protect itself. In general, Orchard's workflow can be summarized in the following diagram.</p><figure class="kg-card kg-image-card"><img src="__GHOST_URL__/content/images/2022/08/------.png" class="kg-image" alt loading="lazy"></figure><p>The functions of all three versions of Orchard are basically the same and include:</p><!--kg-card-begin: markdown--><ul>
<li>Uploading device and user information</li>
<li>Responding to commands/downloading to execute the next stage of the module</li>
<li>Infecting USB storage devices</li>
</ul>
<!--kg-card-end: markdown--><p>The core functions of each of the 3 versions of Orchard are analyzed below in several dimensions, such as DGA algorithm, C2 communication and host behavior.</p><h2 id="v1-version">v1 version</h2><p>The analysis of this version is based on the sample with MD5=5c883ff8539b8d04be017a51a84e3af8. It first releases the embedded PE file to the self-boot directory at runtime, and the released PE is base64 decoded in memory to get the orchard data, and then the PE uses any exe under System32/SysWOW64 as a puppet process to run the saved orchard code. The overall logic of this version of Orchard is as follows, mainly divided into two parts: network communication and USB infection, the final function depends on the specific module issued by C2, so orchard itself can be considered as a Downloader.</p><figure class="kg-card kg-image-card"><img src="__GHOST_URL__/content/images/2022/08/v1-----2.png" class="kg-image" alt loading="lazy"></figure><p>Here we mainly describe its network communication process (the logic of USB infection is the same for all three versions, see the section on USB infection for details).</p><p>C2 communication process is relatively simple, the bot in the check-in process will contact C2 to send the collected host information, and then wait for C2 response. The response data format is generally "command + data", the function of the command is specified by the command code.</p><p>The information collected by v1 version includes: volume serial number (HWID), computer name, user name, operating system name, system version, installed capture driver name, antivirus information, parent process file modification time, top window name and window title, etc. These information are separated by "[o.r.c.h.a.r.d]". " as a separator and then sent as shown in the following figure.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v1.C-------4.png" class="kg-image" alt="v1.C-------4" loading="lazy"></figure><p>The example of C2 response data is as follows, where "[&amp;&amp;]" stands for instruction code 2, which represents downloading and execution, and the specific processing is divided into 2 types: if the response data is a URL, the PE corresponding to the URL is downloaded and executed; if it is a base64 encoded content, the decoded data is decoded first and then executed. The response data here is actually the new version of base64-encoded PE file, which is equivalent to upgrade, which also indicates that the old version may have been deprecated.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v1.C-------5.png" class="kg-image" alt="v1.C-------5" loading="lazy"></figure><p>The v1 version defines a total of 8 instructions, and the correspondence between the instruction code and the instruction string is as follows.</p><pre><code>1 \[=] 
2 \[&amp;&amp;] 
3 \[##] 
4 \[###] 
5 \[%%] 
6 \[%%%] 
7 \[#\_#] 
8 \[\_\_\] \[&gt;&gt;] \[&lt;&lt;] \[^^] \[\*\] \[\~\] \[@] \[!] \[#\*\#\] \[#@#] 
</code></pre><p>Due to the nulling of some instructions, the eight instructions actually correspond to three operations (subsequent versions are similar).</p><!--kg-card-begin: markdown--><ul>
<li>Instruction code 1 and 2: determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create a process to execute (CreateProcess to create a process, puppet process, remote thread injection, etc.).</li>
<li>Instruction code 3, 4, 8: terminate the current process to delete the original file, or restart.</li>
<li>Instruction code 7: collect C2, port, PID, file name information again to send to C2, example: orcharddns.duckdns.org[o.r.c.h.a.r.d]5890[o.r.c.h.a.r.d]2260[o.r.c.h.a.r.d]stage-3_.exe[o.r.c .h.a.r.d]</li>
</ul>
<!--kg-card-end: markdown--><h3 id="dga-algorithm">DGA Algorithm</h3><p>v1's DGA takes the date string (e.g. "2022/07/05") as input, calculates its MD5 value, then divides the MD5 string into four 8-byte substrings, and splices them with the 4 suffixes of .com, .net, .org, .duckdns.org in turn to get the daily 4 groups of 16 DGA domain names, the algorithm is implemented as follows.</p><pre><code># 2021/04/15
import datetime
import hashlib

days=30
for i in range(0, days):
    datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y/%m/%d')
    print("seed: ", datex)
    md5 = hashlib.md5(datex.encode()).hexdigest()
    print('md5: ', md5)

    dga_list = []
    dga_list.append(md5[:8])
    dga_list.append(md5[8:16])
    dga_list.append(md5[16:24])
    dga_list.append(md5[24:32])
    for j in range(len(dga_list)):
        print(dga_list[j] + '.com')
        print(dga_list[j] + '.net')
        print(dga_list[j] + '.org')
        print(dga_list[j] + '.duckdns.org')
</code></pre><p>Sample domains are as follow:</p><pre><code>seed:  2022/07/05
md5:  91ac64d29f78281ad802f44648b2137f
91ac64d2.com
91ac64d2.net
91ac64d2.org
91ac64d2.duckdns.org
9f78281a.com
9f78281a.net
9f78281a.org
9f78281a.duckdns.org
d802f446.com
d802f446.net
d802f446.org
d802f446.duckdns.org
48b2137f.com
48b2137f.net
48b2137f.org
48b2137f.duckdns.org
</code></pre><h2 id="v2-version">v2 version</h2><p>The v2 version appears as a sample of two programming language implementations, Golang and C++, but with the same functionality. The analysis here takes the Golang sample with MD5=f3e0b960a48b433bc4bfe6ac44183b74 as an example, and its C2 initialization function is shown below, which can obviously see the hard-coded C2 domain names.</p><figure class="kg-card kg-image-card"><img src="__GHOST_URL__/content/images/2021/09/3.png" class="kg-image" alt loading="lazy"></figure><p>The v2 version of C2 communication starts to use json format, and the meaning of the fields is relatively clear. It collects roughly the same information as v1, including: volume serial number (HWID), computer name, user name, system version, antivirus information, active window information, etc. The new fields are: .net framework version (e.g. v2.0.50727), USB status, outgoing package type and its own version. The following is an actual observed version number information, Bot_Version=1.2/G may be interpreted as: version=v1.2, writing language=Golang.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v2.golang-----1.png" class="kg-image" alt="v2.golang-----1" loading="lazy"></figure><p>The v2 version of the C++ language sample integrates the same C2, and the version information in the live package becomes "Bot_version:1/C", which collects the information shown in the figure below.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v2.C-------1.png" class="kg-image" alt="v2.C-------1" loading="lazy"></figure><p>According to the code similarity analysis, the v2 C++ language sample is homologous with the later v3 C++ sample, which means that the latter is evolved from the former.</p><p>The v2 version has a total of two kinds of instructions.</p><!--kg-card-begin: markdown--><ul>
<li>Instruction 1: terminate the current process to delete the original file, or restart it.</li>
<li>Instruction 2: Determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create process and execute (CreateProcess create process, puppet process, remote thread injection, etc.).</li>
</ul>
<h4 id="dgaalgorithm">DGA Algorithm</h4>
<p>v2 version of DGA algorithm is the same as v1, the difference lies in the processing of the date string. v2 will splice the hard-coded domain name &quot;orchardmaster.duckdns.org&quot; after the date string, such as &quot;2022/07/ 05orchardmaster.duckdns.org&quot;, and then apply the DGA algorithm of v1 to generate the domain name.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="v3version">v3 version</h3>
<p>The development language of v3 is back to C++, which also includes C2 communication and USB infection functions. C2 communication logic runs in a thread, which also includes a secondary thread tied to XMRig mining, and when Orchard has received the XMrig program and created a puppet process to run, the secondary thread will send mining-related hardware information to C2 again. The purpose of trying to read the configuration of the mining software from C2 is to check if the XMRig runtime configuration needs to be dynamically modified (XMRig provides a set of HTTP api that supports dynamically reading and modifying the runtime mining configuration).<br>
Taking the sample with MD5=cb442cbff066dfef2e3ff0c56610148f as an example, the C2 communication function is as follows.</p>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/07/v3-1.png" class="kg-image" alt="v3-1" loading="lazy"></figure><p>The v3 version also uses json format to save host information in C2 communication, and the overall structure of the sent data is Byte_0x46+TotalLen+InfoLen+Info.json. Compared to v2, v3 adds several fields related to mining, and the collected information includes:</p><!--kg-card-begin: markdown--><ul>
<li>Active_Window: the name of the currently active window</li>
<li>Antivirus: antivirus information</li>
<li>Authentiate_Type: Windows authentication type</li>
<li>CPU_Model: CPU information</li>
<li>Camera: whether a camera is present</li>
<li>Elevated: whether it is administrator privileges</li>
<li>GPU_Models: graphics card information</li>
<li>Identity：HWID\username\computer name</li>
<li>Operating_System: System version information</li>
<li>Ram_Size：Running memory size</li>
<li>System_Architecture：Number of processors</li>
<li>Threads：Number of cores per processor</li>
<li>Version：Orchard version</li>
</ul>
<!--kg-card-end: markdown--><p>An example of a live package for v3 is shown below.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v3.c-------1-1.png" class="kg-image" alt="v3.c-------1-1" loading="lazy"></figure><!--kg-card-begin: markdown--><p>The body part of C2 response message is also in json format, and its structure is:<br>
<code>TotalLen.dword+ Byte0x46+TotalLen+RespDataLen+RespData.json</code>.<br>
v3 supports 8 instructions, corresponding to 3 operations.</p>
<ul>
<li>Instruction 1: Collect host information/its own running status and send it to C2 (fields include Domain, In_Memory, Install_Path, Is_Patched, Message_Type, Patch_Name, Port, Power_SaverMode, Process_ID. (Process_Name, Process_Path, System_Idle, System_Uptime)</li>
<li>Instruction 4, 6: terminate the current process to delete the original file, or restart.</li>
<li>Instruction 7, 8: download &amp; execute the miner program sent down</li>
</ul>
<p>The following is an actual trace of the C2 response instruction.</p>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v33-3.png" class="kg-image" alt="v33-3" loading="lazy"></figure><p>Where Transfer_Port indicates that the host is expected to make another request to 2929, and Message_Type indicates the instruction code, whose value is 7, indicating download &amp; execute.</p><p>After receiving the above instruction, bot makes another request to C2's TCP port 2929. Cuda is a parallel computing framework introduced by Nvidia that can only be used for its own GPU, and a Cuda_Version of 0 here means that Cuda is not supported.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v31-5.png" class="kg-image" alt="v31-5" loading="lazy"></figure><p>C2 then responds with an XMRig miner program, which Client receives and saves and then injects XMRig into the puppet process according to instruction 7 to start performing mining work.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/08/v34-1-1.png" class="kg-image" alt="v34-1-1" loading="lazy"></figure><p>During the analysis we found that the v3 version has recently been continuously distributing an identical XMRig mining program, the latter integrated with the default mining configuration information, private mining pool address: 45.61.187.7:7733</p><!--kg-card-begin: markdown--><h4 id="dgaalgorithm">DGA Algorithm</h4>
<p>The DGA algorithm of v3 is unchanged, but the input is more variable. It actually generates two sets of DGA domains, the first set of domains is entered with a spelling algorithm of date string + &quot;ojena.duckdns.org&quot;, shaped like &quot;2022-08-02ojena.duckdns.org &quot;. The second set of domain names is entered as the return result of the URL <code>https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</code>.  A typical return result is shown below.</p>
<pre><code>{&quot;1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa&quot;:&quot;final_balance&quot;:6854884253,&quot;n_tx&quot;:3393,&quot;total_received&quot;:6854884253}}
</code></pre>
<!--kg-card-end: markdown--><p>The meaning of the relevant fields can be found in <a href="https://zh.m.wikipedia.org/zh-hans/Blockchain.com">Blockchain</a>'s <a href="http://cw.hubwiz.com/card/c/blockchain-api/1/3/9/">API manual</a></p><p>It is worth emphasizing that the v3 version does not parse the returned results, but directly  feed  it into the DGA algorithm as a whole to generate the domain name. Instead, the wallet address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa is said to be the Bitcoin Genesis address held by Satoshi Nakamoto himself. Over the past decade or so, small amounts of bitcoin have been transferred to this wallet on a daily basis for various reasons, so it is variable and that change is difficult to predict, so the balance information for this wallet can also be used as DGA input.</p><p>At the time of writing, we found that other researchers had recently noticed this use of bitcoin account transaction information as DGA input for v3. The results of their analysis agreed with ours, but they did not notice that Orchard had actually been around for a long time.</p><p>The complete v3 DGA algorithm is as follows.</p><pre><code># 2022/07/05
import datetime
import requests
import hashlib

# cluster 1
days = 30
for i in range(0, days):
    domains = ['ojena.duckdns.org', 'vgzero.duckdns.org']
    for do in domains:
        datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y-%m-%d' + do)
        print("seed_1: %s" % datex)
        md5 = hashlib.md5(datex.encode()).hexdigest()
        print("md5: %s" % md5)
        
        dga_list = []
        dga_list.append(md5[:8])
        dga_list.append(md5[8:16])
        dga_list.append(md5[16:24])
        dga_list.append(md5[24:32])
        for j in range(len(dga_list)):
            print(dga_list[j] + '.com')
            print(dga_list[j] + '.net')
            print(dga_list[j] + '.org')
            print(dga_list[j] + '.duckdns.org')


# cluster 2
url = 'https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' 
res = requests.get(url)
wallet_info = res.text
print('seed_2: %s' % wallet_info)
md5 = hashlib.md5(wallet_info.encode()).hexdigest()
print('md5: %s' % md5)

dga_list = []
dga_list.append(md5[:8])
dga_list.append(md5[8:16])
dga_list.append(md5[16:24])
dga_list.append(md5[24:32])
for j in range(len(dga_list)):
    print(dga_list[j] + '.com')
    print(dga_list[j] + '.net')
    print(dga_list[j] + '.org')
    print(dga_list[j] + '.duckdns.org')

</code></pre><h2 id="usb-infection">USB Infection</h2><p>Orchard's file infection is not a traditional code insertion, but a file replacement. When a USB storage device is detected, Orchard will create a hidden directory under the root directory of the device, traverse all files for infection, and back up the files before and after infection to this hidden directory, the infected object is infected with the type attribute removed, and after infection all become exe type, and append the .exe suffix to become an executable file. Then the sample will copy itself to the infected directory and randomly named, the string is saved to the resources of the infected file. When the infected file in the device is executed by the user in the new system, it will launch the sample file in the hidden directory to achieve the purpose of spreading the infection.</p><p>The USB infection process involves two embedded PE files, the first one is a DLL file that will be released to the %LocalAppData% directory, this DLL is called CGO_Helper by Orchard and is mainly used to extract and replace the icon of the infected file, its MD5 is The second file is an exe file with MD5 of f3c06399c68c5fdf80bb2853f8f2934b, which is used as a template file to store the infected code, and all the data of the infected file will be replaced with the data of this template file. The function of this template is to find the corresponding exe in the hidden directory to start execution according to the exe name in the resource, so the resource of the infected file is saved with the name of the backup Orchard sample.</p><p>USB infection case example is as follows, the name of Orchard sample is saved in the resource of the infected file, when the user clicks on the infected exe, it will start the Orchard sample file in the hidden directory.</p><figure class="kg-card kg-image-card"><img src="https://blog.netlab.360.com:8443/content/images/2022/07/-----4.png" class="kg-image" alt="-----4" loading="lazy"></figure><h1 id="summary">Summary</h1><p>Orchard is a botnet family that uses DGA technology. The latest version is dedicated to mining and has started using more unpredictable information like transaction information of bitcoin accounts as input to DGA, making detection more difficult. In over 1 year, Orchard has appeared in 3 different versions with changes in programming language and DGA implementation, indicating that Orchard is a botnet family that is still active and deserves our vigilance. We expect more variants to emerge subsequently, for which we will continue to keep an eye on, and will continue to disclose new findings.</p><!--kg-card-begin: markdown--><h1 id="contactus">Contact us</h1>
<p>Readers are always welcomed to reach us on <a href="https://twitter.com/360Netlab"><strong>twitter</strong></a>  or email us to <strong>netlab[at]360.cn</strong>.</p>
<!--kg-card-end: markdown--><h2 id="iocs">IOCs</h2><h3 id="c2">C2</h3><pre><code>orcharddns.duckdns.org
orchardmaster.duckdns.org
ojena.duckdns.org
vgzero.duckdns.org
victorynicholas.duckdns.org
zamarin1.duckdns.org

45.61.185.36
45.61.186.52
45.61.187.240
205.185.124.143
45.61.185.231
</code></pre><h3 id="md5">MD5</h3><pre><code>5c883ff8539b8d04be017a51a84e3af8
f3e0b960a48b433bc4bfe6ac44183b74
9cbe4bd27eba8c70b6eddaeb6707659b
cb442cbff066dfef2e3ff0c56610148f
10D42F5465D5D8808B43619D8266BD99
f3c06399c68c5fdf80bb2853f8f2934b
19159280736dbe6c11b7d6a57f6bb7b9
b5a6f78d5575a60316f4e784371d4f8c
3c20ba851edecd28c198691321429883
2b244a39571ab27f7bb4174d460adeef
ae1e9b3621ee041be6ab5e12bff37c53
00b1620f89b7980b34d53737d9e42fd3
4d2445a43591d041cabbbf3dfca6dfbd
</code></pre><h3 id="private-mining-pool">Private mining pool</h3><pre><code>45.61.187.7:7733
</code></pre><h2 id="contact-us"><strong>Contact us</strong></h2><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>
DGA is one of the classic techniques for botnets to hide their C2s, attacker only needs to selectively register a very small number of C2 domains, while for the defenders, it is difficult to determine in advance which domain names will be generated and registered.

360 netlab has long focused on the research of botnet attack and defense technology, we maintain a free DGA feed and share the research results with the industry.

Recently we discovered a new botnet that uses Satoshi Nakamoto's Bitcoin account transaction information to generate DGA domain name. Because of the uncertainty of Bitcoin transactions, this technique is more unpredictable than using the common time-generated DGAs, and thus more difficult to defend against.

The technique was discovered in a family of botnets we called Orchard. Since February 2021, this botnet has gone through 3 versions, and even switched programming languages in between.

Key points are as follow:


 * Orchard is a botnet family that uses DGA technology with the core function of installing various malware on the victim's machine.
 * From February 2021 to the present, we have detected 3 versions of Orchard samples, all using the DGA technique.
 * Orchard's DGA algorithm has remained unchanged, but the use of dates has been changing, and the latest version also supports the use of bitcoin account information to generate separate DGA domains.
 * In addition to DGA, Orchard also hardcodes C2 domains.
 * Orchard is still active and dedicated to Monroe coin mining.



Overview

Orchard uses a redundant C2 mechanism of "hardcoded domain + DGA", and each version hardcodes a unique DuckDNS dynamic domain name as C2.

v1, orcharddns.duckdns.org
v2，orchardmaster.duckdns.org
v3, ojena.duckdns.org


A timeline is as follow

* 2021.3, v1, use C++. Combined with historical data, we found that the earliest appearance in January 2021
* 2021.9, v2, use Golang and C++
* 2022.7, v3, use C++


All three versions support propagation by infecting USB disks, much like traditional viruses, as described in the later section of "USB Infection Logic". Theoretically, Orchard can be spread in other ways as well.

Using our graph system in combination with PDNS and other dimensional data, we found that there is a clear case of shared IPs between the C2 of v1 and v2, as shown in the figure below.

The graph system helped us find more C2 IPs and domains, and the domains here are characterized by all ending in duckdns.org. v3 is relatively new and has fewer associated domains, and here is the active situation of v3 domains.

We can see that it was launched in May this year, and then gradually became active, and it should still be in the active period.

Based on our PDNS data, we evaluated the infection scale of the three versions, among which v1 and v2 have thousands of nodes, and v3 has less because of its late appearance, and the following is the detailed resolution number of each version of domain name to specific IP(note the numbers do not reflect all the bots as as our PDNS visibility focus mainly in China)

# v1, orcharddns.duckdns.org
37, 45.61.185.36
413,  45.61.186.52
1301,  45.61.187.240
207, 205.185.124.143

# v2, orchardmaster.duckdns.org
45,  45.61.185.36
104, 45.61.186.52
659,  45.61.187.240

# v3, ojena.duckdns.org
418, 45.61.185.231



Sample Analysis

Loader is used for counter analysis and self-protection. Currently Orchard loader is not fixed, even a single version can have a variety of loaders, for example, v1 version of Orchard is  base64 encoded in the loader, v2/v3 version of the sample in the form of resource files stored in the loader in some cases. Each version has also used virtualization packers such as VMP, Enigma, etc. to protect itself. In general, Orchard's workflow can be summarized in the following diagram.

The functions of all three versions of Orchard are basically the same and include:

 * Uploading device and user information
 * Responding to commands/downloading to execute the next stage of the module
 * Infecting USB storage devices


The core functions of each of the 3 versions of Orchard are analyzed below in several dimensions, such as DGA algorithm, C2 communication and host behavior.


v1 version

The analysis of this version is based on the sample with MD5=5c883ff8539b8d04be017a51a84e3af8. It first releases the embedded PE file to the self-boot directory at runtime, and the released PE is base64 decoded in memory to get the orchard data, and then the PE uses any exe under System32/SysWOW64 as a puppet process to run the saved orchard code. The overall logic of this version of Orchard is as follows, mainly divided into two parts: network communication and USB infection, the final function depends on the specific module issued by C2, so orchard itself can be considered as a Downloader.

Here we mainly describe its network communication process (the logic of USB infection is the same for all three versions, see the section on USB infection for details).

C2 communication process is relatively simple, the bot in the check-in process will contact C2 to send the collected host information, and then wait for C2 response. The response data format is generally "command + data", the function of the command is specified by the command code.

The information collected by v1 version includes: volume serial number (HWID), computer name, user name, operating system name, system version, installed capture driver name, antivirus information, parent process file modification time, top window name and window title, etc. These information are separated by "[o.r.c.h.a.r.d]". " as a separator and then sent as shown in the following figure.

The example of C2 response data is as follows, where "[&&]" stands for instruction code 2, which represents downloading and execution, and the specific processing is divided into 2 types: if the response data is a URL, the PE corresponding to the URL is downloaded and executed; if it is a base64 encoded content, the decoded data is decoded first and then executed. The response data here is actually the new version of base64-encoded PE file, which is equivalent to upgrade, which also indicates that the old version may have been deprecated.

The v1 version defines a total of 8 instructions, and the correspondence between the instruction code and the instruction string is as follows.

1 \[=] 
2 \[&&] 
3 \[##] 
4 \[###] 
5 \[%%] 
6 \[%%%] 
7 \[#\_#] 
8 \[\_\_\] \[>>] \[<<] \[^^] \[\*\] \[\~\] \[@] \[!] \[#\*\#\] \[#@#] 


Due to the nulling of some instructions, the eight instructions actually correspond to three operations (subsequent versions are similar).

 * Instruction code 1 and 2: determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create a process to execute (CreateProcess to create a process, puppet process, remote thread injection, etc.).
 * Instruction code 3, 4, 8: terminate the current process to delete the original file, or restart.
 * Instruction code 7: collect C2, port, PID, file name information again to send to C2, example: orcharddns.duckdns.org[o.r.c.h.a.r.d]5890[o.r.c.h.a.r.d]2260[o.r.c.h.a.r.d]stage-3_.exe[o.r.c .h.a.r.d]



DGA Algorithm

v1's DGA takes the date string (e.g. "2022/07/05") as input, calculates its MD5 value, then divides the MD5 string into four 8-byte substrings, and splices them with the 4 suffixes of .com, .net, .org, .duckdns.org in turn to get the daily 4 groups of 16 DGA domain names, the algorithm is implemented as follows.

# 2021/04/15
import datetime
import hashlib

days=30
for i in range(0, days):
    datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y/%m/%d')
    print("seed: ", datex)
    md5 = hashlib.md5(datex.encode()).hexdigest()
    print('md5: ', md5)

    dga_list = []
    dga_list.append(md5[:8])
    dga_list.append(md5[8:16])
    dga_list.append(md5[16:24])
    dga_list.append(md5[24:32])
    for j in range(len(dga_list)):
        print(dga_list[j] + '.com')
        print(dga_list[j] + '.net')
        print(dga_list[j] + '.org')
        print(dga_list[j] + '.duckdns.org')


Sample domains are as follow:

seed:  2022/07/05
md5:  91ac64d29f78281ad802f44648b2137f
91ac64d2.com
91ac64d2.net
91ac64d2.org
91ac64d2.duckdns.org
9f78281a.com
9f78281a.net
9f78281a.org
9f78281a.duckdns.org
d802f446.com
d802f446.net
d802f446.org
d802f446.duckdns.org
48b2137f.com
48b2137f.net
48b2137f.org
48b2137f.duckdns.org



v2 version

The v2 version appears as a sample of two programming language implementations, Golang and C++, but with the same functionality. The analysis here takes the Golang sample with MD5=f3e0b960a48b433bc4bfe6ac44183b74 as an example, and its C2 initialization function is shown below, which can obviously see the hard-coded C2 domain names.

The v2 version of C2 communication starts to use json format, and the meaning of the fields is relatively clear. It collects roughly the same information as v1, including: volume serial number (HWID), computer name, user name, system version, antivirus information, active window information, etc. The new fields are: .net framework version (e.g. v2.0.50727), USB status, outgoing package type and its own version. The following is an actual observed version number information, Bot_Version=1.2/G may be interpreted as: version=v1.2, writing language=Golang.

The v2 version of the C++ language sample integrates the same C2, and the version information in the live package becomes "Bot_version:1/C", which collects the information shown in the figure below.

According to the code similarity analysis, the v2 C++ language sample is homologous with the later v3 C++ sample, which means that the latter is evolved from the former.

The v2 version has a total of two kinds of instructions.

 * Instruction 1: terminate the current process to delete the original file, or restart it.
 * Instruction 2: Determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create process and execute (CreateProcess create process, puppet process, remote thread injection, etc.).


DGA Algorithm


v2 version of DGA algorithm is the same as v1, the difference lies in the processing of the date string. v2 will splice the hard-coded domain name "orchardmaster.duckdns.org" after the date string, such as "2022/07/ 05orchardmaster.duckdns.org", and then apply the DGA algorithm of v1 to generate the domain name.



v3 version


The development language of v3 is back to C++, which also includes C2 communication and USB infection functions. C2 communication logic runs in a thread, which also includes a secondary thread tied to XMRig mining, and when Orchard has received the XMrig program and created a puppet process to run, the secondary thread will send mining-related hardware information to C2 again. The purpose of trying to read the configuration of the mining software from C2 is to check if the XMRig runtime configuration needs to be dynamically modified (XMRig provides a set of HTTP api that supports dynamically reading and modifying the runtime mining configuration).

Taking the sample with MD5=cb442cbff066dfef2e3ff0c56610148f as an example, the C2 communication function is as follows.


The v3 version also uses json format to save host information in C2 communication, and the overall structure of the sent data is Byte_0x46+TotalLen+InfoLen+Info.json. Compared to v2, v3 adds several fields related to mining, and the collected information includes:

 * Active_Window: the name of the currently active window
 * Antivirus: antivirus information
 * Authentiate_Type: Windows authentication type
 * CPU_Model: CPU information
 * Camera: whether a camera is present
 * Elevated: whether it is administrator privileges
 * GPU_Models: graphics card information
 * Identity：HWID\username\computer name
 * Operating_System: System version information
 * Ram_Size：Running memory size
 * System_Architecture：Number of processors
 * Threads：Number of cores per processor
 * Version：Orchard version


An example of a live package for v3 is shown below.

The body part of C2 response message is also in json format, and its structure is:

TotalLen.dword+ Byte0x46+TotalLen+RespDataLen+RespData.json.

v3 supports 8 instructions, corresponding to 3 operations.


 * Instruction 1: Collect host information/its own running status and send it to C2 (fields include Domain, In_Memory, Install_Path, Is_Patched, Message_Type, Patch_Name, Port, Power_SaverMode, Process_ID. (Process_Name, Process_Path, System_Idle, System_Uptime)
 * Instruction 4, 6: terminate the current process to delete the original file, or restart.
 * Instruction 7, 8: download & execute the miner program sent down


The following is an actual trace of the C2 response instruction.


Where Transfer_Port indicates that the host is expected to make another request to 2929, and Message_Type indicates the instruction code, whose value is 7, indicating download & execute.

After receiving the above instruction, bot makes another request to C2's TCP port 2929. Cuda is a parallel computing framework introduced by Nvidia that can only be used for its own GPU, and a Cuda_Version of 0 here means that Cuda is not supported.

C2 then responds with an XMRig miner program, which Client receives and saves and then injects XMRig into the puppet process according to instruction 7 to start performing mining work.

During the analysis we found that the v3 version has recently been continuously distributing an identical XMRig mining program, the latter integrated with the default mining configuration information, private mining pool address: 45.61.187.7:7733

DGA Algorithm


The DGA algorithm of v3 is unchanged, but the input is more variable. It actually generates two sets of DGA domains, the first set of domains is entered with a spelling algorithm of date string + "ojena.duckdns.org", shaped like "2022-08-02ojena.duckdns.org ". The second set of domain names is entered as the return result of the URL https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. A typical return result is shown below.


{"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":"final_balance":6854884253,"n_tx":3393,"total_received":6854884253}}



The meaning of the relevant fields can be found in Blockchain's API manual

It is worth emphasizing that the v3 version does not parse the returned results, but directly  feed  it into the DGA algorithm as a whole to generate the domain name. Instead, the wallet address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa is said to be the Bitcoin Genesis address held by Satoshi Nakamoto himself. Over the past decade or so, small amounts of bitcoin have been transferred to this wallet on a daily basis for various reasons, so it is variable and that change is difficult to predict, so the balance information for this wallet can also be used as DGA input.

At the time of writing, we found that other researchers had recently noticed this use of bitcoin account transaction information as DGA input for v3. The results of their analysis agreed with ours, but they did not notice that Orchard had actually been around for a long time.

The complete v3 DGA algorithm is as follows.

# 2022/07/05
import datetime
import requests
import hashlib

# cluster 1
days = 30
for i in range(0, days):
    domains = ['ojena.duckdns.org', 'vgzero.duckdns.org']
    for do in domains:
        datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y-%m-%d' + do)
        print("seed_1: %s" % datex)
        md5 = hashlib.md5(datex.encode()).hexdigest()
        print("md5: %s" % md5)
        
        dga_list = []
        dga_list.append(md5[:8])
        dga_list.append(md5[8:16])
        dga_list.append(md5[16:24])
        dga_list.append(md5[24:32])
        for j in range(len(dga_list)):
            print(dga_list[j] + '.com')
            print(dga_list[j] + '.net')
            print(dga_list[j] + '.org')
            print(dga_list[j] + '.duckdns.org')


# cluster 2
url = 'https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' 
res = requests.get(url)
wallet_info = res.text
print('seed_2: %s' % wallet_info)
md5 = hashlib.md5(wallet_info.encode()).hexdigest()
print('md5: %s' % md5)

dga_list = []
dga_list.append(md5[:8])
dga_list.append(md5[8:16])
dga_list.append(md5[16:24])
dga_list.append(md5[24:32])
for j in range(len(dga_list)):
    print(dga_list[j] + '.com')
    print(dga_list[j] + '.net')
    print(dga_list[j] + '.org')
    print(dga_list[j] + '.duckdns.org')




USB Infection

Orchard's file infection is not a traditional code insertion, but a file replacement. When a USB storage device is detected, Orchard will create a hidden directory under the root directory of the device, traverse all files for infection, and back up the files before and after infection to this hidden directory, the infected object is infected with the type attribute removed, and after infection all become exe type, and append the .exe suffix to become an executable file. Then the sample will copy itself to the infected directory and randomly named, the string is saved to the resources of the infected file. When the infected file in the device is executed by the user in the new system, it will launch the sample file in the hidden directory to achieve the purpose of spreading the infection.

The USB infection process involves two embedded PE files, the first one is a DLL file that will be released to the %LocalAppData% directory, this DLL is called CGO_Helper by Orchard and is mainly used to extract and replace the icon of the infected file, its MD5 is The second file is an exe file with MD5 of f3c06399c68c5fdf80bb2853f8f2934b, which is used as a template file to store the infected code, and all the data of the infected file will be replaced with the data of this template file. The function of this template is to find the corresponding exe in the hidden directory to start execution according to the exe name in the resource, so the resource of the infected file is saved with the name of the backup Orchard sample.

USB infection case example is as follows, the name of Orchard sample is saved in the resource of the infected file, when the user clicks on the infected exe, it will start the Orchard sample file in the hidden directory.


Summary

Orchard is a botnet family that uses DGA technology. The latest version is dedicated to mining and has started using more unpredictable information like transaction information of bitcoin accounts as input to DGA, making detection more difficult. In over 1 year, Orchard has appeared in 3 different versions with changes in programming language and DGA implementation, indicating that Orchard is a botnet family that is still active and deserves our vigilance. We expect more variants to emerge subsequently, for which we will continue to keep an eye on, and will continue to disclose new findings.


Contact us


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



IOCs


C2

orcharddns.duckdns.org
orchardmaster.duckdns.org
ojena.duckdns.org
vgzero.duckdns.org
victorynicholas.duckdns.org
zamarin1.duckdns.org

45.61.185.36
45.61.186.52
45.61.187.240
205.185.124.143
45.61.185.231



MD5

5c883ff8539b8d04be017a51a84e3af8
f3e0b960a48b433bc4bfe6ac44183b74
9cbe4bd27eba8c70b6eddaeb6707659b
cb442cbff066dfef2e3ff0c56610148f
10D42F5465D5D8808B43619D8266BD99
f3c06399c68c5fdf80bb2853f8f2934b
19159280736dbe6c11b7d6a57f6bb7b9
b5a6f78d5575a60316f4e784371d4f8c
3c20ba851edecd28c198691321429883
2b244a39571ab27f7bb4174d460adeef
ae1e9b3621ee041be6ab5e12bff37c53
00b1620f89b7980b34d53737d9e42fd3
4d2445a43591d041cabbbf3dfca6dfbd



Private mining pool

45.61.187.7:7733



Contact us

Readers are always welcomed to reach us on Twitter or email us to netlab[at]360.cn.
{"version":"0.3.1","atoms":[],"cards":[["markdown",{"markdown":"Key points are as follow:\n\n* Orchard is a botnet family that uses DGA technology with the core function of installing various malware on the victim's machine.\n* From February 2021 to the present, we have detected 3 versions of Orchard samples, all using the DGA technique.\n* Orchard's DGA algorithm has remained unchanged, but the use of dates has been changing, and the latest version also supports the use of bitcoin account information to generate separate DGA domains.\n* In addition to DGA, Orchard also hardcodes C2 domains.\n* Orchard is still active and dedicated to Monroe coin mining."}],["code",{"code":"v1, orcharddns.duckdns.org\nv2，orchardmaster.duckdns.org\nv3, ojena.duckdns.org\n"}],["code",{"code":"* 2021.3, v1, use C++. Combined with historical data, we found that the earliest appearance in January 2021\n* 2021.9, v2, use Golang and C++\n* 2022.7, v3, use C++\n"}],["image",{"src":"__GHOST_URL__/content/images/2022/08/-------.png"}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v3----.png","alt":"v3----","title":""}],["code",{"code":"# v1, orcharddns.duckdns.org\n37, 45.61.185.36\n413,  45.61.186.52\n1301,  45.61.187.240\n207, 205.185.124.143\n\n# v2, orchardmaster.duckdns.org\n45,  45.61.185.36\n104, 45.61.186.52\n659,  45.61.187.240\n\n# v3, ojena.duckdns.org\n418, 45.61.185.231\n"}],["image",{"src":"__GHOST_URL__/content/images/2022/08/------.png"}],["markdown",{"markdown":"* Uploading device and user information\n* Responding to commands/downloading to execute the next stage of the module\n* Infecting USB storage devices"}],["image",{"src":"__GHOST_URL__/content/images/2022/08/v1-----2.png"}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v1.C-------4.png","alt":"v1.C-------4","title":""}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v1.C-------5.png","alt":"v1.C-------5","title":""}],["code",{"code":"1 \\[=] \n2 \\[&&] \n3 \\[##] \n4 \\[###] \n5 \\[%%] \n6 \\[%%%] \n7 \\[#\\_#] \n8 \\[\\_\\_\\] \\[>>] \\[<<] \\[^^] \\[\\*\\] \\[\\~\\] \\[@] \\[!] \\[#\\*\\#\\] \\[#@#] \n"}],["markdown",{"markdown":"* Instruction code 1 and 2: determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create a process to execute (CreateProcess to create a process, puppet process, remote thread injection, etc.).\n* Instruction code 3, 4, 8: terminate the current process to delete the original file, or restart.\n* Instruction code 7: collect C2, port, PID, file name information again to send to C2, example: orcharddns.duckdns.org[o.r.c.h.a.r.d]5890[o.r.c.h.a.r.d]2260[o.r.c.h.a.r.d]stage-3_.exe[o.r.c .h.a.r.d] "}],["code",{"code":"# 2021/04/15\nimport datetime\nimport hashlib\n\ndays=30\nfor i in range(0, days):\n    datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y/%m/%d')\n    print(\"seed: \", datex)\n    md5 = hashlib.md5(datex.encode()).hexdigest()\n    print('md5: ', md5)\n\n    dga_list = []\n    dga_list.append(md5[:8])\n    dga_list.append(md5[8:16])\n    dga_list.append(md5[16:24])\n    dga_list.append(md5[24:32])\n    for j in range(len(dga_list)):\n        print(dga_list[j] + '.com')\n        print(dga_list[j] + '.net')\n        print(dga_list[j] + '.org')\n        print(dga_list[j] + '.duckdns.org')\n"}],["code",{"code":"seed:  2022/07/05\nmd5:  91ac64d29f78281ad802f44648b2137f\n91ac64d2.com\n91ac64d2.net\n91ac64d2.org\n91ac64d2.duckdns.org\n9f78281a.com\n9f78281a.net\n9f78281a.org\n9f78281a.duckdns.org\nd802f446.com\nd802f446.net\nd802f446.org\nd802f446.duckdns.org\n48b2137f.com\n48b2137f.net\n48b2137f.org\n48b2137f.duckdns.org\n"}],["image",{"src":"__GHOST_URL__/content/images/2021/09/3.png","cardWidth":"","caption":""}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v2.golang-----1.png","alt":"v2.golang-----1","title":""}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v2.C-------1.png","alt":"v2.C-------1","title":""}],["markdown",{"markdown":"* Instruction 1: terminate the current process to delete the original file, or restart it.\n* Instruction 2: Determine whether the response data is URL or PE, if it is URL, then download and execute, if it is PE, then create process and execute (CreateProcess create process, puppet process, remote thread injection, etc.).\n\n#### DGA Algorithm\nv2 version of DGA algorithm is the same as v1, the difference lies in the processing of the date string. v2 will splice the hard-coded domain name \"orchardmaster.duckdns.org\" after the date string, such as \"2022/07/ 05orchardmaster.duckdns.org\", and then apply the DGA algorithm of v1 to generate the domain name."}],["markdown",{"markdown":"### v3 version\nThe development language of v3 is back to C++, which also includes C2 communication and USB infection functions. C2 communication logic runs in a thread, which also includes a secondary thread tied to XMRig mining, and when Orchard has received the XMrig program and created a puppet process to run, the secondary thread will send mining-related hardware information to C2 again. The purpose of trying to read the configuration of the mining software from C2 is to check if the XMRig runtime configuration needs to be dynamically modified (XMRig provides a set of HTTP api that supports dynamically reading and modifying the runtime mining configuration).\nTaking the sample with MD5=cb442cbff066dfef2e3ff0c56610148f as an example, the C2 communication function is as follows."}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/07/v3-1.png","alt":"v3-1","title":""}],["markdown",{"markdown":"* Active_Window: the name of the currently active window\n* Antivirus: antivirus information\n* Authentiate_Type: Windows authentication type\n* CPU_Model: CPU information\n* Camera: whether a camera is present\n* Elevated: whether it is administrator privileges\n* GPU_Models: graphics card information\n* Identity：HWID\\username\\computer name\n* Operating_System: System version information\n* Ram_Size：Running memory size\n* System_Architecture：Number of processors\n* Threads：Number of cores per processor\n* Version：Orchard version"}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v3.c-------1-1.png","alt":"v3.c-------1-1","title":""}],["markdown",{"markdown":"The body part of C2 response message is also in json format, and its structure is: \n```TotalLen.dword+ Byte0x46+TotalLen+RespDataLen+RespData.json```. \nv3 supports 8 instructions, corresponding to 3 operations.\n* Instruction 1: Collect host information/its own running status and send it to C2 (fields include Domain, In_Memory, Install_Path, Is_Patched, Message_Type, Patch_Name, Port, Power_SaverMode, Process_ID. (Process_Name, Process_Path, System_Idle, System_Uptime)\n* Instruction 4, 6: terminate the current process to delete the original file, or restart.\n* Instruction 7, 8: download & execute the miner program sent down\n\nThe following is an actual trace of the C2 response instruction."}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v33-3.png","alt":"v33-3","title":""}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v31-5.png","alt":"v31-5","title":""}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/08/v34-1-1.png","alt":"v34-1-1","title":""}],["markdown",{"markdown":"#### DGA Algorithm\nThe DGA algorithm of v3 is unchanged, but the input is more variable. It actually generates two sets of DGA domains, the first set of domains is entered with a spelling algorithm of date string + \"ojena.duckdns.org\", shaped like \"2022-08-02ojena.duckdns.org \". The second set of domain names is entered as the return result of the URL ```https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa```.  A typical return result is shown below.\n\n```\n{\"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\":\"final_balance\":6854884253,\"n_tx\":3393,\"total_received\":6854884253}}\n```"}],["code",{"code":"# 2022/07/05\nimport datetime\nimport requests\nimport hashlib\n\n# cluster 1\ndays = 30\nfor i in range(0, days):\n    domains = ['ojena.duckdns.org', 'vgzero.duckdns.org']\n    for do in domains:\n        datex = (datetime.datetime.now() - datetime.timedelta(days=i)).strftime('%Y-%m-%d' + do)\n        print(\"seed_1: %s\" % datex)\n        md5 = hashlib.md5(datex.encode()).hexdigest()\n        print(\"md5: %s\" % md5)\n        \n        dga_list = []\n        dga_list.append(md5[:8])\n        dga_list.append(md5[8:16])\n        dga_list.append(md5[16:24])\n        dga_list.append(md5[24:32])\n        for j in range(len(dga_list)):\n            print(dga_list[j] + '.com')\n            print(dga_list[j] + '.net')\n            print(dga_list[j] + '.org')\n            print(dga_list[j] + '.duckdns.org')\n\n\n# cluster 2\nurl = 'https://blockchain.info/balance?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' \nres = requests.get(url)\nwallet_info = res.text\nprint('seed_2: %s' % wallet_info)\nmd5 = hashlib.md5(wallet_info.encode()).hexdigest()\nprint('md5: %s' % md5)\n\ndga_list = []\ndga_list.append(md5[:8])\ndga_list.append(md5[8:16])\ndga_list.append(md5[16:24])\ndga_list.append(md5[24:32])\nfor j in range(len(dga_list)):\n    print(dga_list[j] + '.com')\n    print(dga_list[j] + '.net')\n    print(dga_list[j] + '.org')\n    print(dga_list[j] + '.duckdns.org')\n\n"}],["image",{"src":"https://blog.netlab.360.com:8443/content/images/2022/07/-----4.png","alt":"-----4","title":""}],["markdown",{"markdown":"# Contact us\nReaders are always welcomed to reach us on [**twitter**](https://twitter.com/360Netlab)  or email us to **netlab[at]360.cn**."}],["code",{"code":"orcharddns.duckdns.org\norchardmaster.duckdns.org\nojena.duckdns.org\nvgzero.duckdns.org\nvictorynicholas.duckdns.org\nzamarin1.duckdns.org\n\n45.61.185.36\n45.61.186.52\n45.61.187.240\n205.185.124.143\n45.61.185.231\n"}],["code",{"code":"5c883ff8539b8d04be017a51a84e3af8\nf3e0b960a48b433bc4bfe6ac44183b74\n9cbe4bd27eba8c70b6eddaeb6707659b\ncb442cbff066dfef2e3ff0c56610148f\n10D42F5465D5D8808B43619D8266BD99\nf3c06399c68c5fdf80bb2853f8f2934b\n19159280736dbe6c11b7d6a57f6bb7b9\nb5a6f78d5575a60316f4e784371d4f8c\n3c20ba851edecd28c198691321429883\n2b244a39571ab27f7bb4174d460adeef\nae1e9b3621ee041be6ab5e12bff37c53\n00b1620f89b7980b34d53737d9e42fd3\n4d2445a43591d041cabbbf3dfca6dfbd\n"}],["code",{"code":"45.61.187.7:7733\n"}]],"markups":[["a",["href","https://data.netlab.360.com/dga/"]],["a",["href","https://zh.m.wikipedia.org/zh-hans/Blockchain.com"]],["a",["href","http://cw.hubwiz.com/card/c/blockchain-api/1/3/9/"]],["strong"],["a",["href","https://twitter.com/360Netlab"]]],"sections":[[1,"p",[[0,[],0,"DGA is one of the classic techniques for botnets to hide their C2s, attacker only needs to selectively register a very small number of C2 domains, while for the defenders, it is difficult to determine in advance which domain names will be generated and registered."]]],[1,"p",[[0,[],0,"360 netlab has long focused on the research of botnet attack and defense technology, we maintain a free "],[0,[0],1,"DGA feed"],[0,[],0," and share the research results with the industry. "]]],[1,"p",[[0,[],0,"Recently we discovered a new botnet that uses Satoshi Nakamoto's Bitcoin account transaction information to generate DGA domain name. Because of the uncertainty of Bitcoin transactions, this technique is more unpredictable than using the common time-generated DGAs, and thus more difficult to defend against."]]],[1,"p",[[0,[],0,"The technique was discovered in a family of botnets we called Orchard. Since February 2021, this botnet has gone through 3 versions, and even switched programming languages in between."]]],[10,0],[1,"h1",[[0,[],0,"Overview"]]],[1,"p",[[0,[],0,"Orchard uses a redundant C2 mechanism of \"hardcoded domain + DGA\", and each version hardcodes a unique DuckDNS dynamic domain name as C2."]]],[10,1],[1,"p",[[0,[],0,"A timeline is as follow"]]],[10,2],[1,"p",[[0,[],0,"All three versions support propagation by infecting USB disks, much like traditional viruses, as described in the later section of \"USB Infection Logic\". Theoretically, Orchard can be spread in other ways as well."]]],[1,"p",[[0,[],0,"Using our graph system in combination with PDNS and other dimensional data, we found that there is a clear case of shared IPs between the C2 of v1 and v2, as shown in the figure below."]]],[10,3],[1,"p",[[0,[],0,"The graph system helped us find more C2 IPs and domains, and the domains here are characterized by all ending in duckdns.org. v3 is relatively new and has fewer associated domains, and here is the active situation of v3 domains."]]],[10,4],[1,"p",[[0,[],0,"We can see that it was launched in May this year, and then gradually became active, and it should still be in the active period."]]],[1,"p",[[0,[],0,"Based on our PDNS data, we evaluated the infection scale of the three versions, among which v1 and v2 have thousands of nodes, and v3 has less because of its late appearance, and the following is the detailed resolution number of each version of domain name to specific IP(note the numbers do not reflect all the bots as as our PDNS visibility focus mainly in China)"]]],[10,5],[1,"h1",[[0,[],0,"Sample Analysis"]]],[1,"p",[[0,[],0,"Loader is used for counter analysis and self-protection. Currently Orchard loader is not fixed, even a single version can have a variety of loaders, for example, v1 version of Orchard is  base64 encoded in the loader, v2/v3 version of the sample in the form of resource files stored in the loader in some cases. Each version has also used virtualization packers such as VMP, Enigma, etc. to protect itself. In general, Orchard's workflow can be summarized in the following diagram."]]],[10,6],[1,"p",[[0,[],0,"The functions of all three versions of Orchard are basically the same and include:"]]],[10,7],[1,"p",[[0,[],0,"The core functions of each of the 3 versions of Orchard are analyzed below in several dimensions, such as DGA algorithm, C2 communication and host behavior."]]],[1,"h2",[[0,[],0,"v1 version"]]],[1,"p",[[0,[],0,"The analysis of this version is based on the sample with MD5=5c883ff8539b8d04be017a51a84e3af8. It first releases the embedded PE file to the self-boot directory at runtime, and the released PE is base64 decoded in memory to get the orchard data, and then the PE uses any exe under System32/SysWOW64 as a puppet process to run the saved orchard code. The overall logic of this version of Orchard is as follows, mainly divided into two parts: network communication and USB infection, the final function depends on the specific module issued by C2, so orchard itself can be considered as a Downloader."]]],[10,8],[1,"p",[[0,[],0,"Here we mainly describe its network communication process (the logic of USB infection is the same for all three versions, see the section on USB infection for details)."]]],[1,"p",[[0,[],0,"C2 communication process is relatively simple, the bot in the check-in process will contact C2 to send the collected host information, and then wait for C2 response. The response data format is generally \"command + data\", the function of the command is specified by the command code."]]],[1,"p",[[0,[],0,"The information collected by v1 version includes: volume serial number (HWID), computer name, user name, operating system name, system version, installed capture driver name, antivirus information, parent process file modification time, top window name and window title, etc. These information are separated by \"[o.r.c.h.a.r.d]\". \" as a separator and then sent as shown in the following figure."]]],[10,9],[1,"p",[[0,[],0,"The example of C2 response data is as follows, where \"[&&]\" stands for instruction code 2, which represents downloading and execution, and the specific processing is divided into 2 types: if the response data is a URL, the PE corresponding to the URL is downloaded and executed; if it is a base64 encoded content, the decoded data is decoded first and then executed. The response data here is actually the new version of base64-encoded PE file, which is equivalent to upgrade, which also indicates that the old version may have been deprecated."]]],[10,10],[1,"p",[[0,[],0,"The v1 version defines a total of 8 instructions, and the correspondence between the instruction code and the instruction string is as follows."]]],[10,11],[1,"p",[[0,[],0,"Due to the nulling of some instructions, the eight instructions actually correspond to three operations (subsequent versions are similar)."]]],[10,12],[1,"h3",[[0,[],0,"DGA Algorithm"]]],[1,"p",[[0,[],0,"v1's DGA takes the date string (e.g. \"2022/07/05\") as input, calculates its MD5 value, then divides the MD5 string into four 8-byte substrings, and splices them with the 4 suffixes of .com, .net, .org, .duckdns.org in turn to get the daily 4 groups of 16 DGA domain names, the algorithm is implemented as follows."]]],[10,13],[1,"p",[[0,[],0,"Sample domains are as follow:"]]],[10,14],[1,"h2",[[0,[],0,"v2 version"]]],[1,"p",[[0,[],0,"The v2 version appears as a sample of two programming language implementations, Golang and C++, but with the same functionality. The analysis here takes the Golang sample with MD5=f3e0b960a48b433bc4bfe6ac44183b74 as an example, and its C2 initialization function is shown below, which can obviously see the hard-coded C2 domain names."]]],[10,15],[1,"p",[[0,[],0,"The v2 version of C2 communication starts to use json format, and the meaning of the fields is relatively clear. It collects roughly the same information as v1, including: volume serial number (HWID), computer name, user name, system version, antivirus information, active window information, etc. The new fields are: .net framework version (e.g. v2.0.50727), USB status, outgoing package type and its own version. The following is an actual observed version number information, Bot_Version=1.2/G may be interpreted as: version=v1.2, writing language=Golang."]]],[10,16],[1,"p",[[0,[],0,"The v2 version of the C++ language sample integrates the same C2, and the version information in the live package becomes \"Bot_version:1/C\", which collects the information shown in the figure below."]]],[10,17],[1,"p",[[0,[],0,"According to the code similarity analysis, the v2 C++ language sample is homologous with the later v3 C++ sample, which means that the latter is evolved from the former."]]],[1,"p",[[0,[],0,"The v2 version has a total of two kinds of instructions."]]],[10,18],[10,19],[10,20],[1,"p",[[0,[],0,"The v3 version also uses json format to save host information in C2 communication, and the overall structure of the sent data is Byte_0x46+TotalLen+InfoLen+Info.json. Compared to v2, v3 adds several fields related to mining, and the collected information includes:"]]],[10,21],[1,"p",[[0,[],0,"An example of a live package for v3 is shown below."]]],[10,22],[10,23],[10,24],[1,"p",[[0,[],0,"Where Transfer_Port indicates that the host is expected to make another request to 2929, and Message_Type indicates the instruction code, whose value is 7, indicating download & execute."]]],[1,"p",[[0,[],0,"After receiving the above instruction, bot makes another request to C2's TCP port 2929. Cuda is a parallel computing framework introduced by Nvidia that can only be used for its own GPU, and a Cuda_Version of 0 here means that Cuda is not supported."]]],[10,25],[1,"p",[[0,[],0,"C2 then responds with an XMRig miner program, which Client receives and saves and then injects XMRig into the puppet process according to instruction 7 to start performing mining work."]]],[10,26],[1,"p",[[0,[],0,"During the analysis we found that the v3 version has recently been continuously distributing an identical XMRig mining program, the latter integrated with the default mining configuration information, private mining pool address: 45.61.187.7:7733"]]],[10,27],[1,"p",[[0,[],0,"The meaning of the relevant fields can be found in "],[0,[1],1,"Blockchain"],[0,[],0,"'s "],[0,[2],1,"API manual"]]],[1,"p",[[0,[],0,"It is worth emphasizing that the v3 version does not parse the returned results, but directly  feed  it into the DGA algorithm as a whole to generate the domain name. Instead, the wallet address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa is said to be the Bitcoin Genesis address held by Satoshi Nakamoto himself. Over the past decade or so, small amounts of bitcoin have been transferred to this wallet on a daily basis for various reasons, so it is variable and that change is difficult to predict, so the balance information for this wallet can also be used as DGA input."]]],[1,"p",[[0,[],0,"At the time of writing, we found that other researchers had recently noticed this use of bitcoin account transaction information as DGA input for v3. The results of their analysis agreed with ours, but they did not notice that Orchard had actually been around for a long time."]]],[1,"p",[[0,[],0,"The complete v3 DGA algorithm is as follows."]]],[10,28],[1,"h2",[[0,[],0,"USB Infection"]]],[1,"p",[[0,[],0,"Orchard's file infection is not a traditional code insertion, but a file replacement. When a USB storage device is detected, Orchard will create a hidden directory under the root directory of the device, traverse all files for infection, and back up the files before and after infection to this hidden directory, the infected object is infected with the type attribute removed, and after infection all become exe type, and append the .exe suffix to become an executable file. Then the sample will copy itself to the infected directory and randomly named, the string is saved to the resources of the infected file. When the infected file in the device is executed by the user in the new system, it will launch the sample file in the hidden directory to achieve the purpose of spreading the infection."]]],[1,"p",[[0,[],0,"The USB infection process involves two embedded PE files, the first one is a DLL file that will be released to the %LocalAppData% directory, this DLL is called CGO_Helper by Orchard and is mainly used to extract and replace the icon of the infected file, its MD5 is The second file is an exe file with MD5 of f3c06399c68c5fdf80bb2853f8f2934b, which is used as a template file to store the infected code, and all the data of the infected file will be replaced with the data of this template file. The function of this template is to find the corresponding exe in the hidden directory to start execution according to the exe name in the resource, so the resource of the infected file is saved with the name of the backup Orchard sample."]]],[1,"p",[[0,[],0,"USB infection case example is as follows, the name of Orchard sample is saved in the resource of the infected file, when the user clicks on the infected exe, it will start the Orchard sample file in the hidden directory."]]],[10,29],[1,"h1",[[0,[],0,"Summary"]]],[1,"p",[[0,[],0,"Orchard is a botnet family that uses DGA technology. The latest version is dedicated to mining and has started using more unpredictable information like transaction information of bitcoin accounts as input to DGA, making detection more difficult. In over 1 year, Orchard has appeared in 3 different versions with changes in programming language and DGA implementation, indicating that Orchard is a botnet family that is still active and deserves our vigilance. We expect more variants to emerge subsequently, for which we will continue to keep an eye on, and will continue to disclose new findings."]]],[10,30],[1,"h2",[[0,[],0,"IOCs"]]],[1,"h3",[[0,[],0,"C2"]]],[10,31],[1,"h3",[[0,[],0,"MD5"]]],[10,32],[1,"h3",[[0,[],0,"Private mining pool"]]],[10,33],[1,"h2",[[0,[3],1,"Contact us"]]],[1,"p",[[0,[],0,"Readers are always welcomed to reach us on "],[0,[4],1,"Twitter"],[0,[],0," or email us to netlab[at]360.cn."]]]],"ghostVersion":"3.0"}