Thursday, March 20, 2025

The Art of Evasion: How Attackers Use VBScript and PowerShell in the Obfuscation Game

 


Summary

 

As we know, using obfuscated VBScript to execute obfuscated PowerShell is a common technique in malware to evade detection and complicate analysis. This approach leverages the strengths of both scripting languages while making it harder for security tools and analysts to understand the malicious intent.

 

Recently I came across a malware that is very well-designed for these obfuscation techniques to use, which is so interesting and attracted my curiosity to learn more about what’s happened inside the malware, and it was also low detection rate until first discovered.

 

Below, I would like to share how the attackers use VBScript and PowerShell to evade detection, maybe it can help other malware researchers or analysts, and the common technique but new doing uncommon which being talked on both VBScript obfuscation and PowerShell obfuscation.

 

 

Technical analysis

 

Basic info

The sample hashs:

md5 0e513e80fc18e3db4f0eb6ecb558534b

Sha256
7444d08579781b3d7b233e9fd3e7f9b31a85837c29adf2f4ae7965a628078639

 

 

VBScript obfuscation and evasion technique

In order to execute the VBScript, the attacker uses a mix of obfuscation that combines irrelevant comments, time-based delay, string splitting and concatenation, and dynamic behavior. It is very thoughtful. In addition, the structure of the VBScript code seems to intentionally disrupt logical order to interfere with analysts.

 

 

Adding Irrelevant Comments

The first sight is that the malware was inserted by a large number of difficult-to-understand comments or annotations, which seem like the stream of consciousness in monologues or novels or random text; its aim is to have a mind to interfere with or confuse or mislead information with analysts and antivirus.

Fig.1 a large number of understandable annotations for interfering

 

Ok, in order to do an analysis for this kind of malware, it is a time-consuming thing to remove all the annotations manually. The first thought is to use regular expression; a text editor like Sublime can help us to handle them. To replace all the single-line comment content with regular expressions is '.*$, but it should be done carefully because the obfuscation PowerShell will be replaced and should be checked later one by one.

Fig.2 regular expressions

 

 

Time-Based Obfuscation

Using time delays or conditions to execute parts of the script only after a certain time. Malware often uses time delays to evade sandbox detection and avoid immediate detection. Here, the VBScript code snippet appears to be a time-delay loop, starting a loop that continues until the current time Now() exceeds Suspensorium (i.e., for 9 seconds), and then it will loop 50 times and pause the script for 100 milliseconds (0.1 seconds) during each iteration of the loop, and the real PowerShell scripts will be executed when it Suspensorium exceeds 50.

Fig.3 VBScript Time delay to execute PowerShell

 

Combining obfuscation technique

The below VBScript code snippet demonstrates a malware evasion technique that combines time-based delaysstring obfuscation, and dynamic behavior.

1.       String Obfuscation: pronegotiation= array(79+1,79,87,69,82,83,72,69,76,76), The array contains ASCII codes for the characters in the string "POWERSHELL"

2.       Time-Based Evasion: Checks if the current time (Now()) is less than the value of Suspensorium

3.       Dynamic Behavior: The script behaves differently depending on the current time

Fig.4 combining obfuscation technique

 

String splitting and Concatenation

 using ChrW(34) to concatenate strings that include double quotes, and using Chr(99) instead of the literal character 'c' makes the script harder to read and analyze; the command executes splitting to “Exe + chr(99) + “ute.”

Fig.5 VBScript String splitting and Concatenation

 

 

 

PowerShell obfuscation and evasion technique

In order to execute the PowerShell in VBScript, the attacker uses a user-defined algorithm and heavily obfuscates strings. It is different from other APT groups that use mature algorithms for obfuscation of strings; the attacker is very professional.

 

String splitting and Concatenation

The PowerShell code, the string splitting by well design in VBScript, and using the variable Hennafarvedes and character “&” for concatenation. And the variable in VBScript becomes a bridge in PowerShell scripts.

Fig.6 PowerShell String splitting and Concatenation

 

 

Specific Algorithm for Deobfuscated Script

The real intents in the well design strings, it extracts the characters by a specific algorithm with hardcode value It iterates over the array, starting at index 4 and incrementing by 5 each time. The function returns the concatenated string.

Fig.7 specific algorithm for deobfuscated script

 

 

String obfuscation with inserting invalid characters

The below strings obfuscation technique is also very special; the valid characters are only used as a small part of them and used by a user-defined algorithm to extract them, but the unused strings are like random characters to insert and confuse analysts, like pouring a pile of garbage into a real PowerShell to conceal the attacker's intentions. From the above specific algorithm and hardcoded value, we can get a glimpse of being proficient in the use of obfuscation techniques by the attackers.

Fig.8 strings obfuscation


The real intent
From the above analysis, do further research analysis; the PowerShell script can download the payload from the remote URL address hxxps[:]//aghayezayeat.ir/kids/tyrosines.lzh and finally execute the payload. Here it is not special, and the URL can’t be accessed until now.

Fig.9 PowerShell snippet

 

 

Conclusion

From the above process of analysis, it shows that the attacker is very professional on combining different type of obfuscation techniques to do evasion and being proficient in programming, the malware sample tells cybersecurity community, the attacker always look for breakthroughs in defense and are very proactive, a more hidden threat around the digital world; let’s pay close attention.

 

 

IOCs

Files:

SKMBT20783_ZM.vbs md5 0e513e80fc18e3db4f0eb6ecb558534b

Sha256
7444d08579781b3d7b233e9fd3e7f9b31a85837c29adf2f4ae7965a628078639

 

Network:

hxxps[:]//aghayezayeat[.]ir/kids/Tyrosines.lzh

hxxps://aghayezayeat[.]ir/529/eiRBgmsetYWnjJJIug45[.]bin ( from vmray Platform)

185[.]159.153.133

 

Host:

C:\Users\kEecfMwgj\AppData\Roaming\Hikes.Ove

End.


──────────────────────
Seeker(李标明) · @clibm079    
China · Independent Malware Analyst & Researcher 

Labels: , , , , ,

Friday, March 14, 2025

The Art of Deception: A Deep Dive into Advanced Trojan-Dropper Obfuscation and Their True Intentions



Summary

 

First thanks for Szabolcs Schmidt was calling global malware analysts to analysis the samples on X, I’m really appreciate his work and he is helping to make cybersecurity more safer and stronger.

In this report, I do plan to dive deep into more details of the advanced Trojan dropper; it looks like obfuscation mechanisms, but until now, their true intentions have been unknown.

The Trojan dropper is very intriguing and different from other APT groups. If you are keen to learn from the latest and related report, please click here.

 

Technical analysis

 

Basic info

The sample hashs:

md5 A699AFD908E0DEC5C96FF7188450B89F

Sha256
f18631344d6f7fc57fd248edce37baeb11976e315b72b68d48311c406ace3f8c

 

Operation system: Operation system: Windows(95)[I386, 32-bit, GUI]

(Heur)Packer: Packer detected[High entropy + Section 1 (".data") compressed]

 

 

Advanced string obfuscation Mechanisms?

The strings in the malware Trojan dropper were obfuscated, so it is a big challenge for only static analysis. It is also not to encode those strings with simple base64 or XOR; It appears that it is a good and User defined advanced string obfuscation techniques. Until now it is not clear, let’s do it.

Fig.1 User defined advanced strings obfuscation techniques

 

Three categories for obfuscation mechanisms

The above string looks like obfuscation mechanisms can be classified into three categories: the hardcoded prefix with %s, the hardcoded suffix with %s, and the hardcoded without %s.

The hardcoded prefix with %s

Let’s take the string “%s lbMG4xVIjgrp99jCpcEHRP2Dk4tuy” as an example: it allocates a memory block of size a4 + 1 and If the memory allocation is successful (v5 is not NULL), the first byte of the allocated memory is set to the value of aSLbmg4xvijgrp9[0].

Fig. 2 the hardcode prefix

 

 

The hardcoded suffix with %s

Let’s take the string “iKutjR2ydZ1tUZPHflBndXLYdaNF%s” as an example: it allocates a memory block of size a1 + 48239 and Whether the length of the string "iKutjR2ydZ1tUZPHflBndXLYdaNF%s" is odd and Regardless of the conditional check, the function always returns the pointer v2.

Fig. 3 the hardcode suffix

 

 

The hardcoded without %s

Let’s take the string “WaioFh2jmJmyIwAM” and the sub_407FE3 as an example:

1.      The strings are related to the sub_407F3E includes The hardcoded suffix with the argument 323, allocates memory, and immediately frees it;

2.      Attempts to allocate memory of size a5 + 1

3.      If the allocation fails, retries up to 2060(0x80C) times, sleeping for 72(0x48u) milliseconds between each retry.

4.      If all retries fail, terminates the program using exit(0).

5.      Returns the pointer to the allocated memory.

Fig. 4 without %s

 

The below is another example, and it seems more complicated, but the design is similar when it allocates memory and immediately frees it, sleeping in different times and exiting.

Fig. 5 without %s

 

 

 

What’s the purpose?

What purpose do those three categories serve as obfuscation techniques? Let’s move forward to the type of the hardcoded without %s, which is a little bit different to find when it allocates memory, and v23 points to the 31st byte (offset 31) of the allocated memory block, which points to a new offset within the allocated memory block and then frees it. And the variable v23 is not used for any purpose. It really attracts malware analysts to pay close attention to it; the similar designs are spread in the middle of the code.

Fig. 6 unclear purpose 1

 

Let’s continue to see more examples. The function sub_424BCE allocates memory and performs a specific initialization on the allocated memory and checks if the first byte is equal to the ASCII49 value for the character '1'). If true, it isv29 incremented by 1. and finally freed. And the variable v29 is not used for any purpose.

Fig. 7 unclear purpose

 

 

 

Seems to be finding new things

Until now, the purpose of those things is unclear; curiosity drives me to learn more. I am careful to observe the code and find the function ub_407FE3 is used five times (here just showing the snippet), so I am very excited to know what the motivation is for this.

Fig. 8 ub_407FE3 is used for five times

 

Let’s move to the first sub_407FE3 and step into the sub_407F3E, and the function allocates 48,562 bytes of memory using the allocated malloc and The expression strlen("iKutjR2ydZ1tUZPHflBndXLYdaNF%s") & 1 checks if the length is odd and always returns v2, which is the memory pointer; the string “iKutjR2ydZ1tUZPHflBndXLYdaNF%s” is used for a condition to calculation.

Fig. 9 sub_407F3E

 

And then the parameter v56 passed to the next function sub_4149AA(2054, 247, 3125, 722, v56, 1464); and finally create the temp directory "C:\\Users\\xxx\\AppData\\Local\\Temp\\" to the allocated memory. So here we know that the string “iKutjR2ydZ1tUZPHflBndXLYdaNF%s” looks like an obfuscation technique, but in fact it can’t be deobfuscated, and the design is to intentionally mislead analysts who consider it some kind of obfuscation technique.

Fig.10 Trojan dropper get the temp directory

 

To continue moving forward and diving deeper into the function sub_410E9D(4552, 0, v55, 9993, 0, 1766, v51, v56, v54) and their parameter, the variable v55 from the function v55 = (void *)sub_407FE3(6897, 41, 862, 0, 2046); the value 003B2AE0 is a pointer address that now seems without any valuable data.

Fig. 11 without any valuable data

 

Moving forward to the function sub_421C4C and diving deeper into details and understanding that it will generate random strings as a part of the Trojan dropper file name (e.g, TujxgfVN) that are based on the specific strings “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789”, but the whole process does not use any obfuscation string. It is really unbelievable that it seems to do mathematical calculations but is actually loading DLLs; it implies that the threat actor has high skills for hidden purposes;.

Fig. 12 the code for generating a random string


Fig. 13 return a random string TujxgfVN

 

The variable v55 is used for many functions as a parameter passed, but let’s focus on the next function, sub_410E9D, to see what’s happened.

Fig. 14 v55 is used many times

 

When sub_410E9D finished and the address of memory 003B2AE0 and its values changed to the strings “C:\\Users\\xxx\\AppData\\Local\\Temp\\Verify-TujxgfVN.exe,” it is about to be executed as a new name Trojan dropper in the new directory. Yeah, that’s it! The value of address in memory will pass to the next function as a parameter.

Fig.15 create a new Trojan dropper in temp directory

 

When the Trojan dropper Verify-TujxgfVN.exe is created, it will be triggered and executed by the runas a powerful command-line tool that allows you to run programs or commands as a different user, typically with elevated privileges (e.g., as an administrator).

Fig.16 to run the Trojan dropper Verify-TujxgfVN.exe

 

Conclusion

From the above process of analysis, those strings are embedded in Trojan dropper is not obfuscation techniques but well-designed related to memory allocated and the information that Trojan dropper will handle with, they don’t need to do a deobfuscation trying or decoding with them, those strings themselves without any practical significance, such as prompt information, API or system commands, the design is very different from other APT group, it seems that the threat actors are good at math and the Memory data technology processing, and with high programming skill and understanding how to anti-analysis and protect the malware itself, on the process of debugging, and finding the command-line instruction “cmd.exe /C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del /f /q \"%s\"” that combines several actions to remove itself and anti-debugger. After all, this is a novel design and a new try for hiding their true intentions. Very special!

 

End.


──────────────────────
Seeker(李标明) · @clibm079    
China · Independent Malware Analyst & Researcher 

Labels: , , , ,

Monday, March 10, 2025

Unmasking the Threat: Understanding Sophisticated Trojan-Dropper Mechanisms

 


Summary

 

First thanks for Szabolcs Schmidt was calling global malware analysts to analysis the samples on X, I’m really appreciate his work and he is helping to make cybersecurity more safer and stronger, I have no other words, you are doing an amazing work.

Abuse.ch's Malware Bazaar is an excellent platform for sharing and analyzing malware samples. By contributing to the community, I’m helping to improve global cybersecurity defenses and I’ve uploaded the
sample to share.

 

In this report, I do not plan to dive deep into all the details of the technique, but it is possible to make it up when having enough time to analyze; I would like to do that. In fact, it will learn more when diving deeper into the malware itself.

 

 

Technical analysis

 

Basic info

 

The sample hashs:

md5 A699AFD908E0DEC5C96FF7188450B89F

Sha256
f18631344d6f7fc57fd248edce37baeb11976e315b72b68d48311c406ace3f8c

 

Operation system: Operation system: Windows(95)[I386, 32-bit, GUI]

(Heur)Packer: Packer detected[High entropy + Section 1 (".data") compressed]

 

 

To observe the timeline and activities of the malware running in the sandbox, which created many files, such as DLLs and XML files, which created a task and connected to C2, from their behavior being checked, it is highly confident the malware is the type of Trojan dropper. After all, a logic flow graphic is as follows.

Fig.1 Trojan-Dropper Mechanisms

 

In the first stage, the Trojan dropper constantly tries to escalate privileges to execute malicious actions with the “runas” command in Windows, triggering a UAC prompt with a program name like “%sVerify-%s.exe,” which is created on the temp path like “C:\\Users\\XXX\\AppData\\Local\\Temp\\Verify-VBmJOhWZBbsNCmG.exe,” and once it is allowed to execute, it will drop a DLL file (e.g., eHMuMPu.dll). The eHMuMPu.dll will create a new XML file (e.g., dAdyJ6J.xml) and create the Trojan dropper itself with a new name (e.g., HfNUDO.exe) in the path like “C:\Program Files (x86)\Common Files\SpeechEngines\CSXW942RQP4MrCBvYGRyLsGsK\HfNUDO.exe.”. On the next step, it will continue to use the command line “schtasks /create /tn qb8iA2pa3SXfu /XML %AllUsersProfile%\Start Menu\6MGmiTas9Ndu41eCYbw\dAdyJ6J.xml /F” to create a new task named qb8iA2pa3SXfu with XML, which will execute the task every five minutes.

Fig.2 the first stage

 

In the second stage, the Trojan dropper HfNUDO.exe creates the DLL XSei1gC.dll on the “%AppData%\Media Center Programs\5xHEBJtPlIJ2Ifh\XSei1gC.dll”, and runs it with rundll32.dll in cmd.exe, which can query the details of the task qb8iA2pa3SXfu and create a new DLL BJtPlI.dll on the “%ProgramFiles% (x86)\Common Files\WanNengSoftManager\hI5sEDIwfuuZzva7AiY5A75x\BJtPlI.dll”. Because the Trojan dropper executes the task to do persistence every five minutes, which will create the two DLLs; they have the same abilities but different file names, so the DLLs can be observed in different directories. It is so crazy!

Fig.3 create DLLs with persistence task

 

When the BJtPlI.dll is created by XSei1gC.dll, it will go to the third stage, which will do antivirus and remove the Windows Defender as follows.

Fig.4 Anti Windows Defender

 

In the fourth stage, BJtPlI.dll will connect to the C2 server and execute the attacking campaign.

Fig.5 connect to C2 server

 

The C2 server can be accessed until the write-up is finished. Hunting down the IP 188[.]166.28.204, we can collect many attacking samples deployed by the threat actor. It seems that very hot attacking activities, maybe that’s why Szabolcs Schmidt was calling malware analysts, I’m really appreciate it again and I now do not dive deeper into the sample.

Fig.6 C2 server still working and hot attacking activities


Conclusion

From the above analysis, it appears that the malware is the type of Trojan dropper. It is a little bit new to use XML to create a task as a technique, and with multi-stage DLL techniques, it is highly confident that it is a skilled and experienced APT group, a more hidden threat around the digital world; let’s pay close attention.

 

 

IoCs

Files:

Trojan-Dropper Md5 A699AFD908E0DEC5C96FF7188450B89F

Sha256
f18631344d6f7fc57fd248edce37baeb11976e315b72b68d48311c406ace3f8c

 

Dropped by Trojan-Dropper:

dAdyJ6J.Xml md5 621d17a2e9562fb63248edec813fd481

Sha256

1853cc36050f36dc525ab479c77846e976525269066a6cf4bacc4e25eb55d465

 

eHMuMPu.dll md5 3c46ae847e57438d551ad2e5dceaa100

Sha256

107deecec00a31402430a813be00534e4a3cfc4ac5ded872caf4d2c50d117c25

 

BJtPlI.dll md5 056f31e74efa70a140105fdd74cff033

Sha256

6a66672beba2df1babb7801f63f3e171cf09b0807e1f7be86b42617a29eb983b

 

XSei1gC.dll md5 7c88d53706449de3a09dfd1ca60e81cb

Sha256

80c7d43c40872ff4b3a88f6d1dfe57c9facf9544eedfe08e7db7057e953eec9d

 

 

 

Host:

HKCU\Software\Microsoft\CTF\TOZYHhZP7JrXsnrqoh9bsgGED9aA

\SOFTWARE\Conexant\SAII\Controllayer\Si5cETIwNH7RbB7KQWrrV

cmd.exe /c rundll32 %ProgramFiles% (x86)\Common Files\SpeechEngines\GRyLsGsKSP7YyVjekJtym08\eHMuMPu.dll,

A31RU8dofhmCksIVB0GquGp0C8FYekLqp2qvDoSbkisXSjuqUyxv6KG2aaSOGLRUN

schtasks /query /tn qb8iA2pa3SXfu

schtasks /create /tn qb8iA2pa3SXfu /XML %AllUsersProfile%\Start Menu

\6MGmiTas9Ndu41eCYbw\dAdyJ6J.xml /F

%ProgramFiles% (x86)\Common Files\SpeechEngines\CSXW942RQP4MrCBvYGRyLsGsK\HfNUDO.exe

cmd.exe /c rundll32 %AppData%\Media Center Programs\5xHEBJtPlIJ2Ifh\XSei1gC.dll,

A31RU8dofhmCksIVB0GquGp0C8FYekLqp2qvDoSbkisXSjuqUyxv6KG2aaSOGLRUN

rundll32  %AppData%\Media Center Programs\5xHEBJtPlIJ2Ifh\XSei1gC.dll,

A31RU8dofhmCksIVB0GquGp0C8FYekLqp2qvDoSbkisXSjuqUyxv6KG2aaSOGLRUN

schtasks /query /tn qb8iA2pa3SXfu

schtasks /query /tn qb8iA2pa3SXfu /FO LIST /V

HKCU\Software\Microsoft\CTF\TOZYHhZP7JrXsnrqoh9bsgGED9aA

HKCU\Software\Microsoft\Sensors\aFIYzgtmOjU2vEv\XJkYu2C7y3NPUVxpnW5WxGs0ISC

rundll32 %ProgramFiles% (x86)\Common Files\WanNengSoftManager\hI5sEDIwfuuZzva7AiY5A75x\BJtPlI.dll,cmlPc6dI8

cmd.exe /c rd /q /s %ProgramFiles%\Windows Defender

cmd.exe /c rd /q /s %ProgramFiles% (x86)\Windows Defender

cmd.exe /c rd /q /s %AllUsersProfile%\Microsoft\Windows Defender

cmd.exe /c rd /q /s %ProgramFiles%\Windows Defender Advanced Threat Protection

cmd.exe /c rd /q /s %ProgramFiles% (x86)\Windows Defender Advanced Threat Protection

cmd.exe /c del %WinDir%\System32\MRT.exe /q /s /f

cmd.exe /c del %WinDir%\SysWOW64\MRT.exe /q /s /f

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA

HKLM\SOFTWARE\Policies\Microsoft\Microsoft Antimalware\DisableAntiVirus

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\DisableAntiSpyware

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\DisableRoutinelyTakingAction

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\ServiceKeepAlive

HKCU\Software\Microsoft\Windows\CurrentVersion\Action Center\Checks

\{C8E6F269-B90A-4053-A3BE-499AFCEC98C4}.check.0\CheckSetting

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\DisableSpecialRunningModes

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\DisableAntiVirus

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\DisableRealtimeMonitoring

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Signature Updates\ForceUpdateFromMU

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet\DisableBlockAtFirstSeen

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Features\TamperProtection

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Windows Defender Antivirus\Cloud Delivered Protection\DisableCloudProtection

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection\DisableRealtimeMonitoring

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection\DisableBehaviorMonitoring

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection\DisableScanOnRealtimeEnable

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection\DisableOnAccessProtection

HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection\DisableIOAVProtection

HKLM\SOFTWARE\Policies\Microsoft\Windows\System\EnableSmartScreen

%ProgramFiles% (x86)\Common Files\SpeechEngines\GRyLsGsKSP7YyVjekJtym08\eHMuMPu.dll

%ProgramFiles% (x86)\Common Files\SpeechEngines\CSXW942RQP4MrCBvYGRyLsGsK\HfNUDO.exe

%AllUsersProfile%\Microsoft\Windows\Start Menu\6MGmiTas9Ndu41eCYbw\dAdyJ6J.xml

%ProgramFiles% (x86)\Common Files\WanNengSoftManager\hI5sEDIwfuuZzva7AiY5A75x\BJtPlI.dll

 

Network:

TCP 188[.]166.28.204:80

UDP 188[.]166.28.204:137 

End.


──────────────────────
Seeker(李标明) · @clibm079    
China · Independent Malware Analyst & Researcher 

Labels: , , , , ,