Malware Analysis

My attempt at blogging about my experiences in malware analysis

back

Dissecting an AutoIT Malware Sample

This post outlines a systematic breakdown of a malware sample developed using AutoIT, highlighting techniques used for unpacking and analysis.

execution_flow

Stage 1: De-obfuscating the Batch Script

The initial stage of the infection chain involves a heavily obfuscated batch script. The de-obfuscation process included:

Obfuscated Script:

batch_obfuscated

De-obfuscated Script:

batch_deobfuscated

Observations:

Stage 2: Analyzing the Obfuscated AutoIT Script

Pre-Deobfuscation View:

autoit_script1

The script includes multiple calls to a function labeled Spyware

String De-obfuscation Logic:

autoit_script2

The function takes an encoded string and splits it using % as a delimiter. Each segment is adjusted based on a key and then converted into corresponding Unicode characters.

Resulting Output:

autoit_script3

The decoded strings in this instance appear to be junk or placeholders, suggesting the use of decoy or filler code.

Stage 3: Embedded Binary Extraction

An embedded binary blob is found assigned to a variable (pNseF) within the script: binary_blob

This blob is passed to a custom function named Nickpot. nickpot

Stage 4: Investigating the Nickpot Function

Within Nickpot, another binary blob labeled ConnectionsEquality appears. Its value changes based on whether a 32-bit or 64-bit environment is detected. The focus here is on the 64-bit version: binary_blob2

Decompilation reveals that ConnectionsEquality implements a form of custom encryption or decryption routine:

decryption_stub

Tracing Usage:

setstruct_1

dllcalladdress1

dllstructcreate1

dllstructsetdata1

binlen1

To conclude, the function ConnectionsEquality sets the data of QualifiedRefugeesCattle depending on the value of DETAILWITNESS.

Tracking the Usage of QualifiedRefugeesCattle

dllcalladdress2

dllstructsetdata2

binlen2

The decrypted structure, QualifiedRefugeesCattle, is subsequently used as the first argument in another call to DllCallAddress. This time, the function receives two additional arguments:

In this step, DETAILWITNESS2 is updated or transformed based on the decrypted data from QualifiedRefugeesCattle. This suggests a two-step decryption or decoding routine, possibly for layered obfuscation or added evasion.

Final Return From Nickpot

The function MarcoCindy is invoked at the end of Nickpot, serving a simple role: it returns the contents of DETAILWITNESS2 as a fully populated data structure.

return

Final Stage: Decompression via FishVerzeichnisBobby

func

dllstructsetdata3

dllcall

The returned data (now referred to as SquirtingNcaaTnAj) is passed into the function FishVerzeichnisBobby, which prepares the buffer for decompression.

Within this function:

According to Microsoft’s MSDN documentation, RtlDecompressFragment decompresses a portion of an input buffer into a destination buffer.

Final Payload Extraction

The result of the decompression is stored in a buffer named transmissionsetpromptlylab. By dumping the contents of this variable, we recover a valid Portable Executable (PE) file:

Conclusion

This AutoIT-based malware employs a multi-layered obfuscation and unpacking technique:

  1. Obfuscated Batch Loader – Prepares the environment and drops the AutoIT payload.
  2. AutoIT Script – Implements custom string decryption, binary merging, and memory-based loading.
  3. Custom Decryption Routine (Nickpot) – Decrypts an embedded blob using shellcode-style logic.
  4. Final Decompression via Native API – Extracts the final PE using RtlDecompressFragment.

By reversing these layers, we uncover a known infostealer embedded deeply within custom logic to evade traditional detection methods.