$npx -y skills add hypnguyen1209/offensive-claude --skill coding-masteryUse when writing security tooling, exploits, scanners, or C2 in Python/C/Go/Rust/ASM — systems & network programming, automation, cryptography implementation
| 1 | # Coding Mastery |
| 2 | |
| 3 | ## When to Activate |
| 4 | |
| 5 | - Writing exploit code, PoCs, or security tools |
| 6 | - Developing automation scripts for pentesting workflows |
| 7 | - Implementing network protocols or custom C2 |
| 8 | - Building security analysis tools |
| 9 | - Cryptographic implementation or analysis |
| 10 | - Performance-critical systems programming |
| 11 | |
| 12 | ## Languages & Use Cases |
| 13 | |
| 14 | ### Python (Primary — Offensive Tooling) |
| 15 | ```python |
| 16 | # Exploit development with pwntools |
| 17 | from pwn import * |
| 18 | context(arch='amd64', os='linux') |
| 19 | |
| 20 | # Network programming |
| 21 | import socket, ssl, struct |
| 22 | import asyncio, aiohttp # async operations |
| 23 | |
| 24 | # Web exploitation |
| 25 | import requests, urllib3 |
| 26 | from bs4 import BeautifulSoup |
| 27 | |
| 28 | # Crypto |
| 29 | from Crypto.Cipher import AES, DES |
| 30 | from Crypto.PublicKey import RSA |
| 31 | import hashlib, hmac |
| 32 | |
| 33 | # Binary analysis |
| 34 | import struct, ctypes |
| 35 | from capstone import * # disassembly |
| 36 | from unicorn import * # emulation |
| 37 | from keystone import * # assembly |
| 38 | ``` |
| 39 | |
| 40 | ### C/C++ (Systems & Exploit Dev) |
| 41 | ```c |
| 42 | // Shellcode development |
| 43 | // Position-independent code, null-free |
| 44 | // Syscall-based (avoid libc dependency) |
| 45 | |
| 46 | // Kernel module development |
| 47 | #include <linux/module.h> |
| 48 | #include <linux/kernel.h> |
| 49 | |
| 50 | // Windows API abuse |
| 51 | #include <windows.h> |
| 52 | #include <winternl.h> |
| 53 | // Direct syscalls, NTAPI |
| 54 | |
| 55 | // Memory manipulation |
| 56 | // Custom allocators, heap spray, ROP gadget finders |
| 57 | ``` |
| 58 | |
| 59 | ### Go (Offensive Tooling & C2) |
| 60 | ```go |
| 61 | // Implant development (cross-compile, static binary) |
| 62 | // C2 communication (HTTP/DNS/named pipes) |
| 63 | // Network scanning and enumeration |
| 64 | // Proxy/tunnel tools (chisel-like) |
| 65 | |
| 66 | // Advantages: single binary, cross-platform, fast, good crypto stdlib |
| 67 | ``` |
| 68 | |
| 69 | ### Rust (High-Performance Security Tools) |
| 70 | ```rust |
| 71 | // Memory-safe exploit tooling |
| 72 | // High-performance scanners |
| 73 | // Custom protocol implementations |
| 74 | // Fuzzing harnesses |
| 75 | ``` |
| 76 | |
| 77 | ### PowerShell (Windows Post-Exploitation) |
| 78 | ```powershell |
| 79 | # AMSI bypass, ETW patching |
| 80 | # In-memory execution (reflection) |
| 81 | # AD enumeration and exploitation |
| 82 | # Fileless malware techniques |
| 83 | ``` |
| 84 | |
| 85 | ### Assembly (x86/x64/ARM) |
| 86 | ```nasm |
| 87 | ; Shellcode |
| 88 | ; ROP gadgets |
| 89 | ; Anti-debugging |
| 90 | ; Kernel exploitation |
| 91 | ; Architecture-specific tricks |
| 92 | ``` |
| 93 | |
| 94 | ## Design Patterns for Security Tools |
| 95 | |
| 96 | ### Scanner Architecture |
| 97 | ```python |
| 98 | import asyncio |
| 99 | from dataclasses import dataclass |
| 100 | from typing import AsyncIterator |
| 101 | |
| 102 | @dataclass |
| 103 | class Finding: |
| 104 | severity: str |
| 105 | target: str |
| 106 | vulnerability: str |
| 107 | evidence: str |
| 108 | |
| 109 | class Scanner: |
| 110 | def __init__(self, targets: list[str], concurrency: int = 50): |
| 111 | self.targets = targets |
| 112 | self.semaphore = asyncio.Semaphore(concurrency) |
| 113 | |
| 114 | async def scan_target(self, target: str) -> list[Finding]: |
| 115 | async with self.semaphore: |
| 116 | # Implement scan logic |
| 117 | pass |
| 118 | |
| 119 | async def run(self) -> AsyncIterator[Finding]: |
| 120 | tasks = [self.scan_target(t) for t in self.targets] |
| 121 | for coro in asyncio.as_completed(tasks): |
| 122 | findings = await coro |
| 123 | for f in findings: |
| 124 | yield f |
| 125 | ``` |
| 126 | |
| 127 | ### C2 Communication Pattern |
| 128 | ```python |
| 129 | import base64, json, time, random |
| 130 | from cryptography.fernet import Fernet |
| 131 | |
| 132 | class Beacon: |
| 133 | def __init__(self, server: str, key: bytes, jitter: float = 0.3): |
| 134 | self.server = server |
| 135 | self.cipher = Fernet(key) |
| 136 | self.jitter = jitter |
| 137 | self.sleep_time = 60 |
| 138 | |
| 139 | def encrypt(self, data: bytes) -> str: |
| 140 | return base64.b64encode(self.cipher.encrypt(data)).decode() |
| 141 | |
| 142 | def decrypt(self, data: str) -> bytes: |
| 143 | return self.cipher.decrypt(base64.b64decode(data)) |
| 144 | |
| 145 | def sleep(self): |
| 146 | jitter = random.uniform(1 - self.jitter, 1 + self.jitter) |
| 147 | time.sleep(self.sleep_time * jitter) |
| 148 | |
| 149 | def checkin(self) -> dict: |
| 150 | # POST encrypted system info, receive tasking |
| 151 | pass |
| 152 | ``` |
| 153 | |
| 154 | ### Network Protocol Implementation |
| 155 | ```python |
| 156 | import struct |
| 157 | |
| 158 | class ProtocolParser: |
| 159 | def __init__(self, data: bytes): |
| 160 | self.data = data |
| 161 | self.offset = 0 |
| 162 | |
| 163 | def read_u8(self) -> int: |
| 164 | val = struct.unpack_from('B', self.data, self.offset)[0] |
| 165 | self.offset += 1 |
| 166 | return val |
| 167 | |
| 168 | def read_u16(self) -> int: |
| 169 | val = struct.unpack_from('>H', self.data, self.offset)[0] |
| 170 | self.offset += 2 |
| 171 | return val |
| 172 | |
| 173 | def read_u32(self) -> int: |
| 174 | val = struct.unpack_from('>I', self.data, self.offset)[0] |
| 175 | self.offset += 4 |
| 176 | return val |
| 177 | |
| 178 | def read_bytes(self, n: int) -> bytes: |
| 179 | val = self.data[self.offset:self.offset + n] |
| 180 | self.offset += n |
| 181 | return val |
| 182 | |
| 183 | def read_string(self) -> str: |
| 184 | length = self.read_u16() |
| 185 | retur |