Skip to content

Authorized use only

For the official OSEP labs/exam, or systems you are written-authorized to test. Do not use against unauthorized systems.

Environment and infrastructure ​

Shared attacker-box prep for every module: directories, ports, payload shape, and a triage order when nothing comes back. Each module's prepare step assumes this is already standing.

Environment assumptions ​

RoleSystemNotes
Attacker boxKali Linux (official exam image)All listeners, builds, delivery, and tunneling happen here
Entry targetWindows 10/11 + OfficeDefender present; AppLocker / CLM / AMSI may be enabled
Domain environmentAD DS (child domains, ADCS, MSSQL, IIS possible)Domain Admins, delegation, certificates, SQL service accounts, etc.
Linux targetDomain-joined or standaloneELF execution, shared libraries, sudo, SSH reuse, Kerberos tickets
Network limitsSegmentation + proxies, maybe only a few egress paths allowedDecides whether you go direct, through a proxy, over DNS, or with domain fronting

The techniques in these notes are old, but they get through the exam environment. The exam is not a modern EDR battlefield — don't complicate the chain chasing novelty. Simpler is more reliable, and one failed attempt costs a lot of time.

Attacker-box directories ​

bash
mkdir -p ~/osep/{payloads/{win/{x86,x64},linux,web},listeners,logs,loot,tools}
cd ~/osep
DirectoryWhat goes in it
payloads/win/x86, payloads/win/x64Windows payloads split by architecture (never mix them)
payloads/linuxELF, shared libraries, encoded loaders
payloads/webASPX/JSP/PHP shells, uploaded files
listenersListener scripts, listener command notes
logsOne log file per entry, to confirm callbacks and troubleshoot
lootHashes, tickets, credentials, screenshots
toolsBuild outputs and third-party tools (trusted sources only)

Unified placeholders (use these across the whole project; do not invent your own):

PlaceholderMeaning
LHOSTAttacker-box IP reachable from the target
LPORTListening port
TARGETTarget IP / hostname
DOMAINAD domain name
USER / PASS / NTHASHCredentials
PAYLOADPayload file name
URLOur HTTP(S) address

Ports and listeners ​

Fix one port set so you do not mix them up during the exam:

PortUse
80HTTP delivery (python3 -m http.server / nginx)
443HTTPS delivery (self-signed cert, record the fingerprint)
445SMB delivery (impacket-smbserver / with Responder stopped)
8080Spare HTTP / SOCKS front end
4444General-purpose reverse shell listener
4445Spare listener (second session)
11601Ligolo-ng proxy
5985WinRM (target side)

Start delivery and a listener:

bash
# HTTP delivery + request log (confirm the target really downloaded it)
cd ~/osep/payloads && python3 -m http.server 80 2>&1 | tee ~/osep/logs/http-80.log

# HTTPS delivery
openssl req -newkey rsa:2048 -nodes -keyout ~/osep/tools/key.pem \
  -x509 -days 365 -out ~/osep/tools/cert.pem -subj "/CN=LHOST"
# Note the fingerprint; use it on the target side if the cert must be trusted
openssl x509 -in ~/osep/tools/cert.pem -noout -fingerprint -sha256

# SMB delivery (temporary share, no authentication required)
impacket-smbserver share ~/osep/payloads -smb2support

# Listener with readline (recommended — fewer broken keystrokes in the exam)
rlwrap -cAr nc -lvnp 4444 | tee ~/osep/logs/shell-4444.log

For every entry, prove the callback in this order:

Payload matrix ​

EntryFirst choiceNeeds egressNotes
Word macroVBA in-process Runner / PowerShell stagerDependsProbe bitness first when unknown
HTAHTA + PowerShell / embedded C#DependsPrefer a non-EXE form under AppLocker
JScriptDotNetToJScript + C# stage 2DependsWSH host; AMSI handling must be done separately
Mail ZIPProxy DLL + sideload hostNoKeep the host running normally
Mail / webInstallUtil / Workflow / XSLNoTrusted host, bypasses AppLocker
Web (ASPX)Minimal ASPX + managed loadYesService account; watch AV detection
Web (command injection)Short command + downloader fallbackYesWatch the length limit
LinuxCustom ELF / shared libraryDependsKeep the business output and lifetime

If Office bitness is unknown, probe first — see 01-word-vba-office. If you are still unsure, prepare both architectures and branch.

If stage one gets through but stage two does not, 90% of the time it is a mismatched address, port, or protocol, or a different proxy context — see 09-c2-egress-channels. Every stage must travel the same verified-reachable path.

When the payload is silent ​

No reaction from the payload
├─ no request in the delivery log → delivery blocked / user never opened → change delivery method (HTTP→SMB→mail attachment)
├─ request seen, no execution     → payload killed statically → encode/encrypt/change the host form (module 05)
├─ executed, then exited at once  → bitness mismatch / missing dependency / export mismatch (modules 01, 04)
├─ executed, then terminated      → behavior detection → switch to in-process / cross-process implementation (module 05)
├─ stage one up, stage two not    → communication path / proxy context mismatch (module 09)
└─ session up, then drops quickly → host lifetime problem → migrate / persist (module 01)

Change one variable at a time; after every change, write down what you changed and what the result was.

Build tools (Kali) ​

bash
# Windows cross-compilation (x64 / x86)
sudo apt install -y mingw-w64
x86_64-w64-mingw32-gcc -o payload-x64.exe payload.c -lws2_32 -s -O2
i686-w64-mingw32-gcc   -o payload-x86.exe payload.c -lws2_32 -s -O2

# Shared library / Proxy DLL
x86_64-w64-mingw32-gcc -shared -o proxy.dll proxy.c proxy.def -s
x86_64-w64-mingw32-g++ -shared -o proxy.dll proxy.cpp proxy.def -s

# Linux side
gcc -o loader loader.c -O2
gcc -shared -fPIC -o libpayload.so libpayload.c -O2

Compile .NET assemblies with the csc.exe already present on the target (more reliable in the exam than installing Mono), or pre-compile on your own box with mcs/dotnet and deliver only the assembly.

DocContents
01-word-vba-officeWord/VBA entry, bitness probing, Runner
02-htaHTA entry and AppLocker/CLM/AMSI combinations
05-applocker-clm-amsiAV evasion and trusted hosts
09-c2-egress-channelsEgress channels: proxy, DNS, domain fronting, staging
99-pre-exam-checklistPre-exam item-by-item checklist

Authorized labs and the official exam environment only.