{"id":21906,"date":"2023-05-03T03:20:54","date_gmt":"2023-05-03T11:20:54","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2023\/05\/03\/news-15637\/"},"modified":"2023-05-03T03:20:54","modified_gmt":"2023-05-03T11:20:54","slug":"news-15637","status":"publish","type":"post","link":"https:\/\/www.palada.net\/index.php\/2023\/05\/03\/news-15637\/","title":{"rendered":"A doubled \u201cDragon Breath\u201d adds new air to DLL sideloading attacks"},"content":{"rendered":"<p><strong>Credit to Author: Gabor Szappanos| Date: Wed, 03 May 2023 10:00:12 +0000<\/strong><\/p>\n<div class=\"entry-content lg:prose-lg mx-auto prose max-w-4xl\">\n<p>We have spotted malicious DLL sideloading activity that builds on the classic sideloading scenario, but adds complexity and layers to its execution. Moreover, our investigation indicates that the responsible threat actor(s) fell so much in love with this adaptation of the original scenario that they used multiple variations of it, repeatedly swapping out a particular component in the process to evade detection at this step of the attack chain.<\/p>\n<p>Earlier forms of the attack have been covered previously in the industry, mainly in the Sinophone <a href=\"https:\/\/www.ctfiot.com\/40522.html\">CTFIoT<\/a> and <a href=\"https:\/\/zhuanlan.zhihu.com\/p\/515150114\">Zhizu<\/a> blogs. The attack is based on a classic sideloading attack, consisting of a clean application, a malicious loader, and an encrypted payload, with various modifications made to these components over time. The latest campaigns add a twist in which a first-stage clean application \u201cside\u201dloads a <em>second<\/em> clean application and auto-executes it. The second clean application sideloads the malicious loader DLL. After that, the malicious loader DLL executes the final payload.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91431\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png\" alt=\"A flow chart showing the genericized flow of the double-loading technique described in the article\" width=\"640\" height=\"199\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png 1105w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png?resize=300,93 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png?resize=768,238 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-01.png?resize=1024,318 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 1: DLL sideloading, with recently identified extra steps; the clean applications are shown in blue boxes and within the blue outline, while the malicious steps are shown in orange boxes with red type and outlined in red. This chart will appear again in the report with the specifics of each variation highlighted<\/em><\/p>\n<p>The threat actor most associated with this attack is variously called \u201cOperation Dragon Breath,\u201d \u201cAPT-Q-27,\u201d or \u201cGolden Eye Dog,\u201d and is believed to specialize in the online-gambling space and its participants. These actors liked this two-clean-apps scenario so much that they used multiple scenarios in which the second-stage application is replaced with other clean applications.<\/p>\n<p>The original campaigns targeted Chinese-speaking Windows users engaged in online gambling, and initial infection vectors were distributed via Telegram. We have, to date, identified intended targets in the Philippines, Japan, Taiwan, Singapore, Hong Kong, and China. Sophos normally blocks sideloading attacks during the sideloading process, so the payload never executes and the users are protected.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91432\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png\" alt=\"Map highlighting the affected areas -- China, Hong Kong, Japan, Philippines, Singapore, Taiwan\" width=\"640\" height=\"424\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png 1538w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png?resize=300,199 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png?resize=768,508 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png?resize=1024,678 1024w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-02.png?resize=1536,1017 1536w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 2: Where we saw Operation Double Dragon Breath<\/em><\/p>\n<p>In this investigation we found several distinct variations on the double-clean-installer approach; variations mainly involved changes to precisely which program was abused in the second stage, with a few knock-on effects caused in turn by those changes. We\u2019ll describe the most commonly encountered code we found at each stage, touching on variations as we go along.<\/p>\n<h3>The beginning: Infection vector<\/h3>\n<p>Early on, our investigation led us to a Web site (telegramos[.]org) that delivers, or claims to deliver, Chinese-language versions of the Telegram application for Android, iOS, and Windows. We noted that the site &#8212; which we and other vendors flag as malicious &#8212; occasionally but not consistently ignored our OS choices when we clicked the download links, instead delivering a version based on the user-agent string to which our browser was set, as shown in the screen captures below.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91433\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png\" alt=\"A (fake) Telegram installation csreen\" width=\"640\" height=\"384\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png 1280w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png?resize=300,180 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png?resize=768,461 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-03.png?resize=1024,614 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 3: Clicking the \u2018Windows\u201d button from the Windows download page meant nothing when our browser reported itself as Android\u2026<\/em><\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91434\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png\" alt=\"Another fake Telegram installation screen\" width=\"640\" height=\"384\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png 1280w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png?resize=300,180 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png?resize=768,461 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-04.png?resize=1024,614 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 4: \u2026so we changed our UA string to IE <\/em><\/p>\n<p>This is the site from which the affected user is thought to have downloaded the package that caused the infection. How the user first encountered the site, whether through phishing or SEO poisoning or some other method, is beyond the scope of this investigation.<\/p>\n<h3>First-stage installer: Telegram<\/h3>\n<p>As mentioned above, the initial investigation of these attacks involved a malicious Telegram installer. Later in this article we\u2019ll see variations in which other \u201clure\u201d applications were used, but Telegram was by far the most common lure, and dissecting it provides a good example of how the attack works.<\/p>\n<p>When the malicious Telegram installer (SHA256: 097899b3acb3599944305b064667e959c707e519aef3d98be1741bbc69d56a17) is run, it installs and executes the sideloading package.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-05.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91435\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-05.png\" alt=\"The fake setup wizard\" width=\"379\" height=\"295\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-05.png 379w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-05.png?resize=300,234 300w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/a><\/p>\n<p><em>Figure 5: This setup screen is actually an <\/em>evil<em> wizard<\/em><\/p>\n<p>It installs multiple components on the system, dropping them to a directory in the user data folder:<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-06.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91436\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-06.png\" alt=\"A file directory showing multiple components and a subdirectory\" width=\"546\" height=\"186\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-06.png 546w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-06.png?resize=300,102 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/a><\/p>\n<p><em>Figure 6: Gifts of the evil setup wizard<\/em><\/p>\n<p>It also creates a shortcut on the desktop. However, this shortcut does not execute the Telegram program, but an unusual command:<\/p>\n<pre>C:Users{redacted}AppDataRoamingTg_B518c1A0Ff8CappR.exe \/s\u00a0\u00a0 \/n\u00a0\u00a0 \/u\u00a0\u00a0 \/i:appR.dat\u00a0\u00a0 appR.dll<\/pre>\n<p>Here appR.exe is the regsvr32.exe Windows component, renamed. It will execute the appR.dll library, which is another renamed Windows component, scrobj.dll &#8212; the script execution engine. It will then execute the Javascript code stored in appR.dat:<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-07.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91437\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-07.png\" alt=\"The registry entry for the fake installer\" width=\"523\" height=\"258\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-07.png 523w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-07.png?resize=300,148 300w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/a><\/p>\n<p><em>Figure 7: Its reg description is Bandit, which is accurate<\/em><\/p>\n<p>When the shortcut is executed, the JavaScript code runs. To the user, it displays the expected Telegram desktop UI, mostly in Chinese:<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-08.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91438\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-08.png\" alt=\"The desktop installer for the fake Telegram\" width=\"373\" height=\"265\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-08.png 373w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-08.png?resize=300,213 300w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/a><\/p>\n<p><em>Figure 8: A mostly transliterated version of the Telegram desktop UI<\/em><\/p>\n<p>But behind the scenes it drops various sideloading components to a directory:<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-09.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91439\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-09.png\" alt=\"A file directory showing the application, two DLLs, a readme, and the second (updater) application\" width=\"575\" height=\"159\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-09.png 575w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-09.png?resize=300,83 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/a><\/p>\n<p><em>Figure 9: A directory with problematic files deposited in it<\/em><\/p>\n<p>The installer also creates a shortcut file in the user\u2019s startup directory. In this way, the malware establishes persistence and allows for automatic execution after system startup.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-10.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91440\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-10.png\" alt=\"A closer look at properties of the &quot;Application.exe&quot; item from the previous screenshot\" width=\"350\" height=\"218\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-10.png 350w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-10.png?resize=300,187 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p><em>Figure 10: A fairly innocuous-looking shortcut is anything but; note \u201cApplication.exe,\u201d which we\u2019ll see again in the next stage of the attack<\/em><\/p>\n<p>The sideloading components and the startup link are only created when the desktop Telegram link is executed. This could be an anti-analysis trick, since dynamic analysis sandboxes would not see the dropped sideloader files.<\/p>\n<h4>A first-stage variation: LetsVPN installer<\/h4>\n<p>We also found a trojanized installer for LetsVPN (SHA256: e414fc7bcd80a75d57ee4fdbb1c80a90a0993be8e8bbbe0decfc62870a2e1e86). The malicious parts of the package are the same as in the Telegram cases, but the bundled clean application is LetsVPN:<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91441\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11.png\" alt=\"The first half of a screen capture showing the LetsVPN variation of the malware\" width=\"344\" height=\"266\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11.png 344w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11.png?resize=300,232 300w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/a><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11a.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91442\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11a.png\" alt=\"The second half of a screen capture showing the LetsVPN variation of the malware\" width=\"284\" height=\"484\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11a.png 284w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-11a.png?resize=176,300 176w\" sizes=\"auto, (max-width: 284px) 100vw, 284px\" \/><\/a><\/p>\n<p><em>Figure 11: The LetsVPN variation we found is translated into Chinese on its initial screen, but the installation screen is in English<\/em><\/p>\n<p>As the Telegram installer did, it creates a shortcut on the desktop. The program that the shortcut launches invokes the JavaScript code that does the ultimate installation of the sideloading package.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-12.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91443\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-12.png\" alt=\"The same file called &quot;Application.exe&quot; above, showing the different icon\" width=\"438\" height=\"234\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-12.png 438w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-12.png?resize=300,160 300w\" sizes=\"auto, (max-width: 438px) 100vw, 438px\" \/><\/a><\/p>\n<p><em>Figure 12: The icon has changed, but the application to which it truly points remains the same<\/em><\/p>\n<h2>One more first-stage variation: WhatsApp installer<\/h2>\n<p>In one case, we did not have direct contact with the installer file, but our telemetry shows that running a file called Whatsapp.msi also leads to the installation of the malicious files we saw in the other two first-stage examples.<\/p>\n<pre>roamingwhatsapp_ae2b02appmain.exe : 91e4eb7517f55ac93b1da109539aa0011e9346be41704dc0da360ebad0f3f63d    roamingwhatsapp_ae2b02appr.dll : e25289d44403a6f6132a470fdbe6b46eade466d08eca0ad44fca519592c54fdf    roamingwhatsapp_ae2b02appr.exe : fffa7a97fba9dfb235f969ecce0e5c4a71a48a37c1bc79b77cd78f0ab72f993d    roamingwhatsapp_ae2b02littleunzip.exe : 81046f943d26501561612a629d8be95af254bc161011ba8a62d25c34c16d6d2a    roamingwhatsapp_ae2b02app-2.2232.8whatsapp.exe : 8d92c7d7f301bc0e4965dbd9253933a4580883805119dd7c27788d04c17d595e    c:userspublicapplication2application.exe : c936f1598721a9a92d7f31c6c13b55013b8a2a344e3df4156e5b033006336544    c:userspublicapplication2xlgameupdate.exe : 769d59d03036af86c7a9950f03ebc7b693a94d3e2f8ecd1d74cf5600ab948105    c:userspublicapplication2libexpat.dll : 31d2076066107bd04ab24ff7bbdf8271aa16dd1d04e70bd9cc492e9aa1e6c82b    c:userspublicapplication2basicnetutils.dll : ae2e145b36ab2ed129a2d34de435b76a1f4e5a4820d9d623e7018b87f24d0648<\/pre>\n<h4>Second stage: More sideloading<\/h4>\n<p>As mentioned, one of the most exciting things about this investigation was spotting a new variation on DLL sideloading \u2013 the use of a second \u201cclean\u201d application as a secondary stage in the attack. In these unusual attacks, the beginning (first-stage loader) and the end (payload) were the same; the only difference was in this second-stage sideloading.<\/p>\n<p>In Figure 8 above, we pointed out \u201cApplication.exe,\u201d for which the installer left a shortcut on the desktop. In Figure 11 we see it again. It\u2019s actually the program XLGame.exe, signed by Shenzhen Thunder Networking Technologies Ltd, but renamed by the attackers to Application.exe. It has a clean dependency, libexpat.dll, which is part of the package.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91444\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png\" alt=\"A version of the flowchart shown in Figure 1, highlighting how it works in the specific case of XLGame\" width=\"640\" height=\"199\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png 1105w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png?resize=300,93 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png?resize=768,238 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-13.png?resize=1024,318 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 13: The attackers used a clean-but-vulnerable application (named \u201cApplication.exe\u201d on the desktop, but really XLGame.exe) that auto-updates itself if it finds a file with a specific name. The names of malicious files are shown in the orange boxes to the right as before, and files renamed by the attacker are shown in quotation marks<\/em><\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-14.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91445\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-14.png\" alt=\"Three views of images showing digital signatures related to XLGame\" width=\"640\" height=\"274\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-14.png 780w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-14.png?resize=300,128 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-14.png?resize=768,329 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 14: XLGame\u2019s digital signatures would seem to indicate everything is in order, despite being renamed to Application.exe<\/em><\/p>\n<p>XLGame will automatically perform an automatic update if it finds a program named XLGameUpdate.exe in the same directory. The loading process makes use of this auto-update functionality, as the malicious package contains an executable with this name &#8212; but it\u2019s not the real XLGameUpdate.exe. Rather, it is a clean, signed .exe from Beijing Baidu Netcom Science and Technology Co.,Ltd.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-15.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91446\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-15.png\" alt=\"Three images showing the signatures related to the fake XLGameUpdate application\" width=\"640\" height=\"271\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-15.png 780w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-15.png?resize=300,127 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-15.png?resize=768,325 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 15: XLGameUpdate.exe is actually a different, unnamed application, but renamed to trick \u201cApplication.exe\u201d (really, XLGames.exe) into running it<\/em><\/p>\n<p>And now we return to the usual DLL-sideloading process. This second-stage loader has a dependency, BASICNETUTILS.dll, which the attackers have replaced with a malicious loader DLL. The malicious loader DLL finds templateX.txt in the same directory, loads the content, decrypts the payload loader shellcode, and executes it. (All these files are of course located in the same directory, as seen in Figure 7 above.)<\/p>\n<h4>Second stage: More sideloading (a variation)<\/h4>\n<p>As noted in the introduction, the attackers appear to be very fond of their double-dip DLL sideloading strategy, swapping various clean apps into the new spot in the sideloading process. Figure 16 shows a flow very similar to the previous scheme, but the clean executable is different in the second-stage loader. Consequently, the malicious loader DLL has to be renamed to reflect the dependency of the replaced clean application.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91447\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png\" alt=\"The flowchart from Figures 1 and 13, showing the specifics for the XLGame version of the attack\" width=\"640\" height=\"199\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png 1105w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png?resize=300,93 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png?resize=768,238 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-16.png?resize=1024,318 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 16: The attackers are running the same extra-step playbook as in Figure 13, but they\u2019ve swapped in a new program in the \u201cXLGameUpdate.exe\u201d spot; by extension, the to-be-swapped DLL shown at upper right must change as well. <\/em><em>Again, the names of malicious files are shown in the orange boxes to the right, and files renamed by the attacker are shown in quotation marks<\/em><\/p>\n<p>As before, \u201cApplication.exe\u201d is actually XLGames.exe. The second-stage clean loader is renamed once again to XLGameUpdate.exe, but its original (real) name is KingdomTwoCrowns.exe. It is not digitally signed, so it\u2019s not clear what the benefit might be of replacing the clean, signed loader from Baidu with this one.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-17.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91448\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-17.png\" alt=\"A Properties screen showing that XLGameUpdate is once again not that program\" width=\"453\" height=\"252\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-17.png 453w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-17.png?resize=300,167 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/a><\/p>\n<p><em>Figure 17: It\u2019s still not XLGameUpdate, but this time it\u2019s actually \u201cKingdomTwoCrowns\u201d<\/em><\/p>\n<p>It has the following PDB path:<\/p>\n<pre>C:buildslaveunitybuildartifactsWindowsPlayerWin32_nondev_i_rWindowsPlayer_Master_il2cpp_x86.pdb<\/pre>\n<p>This second-stage loader is used for the usual sideloading scenario; its dependency, UNITYPLAYER.dll, is replaced with a malicious loader DLL. The malicious loader finds templateX.txt in the same directory, loads the content, decrypts the payload loader shellcode, and executes it.<\/p>\n<p>Thus, the second-stage clean loader is different, but the second-stage malicious loader and the payload files in this variation are essentially the same as in the variation described in the previous section (aside from being renamed). In fact, one of the encrypted payload files (3fc9405cfe9272323bd96aacfd082c16b392fea6e0f108545138026aa6f79137) was used in both scenarios. (We\u2019ll discuss the payload in the final section of this article.)<\/p>\n<h4>Second stage: More sideloading (one more variation)<\/h4>\n<p>Once again, this scenario swaps out the clean executable in the second-stage loader, this time abusing a clean, digitally signed tool once offered by HP. \u00a0This is very similar to the previous scheme, but since the clean executable is once again different in the second-stage loader, the malicious loader DLL has to once again be renamed to reflect the different dependency.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91449\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png\" alt=\"The flowchart form Figure 1, 13, and 16, showing the change to the clean second-stage executable\" width=\"640\" height=\"199\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png 1105w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png?resize=300,93 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png?resize=768,238 768w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-18.png?resize=1024,318 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 18: One more variation on the double-dip sideloading theme, with an HP tool in the XLGameUpdate spot at center-top and yet another DLL in the highlighted malicious spot at upper right. <\/em><em>Once again the names of malicious files are shown in the orange boxes to the right, and files renamed by the attacker are shown in quotation marks<\/em><\/p>\n<p>The second-stage clean loader is again renamed to XLGameUpdate.exe. Its original name is d3dim9.exe. It is digitally signed by HP Inc.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-19.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91450\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-19.png\" alt=\"A Properties screen showing that once again, XLGameUpdate is not what it seems\" width=\"640\" height=\"293\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-19.png 683w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-19.png?resize=300,137 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><em>Figure 19: This time, the application renamed as XLGameUpdate is really a signed, clean application from HP<\/em><\/p>\n<p>This second-stage loader is used for the usual sideloading scenario. Its dependency, d3dx9_43.dll, is replaced with a malicious loader DLL. That DLL finds templateX.txt in the same directory and \u2013 once again &#8212; loads the content, decrypts the payload loader shellcode, and executes it.<\/p>\n<h3>Third stage: At last, the malicious DLL<\/h3>\n<p>The second-stage loaders had interesting variations, but all roads lead to one thing: cryptowallet theft. To that end, the payloads we saw in this investigation were fairly constant.<\/p>\n<p>At the end of stage 2, the clean second-stage loader (whichever one is in use) calls a specific DLL \u2013 and get the malicious, identically named version the attackers have placed in the same directory, in the classic DLL-sideloading fashion. The malicious DLL loads the payload from the file template.txt, then decrypts it.<\/p>\n<p>The payload\u2019s encryption is a simple combination of bytewise SUB and XOR:<\/p>\n<pre>int __fastcall decrypt(int a1, int a2)    {    \u00a0 int result; \/\/ eax    \u00a0 for ( result = 0; result &lt; a2; ++result )    \u00a0\u00a0\u00a0 *(_BYTE *)(result + a1) = (*(_BYTE *)(result + a1) - 122) ^ 0x19;    \u00a0 return result;<\/pre>\n<p>&nbsp;<\/p>\n<p>The decrypted content is a loader shellcode, which decompresses and executes the final payload. This execution log shows this decompression of the final payload:<\/p>\n<pre>4010ae\u00a0\u00a0\u00a0 GetProcAddress(LoadLibraryA)    4010ae\u00a0\u00a0\u00a0 GetProcAddress(VirtualAlloc)    4010ae\u00a0\u00a0\u00a0 GetProcAddress(VirtualFree)    4010ae\u00a0\u00a0\u00a0 GetProcAddress(lstrcmpiA)    401153\u00a0\u00a0\u00a0 LoadLibraryA(ntdll)    4010ae\u00a0\u00a0\u00a0 GetProcAddress(RtlZeroMemory)    4010ae\u00a0\u00a0\u00a0 GetProcAddress(RtlMoveMemory)    40148e\u00a0\u00a0\u00a0 VirtualAlloc(base=0 , sz=20a00) = 600000    401635\u00a0\u00a0\u00a0 GetProcAddress(LoadLibraryA)    401697\u00a0\u00a0\u00a0 LoadLibraryA(ntdll)    401635\u00a0\u00a0\u00a0 GetProcAddress(RtlDecompressBuffer)    4016bd\u00a0\u00a0 RtlDecompressBuffer(fmat=102,ubuf=600000, usz=20a00, cbuf=4016e3, csz=16789) (Outsz: 20a00) = 0    4011e2\u00a0\u00a0\u00a0 VirtualAlloc(base=0 , sz=26000) = 621000    4011f9\u00a0\u00a0\u00a0 RtlMoveMemory(dst=621000, src=600000, sz=400)    401235\u00a0\u00a0\u00a0 RtlMoveMemory(dst=622000, src=600400, sz=17e00)    401235\u00a0\u00a0\u00a0 RtlMoveMemory(dst=63a000, src=618200, sz=4c00)    401235\u00a0\u00a0\u00a0 RtlMoveMemory(dst=63f000, src=61ce00, sz=1800)    401235\u00a0\u00a0\u00a0 RtlMoveMemory(dst=643000, src=61e600, sz=200)    401235\u00a0\u00a0\u00a0 RtlMoveMemory(dst=644000, src=61e800, sz=2200)    4012ed\u00a0\u00a0\u00a0 LoadLibraryA(KERNEL32.dll)<\/pre>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91451\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png\" alt=\"The payload decompressed\" width=\"480\" height=\"480\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png 480w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=150,150 150w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=300,300 300w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=32,32 32w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=50,50 50w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=64,64 64w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=96,96 96w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-20.png?resize=128,128 128w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/p>\n<p><em>Figure 20: The decompression of the final payload<\/em><\/p>\n<p>After this, the shellcode loads the final payload DLL into memory and executes it.<\/p>\n<h3>Fourth stage: The payload<\/h3>\n<p>The payload DLL contains one export, rudely named:<\/p>\n<pre>dllname: ServerDll.dll    \u00a0 0\u00a0\u00a0 1\u00a0 0x14780\u00a0 0x15380 F\u25a0ck<\/pre>\n<p>This creates a flag key in the registry. The name of the key will be HKCUSOFTWARE%COMPUTERNAME%, if GetComputerName returns a value; otherwise <em>UnkNow<\/em> will be used.<\/p>\n<p><a href=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-21.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-91452\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-21.png\" alt=\"The flag key\" width=\"570\" height=\"302\" srcset=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-21.png 570w, https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/figure-21.png?resize=300,159 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><\/p>\n<p><em>Figure 21: The flag key picked up the name of the machine on which this exploit was dissected<\/em><\/p>\n<p>Multiple values are stored under this key:<\/p>\n<ul>\n<li>Time: records the date and time of installation of the malware<\/li>\n<li>CopyC: updated C2 address (encoded with bytewise XOR 5 + BASE64)<\/li>\n<li>ARPD: list of names, separated with | . creates new thread for each; searches for strings isARDll, PluginMe, getDllName \u2013 may be export names<\/li>\n<li>ZU: value is used in the procedure that reads the wallet seed for the Chrome extension; likely provides destination information for exfiltration of wallet contents<\/li>\n<li>Remark: stores the hostname<\/li>\n<\/ul>\n<p>The backdoor supports a set of numeric command codes:<\/p>\n<p>&nbsp;<\/p>\n<p>It also contains a string related to <a href=\"https:\/\/metamask.io\/\">MetaMask<\/a>. MetaMask is a crypto (Ethereum) wallet available as, among other things, a Chrome extension. In the past, attackers looking to steal from cryptowallets have targeted users who have installed this extension, and that\u2019s what appears to be happening here.<\/p>\n<pre>C:Users%sAppDataLocalGoogleChromeUser     C:Users%sAppDataLocalGoogleChromeUser DataDefaultExtensionsnkbihfbeogaeaoehlefnkodbefgpgknn<\/pre>\n<p>The C2 server name, nsjdhmdjs[.]com, has been associated with Operation Dragon Breath (aka \u201cAPT-Q-27\u201d or \u201cGolden Eye Dog,\u201d as above). Some of the DLL sideloading characteristics we\u2019ve demonstrated and also the ServerDll.dll name are likewise characteristic of this threat actor.<\/p>\n<h2>Fourth stage: Payload variations \u2013 a debug build version and the gh0st of a sample<\/h2>\n<p>We also found, on VirusTotal, a specific version of the payload (SHA256: d86f1292d83948082197f0a29fcb69fdec9feb4bf3898d7b8e693c7d5a28099c) that contained more internal information than usual. This is also an executable, unlike the usual payloads (which are DLLs).<\/p>\n<p>The PDB path is the usual:<\/p>\n<pre>D:Work3\u8fdc\u63a7\u4f01\u4e1a\u8fdc\u7a0b\u63a7\u5236DebugServerDll.pdb<\/pre>\n<p>In this case, however, it contains the source code of the infamous gh0st RAT. The source archive is supposed to be dropped by one of the procedures, but that code is never executed:<\/p>\n<pre>\u00a0 hFile = CreateFileA(lpFileName, 0x40000000u, 1u, 0, 2u, 0, 0);    \u00a0 if ( hFile == (HANDLE)-1 )    \u00a0\u00a0\u00a0 v4 = 0;    \u00a0 if ( WriteFile(hFile, &amp;gh0st_rat_src, 0xE5B1Au, &amp;NumberOfBytesWritten, 0) )    \u00a0\u00a0\u00a0 v4 = 1;    \u00a0 CloseHandle(hFile);    \u00a0 return v4;<\/pre>\n<p>For this sample, the C2 server is 23[.]225[.]147[.]227.<\/p>\n<p>We also saw on VirusTotal a similar sample (sha256: 64613eadd91a803fe103bef5349db04ddfc01b8d115ba7a24a694563123d38ad) that contained gh0st RAT source code, but no debug information and no PDB information. Both these debug versions were submitted to VirusTotal from Hong Kong, one of the regions known to be affected, so it is likely they were indeed used in attacks.<\/p>\n<p>A full list of IoCs is <a href=\"https:\/\/github.com\/sophoslabs\/IoCs\/blob\/master\/double-dragon-breath-iocs.csv\">available on our GitHub<\/a>.<\/p>\n<h2>Conclusion<\/h2>\n<p>DLL sideloading, first identified in Windows products in 2010 but prevalent across multiple platforms, continues to be an effective and appealing tactic for threat actors. This double-clean-app technique employed by the Dragon Breath group, targeting a user sector (online gambling) that has traditionally been less scrutinized by security researchers, represents the continued vitality of this approach. While speculation about future uses of the technique is beyond the scope of this post, it may be useful for defenders to keep an eye out for the behavior we\u2019ve documented here.<\/p>\n<h3>Acknowledgements<\/h3>\n<p>Thanks to Xinran Wu of SophosLabs and Andrew Brandt of X-Ops Comms for their assistance on this writeup.<\/p>\n<\/p><\/div>\n<p><a href=\"https:\/\/news.sophos.com\/en-us\/2023\/05\/03\/doubled-dll-sideloading-dragon-breath\/\" target=\"bwo\" >http:\/\/feeds.feedburner.com\/sophos\/dgdY<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/news.sophos.com\/wp-content\/uploads\/2023\/05\/shutterstock_2263767925.jpg\"\/><\/p>\n<p><strong>Credit to Author: Gabor Szappanos| Date: Wed, 03 May 2023 10:00:12 +0000<\/strong><\/p>\n<p>Exploits of the venerable vulnerability gain in complexity<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10378,10377],"tags":[28964,129,27030,16771],"class_list":["post-21906","post","type-post","status-publish","format-standard","hentry","category-security","category-sophos","tag-dll-sideloading","tag-featured","tag-sophos-x-ops","tag-threat-research"],"_links":{"self":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/21906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=21906"}],"version-history":[{"count":0,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/21906\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=21906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=21906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=21906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}