gung12 1.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gung12-1.13.0/LICENSE +21 -0
- gung12-1.13.0/PKG-INFO +190 -0
- gung12-1.13.0/README.md +149 -0
- gung12-1.13.0/gung12/__init__.py +3 -0
- gung12-1.13.0/gung12/__main__.py +4 -0
- gung12-1.13.0/gung12/ai_analyzer.py +104 -0
- gung12-1.13.0/gung12/analyzer.py +485 -0
- gung12-1.13.0/gung12/auth.py +123 -0
- gung12-1.13.0/gung12/cli.py +686 -0
- gung12-1.13.0/gung12/crawler.py +179 -0
- gung12-1.13.0/gung12/engine.py +853 -0
- gung12-1.13.0/gung12/graphql_scanner.py +302 -0
- gung12-1.13.0/gung12/grpc_scanner.py +102 -0
- gung12-1.13.0/gung12/models.py +132 -0
- gung12-1.13.0/gung12/net.py +35 -0
- gung12-1.13.0/gung12/parser.py +128 -0
- gung12-1.13.0/gung12/payloads/__init__.py +29 -0
- gung12-1.13.0/gung12/payloads/cmdi.py +78 -0
- gung12-1.13.0/gung12/payloads/csrf.py +29 -0
- gung12-1.13.0/gung12/payloads/file_upload.py +36 -0
- gung12-1.13.0/gung12/payloads/htmli.py +34 -0
- gung12-1.13.0/gung12/payloads/loader.py +27 -0
- gung12-1.13.0/gung12/payloads/logic.py +40 -0
- gung12-1.13.0/gung12/payloads/nosql.py +46 -0
- gung12-1.13.0/gung12/payloads/open_redirect.py +35 -0
- gung12-1.13.0/gung12/payloads/sqli.py +95 -0
- gung12-1.13.0/gung12/payloads/ssti.py +48 -0
- gung12-1.13.0/gung12/payloads/xpath.py +40 -0
- gung12-1.13.0/gung12/payloads/xss.py +51 -0
- gung12-1.13.0/gung12/payloads/xxe.py +34 -0
- gung12-1.13.0/gung12/reporter.py +658 -0
- gung12-1.13.0/gung12/spa_parser.py +326 -0
- gung12-1.13.0/gung12/waf_bypass.py +57 -0
- gung12-1.13.0/gung12/webui.py +187 -0
- gung12-1.13.0/gung12/ws_scanner.py +261 -0
- gung12-1.13.0/gung12.egg-info/PKG-INFO +190 -0
- gung12-1.13.0/gung12.egg-info/SOURCES.txt +52 -0
- gung12-1.13.0/gung12.egg-info/dependency_links.txt +1 -0
- gung12-1.13.0/gung12.egg-info/entry_points.txt +2 -0
- gung12-1.13.0/gung12.egg-info/requires.txt +20 -0
- gung12-1.13.0/gung12.egg-info/top_level.txt +1 -0
- gung12-1.13.0/pyproject.toml +55 -0
- gung12-1.13.0/setup.cfg +4 -0
- gung12-1.13.0/tests/test_cmdi_time.py +42 -0
- gung12-1.13.0/tests/test_concurrency.py +49 -0
- gung12-1.13.0/tests/test_crawler.py +19 -0
- gung12-1.13.0/tests/test_depth.py +56 -0
- gung12-1.13.0/tests/test_false_positives.py +43 -0
- gung12-1.13.0/tests/test_form_scanners.py +55 -0
- gung12-1.13.0/tests/test_graphql.py +24 -0
- gung12-1.13.0/tests/test_grpc.py +18 -0
- gung12-1.13.0/tests/test_robustness.py +98 -0
- gung12-1.13.0/tests/test_spa_detection.py +36 -0
- gung12-1.13.0/tests/test_websocket.py +27 -0
gung12-1.13.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Den Reanin Gerasimov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gung12-1.13.0/PKG-INFO
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gung12
|
|
3
|
+
Version: 1.13.0
|
|
4
|
+
Summary: DAST especializado en detección de vulnerabilidades en formularios web (12 categorías)
|
|
5
|
+
Author: Den Reanin Gerasimov
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/DenReanin/gung12
|
|
8
|
+
Project-URL: Repository, https://github.com/DenReanin/gung12
|
|
9
|
+
Project-URL: Issues, https://github.com/DenReanin/gung12/issues
|
|
10
|
+
Keywords: security,dast,owasp,vulnerability-scanner,web-security,formularios
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: requests>=2.31.0
|
|
25
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
26
|
+
Requires-Dist: click>=8.1.0
|
|
27
|
+
Requires-Dist: colorama>=0.4.6
|
|
28
|
+
Provides-Extra: spa
|
|
29
|
+
Requires-Dist: playwright>=1.40.0; extra == "spa"
|
|
30
|
+
Provides-Extra: dashboard
|
|
31
|
+
Requires-Dist: flask>=2.0; extra == "dashboard"
|
|
32
|
+
Provides-Extra: grpc
|
|
33
|
+
Requires-Dist: grpcio>=1.40; extra == "grpc"
|
|
34
|
+
Requires-Dist: grpcio-reflection>=1.40; extra == "grpc"
|
|
35
|
+
Provides-Extra: test
|
|
36
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
37
|
+
Requires-Dist: flask>=2.0; extra == "test"
|
|
38
|
+
Requires-Dist: grpcio>=1.40; extra == "test"
|
|
39
|
+
Requires-Dist: grpcio-reflection>=1.40; extra == "test"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# Gung12
|
|
43
|
+
|
|
44
|
+
[](https://github.com/DenReanin/gung12/releases)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+
[](https://www.python.org/)
|
|
47
|
+
|
|
48
|
+
DAST (Dynamic Application Security Testing) especializado en la detección de vulnerabilidades en **formularios web**. Cubre 12 categorías alineadas con el OWASP Top 10 con un enfoque dirigido y pensado para integración en flujos de CI/CD.
|
|
49
|
+
|
|
50
|
+
## Características
|
|
51
|
+
|
|
52
|
+
- 12 categorías de vulnerabilidad: XSS, SQLi, SSTI, XPath, CMDi, NoSQL, XXE, CSRF, File Upload, Open Redirect, HTML Injection, Logic
|
|
53
|
+
- SQLi ciega **booleana y basada en tiempo** por análisis diferencial confirmado (modo exhaustivo `-F`) y XSS almacenado (`--stored-xss`)
|
|
54
|
+
- Confirmación semántica de Command Injection por marcador único y, en modo exhaustivo (`-F`), **ciega basada en tiempo con petición de control** (descarta falsos positivos en páginas con baseline lento); NoSQL por operadores de bypass (diferencial)
|
|
55
|
+
- Rastreo automático de formularios en el sitio (`--crawl`) con control de profundidad, `robots.txt` y deduplicación
|
|
56
|
+
- Escaneo concurrente: barrido de inyección en paralelo por formulario (`-j/--concurrency`) y análisis de varios formularios a la vez en modo rastreo (`--crawl-workers`); las pasadas por tiempo/diferencial se mantienen secuenciales para no falsear las medidas
|
|
57
|
+
- Wordlists externas estilo SecLists (`--payloads-dir`) que amplían los payloads integrados
|
|
58
|
+
- Modo GraphQL (`--graphql`): introspección, fuga por sugerencias e inyección SQL en argumentos (error-based y diferencial)
|
|
59
|
+
- Modo WebSocket (`--websocket`): batería de inyección en mensajes (XSS, SQLi, SSTI, XPath, CMDi, NoSQL, XXE, HTML) con cliente WS propio (RFC 6455)
|
|
60
|
+
- Modo gRPC (`--grpc`): detección de server reflection habilitada
|
|
61
|
+
- Dashboard web opcional (`--serve`): interfaz local para lanzar escaneos y ver el informe
|
|
62
|
+
- Soporte para SPAs (Angular/React/Vue): **detección automática** y render con Playwright (dependencia opcional, `pip install "gung12[spa]"`), más descubrimiento automático de endpoints REST
|
|
63
|
+
- Análisis con IA (Gemini, Groq) como segunda opinión sobre los hallazgos
|
|
64
|
+
- Autenticación previa automática (`--login-url`)
|
|
65
|
+
- Evasión de WAFs basados en firmas (`--waf-bypass`)
|
|
66
|
+
- Refresco dinámico del token anti-CSRF (`--refresh-csrf`) para frameworks que lo rotan (Django, Laravel, ASP.NET)
|
|
67
|
+
- Filtro automático de falsos positivos por reflexión total (respeta la evidencia semántica: no degrada SSTI evaluado, errores SQL, etc.)
|
|
68
|
+
- Las pasadas de evidencia fuerte (ciega, tiempo, diferencial, marcador CMDi) confirman y reemplazan detecciones débiles en el mismo campo
|
|
69
|
+
- Bajo índice de falsos positivos: la SQLi/XPath booleana exige confirmación diferencial con control (no basta un cambio de tamaño) y el Open Redirect se confirma verificando que la cabecera `Location` apunte al host externo inyectado (validado contra la app segura Flaskr: solo reporta el fallo real)
|
|
70
|
+
- Robustez de red: reintentos ante fallos transitorios de conexión y límite de tamaño de respuesta y de frame WebSocket
|
|
71
|
+
- Informes HTML y JSON con coloreado por severidad (informe combinado en modo rastreo)
|
|
72
|
+
|
|
73
|
+
## Instalación
|
|
74
|
+
|
|
75
|
+
### Desde código fuente
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/DenReanin/gung12
|
|
79
|
+
cd gung12
|
|
80
|
+
pip install -r requirements.txt # instalación base (ligera)
|
|
81
|
+
python -m gung12 --help
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
La instalación base son solo 4 dependencias pequeñas. Los modos opcionales se
|
|
85
|
+
instalan a la carta:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install "gung12[spa]" # render de SPAs (Playwright)
|
|
89
|
+
pip install "gung12[dashboard]" # dashboard web (Flask)
|
|
90
|
+
pip install "gung12[grpc]" # modo gRPC (grpcio-reflection)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
> **Nota (SPA):** Gung12 **detecta automáticamente** si una página es una SPA y,
|
|
94
|
+
> si el modo SPA está instalado, la renderiza con el Chromium de Playwright (lo
|
|
95
|
+
> **descarga solo la primera vez**, ~280 MB, en la caché del usuario). Puedes
|
|
96
|
+
> forzar el render con `--spa` o desactivarlo con `--no-spa`. Si la descarga
|
|
97
|
+
> automática falla (sin conexión o tras un proxy), ejecuta `playwright install chromium`.
|
|
98
|
+
|
|
99
|
+
### Ejecutable
|
|
100
|
+
|
|
101
|
+
Descargar desde [Releases](https://github.com/DenReanin/gung12/releases) el binario para tu plataforma (Windows, Linux o macOS) y ejecutarlo directamente. No requiere Python instalado.
|
|
102
|
+
|
|
103
|
+
El binario incluye Playwright. La primera vez que se utilice `--spa`, Playwright descargará Chromium en la caché del usuario (~280 MB).
|
|
104
|
+
|
|
105
|
+
## Uso básico
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Escaneo rápido con XSS y SQLi
|
|
109
|
+
gung12 -u "http://target/form" -T xss,sqli
|
|
110
|
+
|
|
111
|
+
# Escaneo completo con login previo
|
|
112
|
+
gung12 -u "http://target/admin/profile" \
|
|
113
|
+
--login-url "http://target/login" \
|
|
114
|
+
--login-user "admin" --login-pass "secret" \
|
|
115
|
+
-T all -F -o report.html
|
|
116
|
+
|
|
117
|
+
# Modo SPA contra OWASP Juice Shop (Angular)
|
|
118
|
+
gung12 -u "http://localhost:3000/#/login" --spa -T sqli,nosql
|
|
119
|
+
|
|
120
|
+
# Rastreo automático: descubre y analiza todos los formularios del sitio
|
|
121
|
+
gung12 -u "http://target/" --crawl --crawl-depth 2 --max-forms 20 -T all -o crawl.html
|
|
122
|
+
|
|
123
|
+
# Escaneo concurrente: 8 peticiones de inyección en paralelo por formulario
|
|
124
|
+
gung12 -u "http://target/form" -T all -j 8
|
|
125
|
+
|
|
126
|
+
# Rastreo con 4 formularios analizados a la vez
|
|
127
|
+
gung12 -u "http://target/" --crawl --crawl-workers 4 -T all -o crawl.html
|
|
128
|
+
|
|
129
|
+
# Refresco de token CSRF en cada payload (Django, Laravel, ASP.NET MVC)
|
|
130
|
+
gung12 -u "http://target/profile" --refresh-csrf -T xss,sqli
|
|
131
|
+
|
|
132
|
+
# SQLi ciega booleana (análisis diferencial, requiere modo exhaustivo -F)
|
|
133
|
+
gung12 -u "http://target/status?id=1" -T sqli -F
|
|
134
|
+
|
|
135
|
+
# XSS almacenado: inyecta un canario y comprueba si persiste en otra página
|
|
136
|
+
gung12 -u "http://target/comment" --stored-xss --stored-url "http://target/wall" -T xss
|
|
137
|
+
|
|
138
|
+
# Wordlists externas (SecLists): archivos <tipo>.txt (xss.txt, sqli.txt...)
|
|
139
|
+
gung12 -u "http://target/form" -T sqli,xss --payloads-dir ./SecLists/gung12
|
|
140
|
+
|
|
141
|
+
# Modo GraphQL: introspección, fuga por sugerencias e inyección en argumentos
|
|
142
|
+
gung12 -u "http://target/graphql" --graphql -o graphql.html
|
|
143
|
+
|
|
144
|
+
# Modo WebSocket: inyección de payloads en mensajes
|
|
145
|
+
gung12 -u "ws://target:8080/chat" --websocket
|
|
146
|
+
|
|
147
|
+
# Modo gRPC: server reflection habilitada (pip install "gung12[grpc]")
|
|
148
|
+
gung12 -u "target:50051" --grpc
|
|
149
|
+
|
|
150
|
+
# Dashboard web (requiere Flask: pip install "gung12[dashboard]")
|
|
151
|
+
gung12 --serve # abre http://127.0.0.1:8012
|
|
152
|
+
|
|
153
|
+
# CI/CD: salida silenciosa con exit code útil
|
|
154
|
+
gung12 -u "$TARGET" -T all --quiet -o report.json
|
|
155
|
+
# exit 0 = sin hallazgos relevantes, 1 = ALTA/MEDIA, 2 = error
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Tests
|
|
159
|
+
|
|
160
|
+
La suite de pruebas levanta objetivos vulnerables locales (formularios, GraphQL,
|
|
161
|
+
WebSocket y gRPC) y verifica todos los escáneres de extremo a extremo:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pip install "gung12[test]"
|
|
165
|
+
pytest
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Modos de salida
|
|
169
|
+
|
|
170
|
+
| Modo | Flag | Uso recomendado |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| Por defecto | (ninguno) | Defensa, demos, ejecuciones manuales |
|
|
173
|
+
| Silencioso | `-q` / `--quiet` | Pipelines CI/CD (solo hallazgos) |
|
|
174
|
+
| Verboso | `-v` / `--verbose` | Debugging y pentesting (muestra payloads) |
|
|
175
|
+
|
|
176
|
+
## Códigos de retorno (CI/CD)
|
|
177
|
+
|
|
178
|
+
| Código | Significado |
|
|
179
|
+
|---|---|
|
|
180
|
+
| 0 | Sin hallazgos o solo de severidad BAJA |
|
|
181
|
+
| 1 | Hallazgos de severidad ALTA o MEDIA |
|
|
182
|
+
| 2 | Error de ejecución (URL inaccesible, argumentos inválidos) |
|
|
183
|
+
|
|
184
|
+
## Aviso legal
|
|
185
|
+
|
|
186
|
+
Esta herramienta está diseñada para **uso autorizado únicamente** sobre sistemas propios o con permiso explícito por escrito del propietario. El uso contra sistemas no autorizados constituye un delito tipificado en el artículo 197 bis del Código Penal español y en la normativa europea sobre ciberseguridad.
|
|
187
|
+
|
|
188
|
+
## Licencia
|
|
189
|
+
|
|
190
|
+
MIT. Proyecto académico desarrollado como Trabajo Fin de Máster en el Máster Universitario en Ciberseguridad de la Universidad de Alicante.
|
gung12-1.13.0/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Gung12
|
|
2
|
+
|
|
3
|
+
[](https://github.com/DenReanin/gung12/releases)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.python.org/)
|
|
6
|
+
|
|
7
|
+
DAST (Dynamic Application Security Testing) especializado en la detección de vulnerabilidades en **formularios web**. Cubre 12 categorías alineadas con el OWASP Top 10 con un enfoque dirigido y pensado para integración en flujos de CI/CD.
|
|
8
|
+
|
|
9
|
+
## Características
|
|
10
|
+
|
|
11
|
+
- 12 categorías de vulnerabilidad: XSS, SQLi, SSTI, XPath, CMDi, NoSQL, XXE, CSRF, File Upload, Open Redirect, HTML Injection, Logic
|
|
12
|
+
- SQLi ciega **booleana y basada en tiempo** por análisis diferencial confirmado (modo exhaustivo `-F`) y XSS almacenado (`--stored-xss`)
|
|
13
|
+
- Confirmación semántica de Command Injection por marcador único y, en modo exhaustivo (`-F`), **ciega basada en tiempo con petición de control** (descarta falsos positivos en páginas con baseline lento); NoSQL por operadores de bypass (diferencial)
|
|
14
|
+
- Rastreo automático de formularios en el sitio (`--crawl`) con control de profundidad, `robots.txt` y deduplicación
|
|
15
|
+
- Escaneo concurrente: barrido de inyección en paralelo por formulario (`-j/--concurrency`) y análisis de varios formularios a la vez en modo rastreo (`--crawl-workers`); las pasadas por tiempo/diferencial se mantienen secuenciales para no falsear las medidas
|
|
16
|
+
- Wordlists externas estilo SecLists (`--payloads-dir`) que amplían los payloads integrados
|
|
17
|
+
- Modo GraphQL (`--graphql`): introspección, fuga por sugerencias e inyección SQL en argumentos (error-based y diferencial)
|
|
18
|
+
- Modo WebSocket (`--websocket`): batería de inyección en mensajes (XSS, SQLi, SSTI, XPath, CMDi, NoSQL, XXE, HTML) con cliente WS propio (RFC 6455)
|
|
19
|
+
- Modo gRPC (`--grpc`): detección de server reflection habilitada
|
|
20
|
+
- Dashboard web opcional (`--serve`): interfaz local para lanzar escaneos y ver el informe
|
|
21
|
+
- Soporte para SPAs (Angular/React/Vue): **detección automática** y render con Playwright (dependencia opcional, `pip install "gung12[spa]"`), más descubrimiento automático de endpoints REST
|
|
22
|
+
- Análisis con IA (Gemini, Groq) como segunda opinión sobre los hallazgos
|
|
23
|
+
- Autenticación previa automática (`--login-url`)
|
|
24
|
+
- Evasión de WAFs basados en firmas (`--waf-bypass`)
|
|
25
|
+
- Refresco dinámico del token anti-CSRF (`--refresh-csrf`) para frameworks que lo rotan (Django, Laravel, ASP.NET)
|
|
26
|
+
- Filtro automático de falsos positivos por reflexión total (respeta la evidencia semántica: no degrada SSTI evaluado, errores SQL, etc.)
|
|
27
|
+
- Las pasadas de evidencia fuerte (ciega, tiempo, diferencial, marcador CMDi) confirman y reemplazan detecciones débiles en el mismo campo
|
|
28
|
+
- Bajo índice de falsos positivos: la SQLi/XPath booleana exige confirmación diferencial con control (no basta un cambio de tamaño) y el Open Redirect se confirma verificando que la cabecera `Location` apunte al host externo inyectado (validado contra la app segura Flaskr: solo reporta el fallo real)
|
|
29
|
+
- Robustez de red: reintentos ante fallos transitorios de conexión y límite de tamaño de respuesta y de frame WebSocket
|
|
30
|
+
- Informes HTML y JSON con coloreado por severidad (informe combinado en modo rastreo)
|
|
31
|
+
|
|
32
|
+
## Instalación
|
|
33
|
+
|
|
34
|
+
### Desde código fuente
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/DenReanin/gung12
|
|
38
|
+
cd gung12
|
|
39
|
+
pip install -r requirements.txt # instalación base (ligera)
|
|
40
|
+
python -m gung12 --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
La instalación base son solo 4 dependencias pequeñas. Los modos opcionales se
|
|
44
|
+
instalan a la carta:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install "gung12[spa]" # render de SPAs (Playwright)
|
|
48
|
+
pip install "gung12[dashboard]" # dashboard web (Flask)
|
|
49
|
+
pip install "gung12[grpc]" # modo gRPC (grpcio-reflection)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> **Nota (SPA):** Gung12 **detecta automáticamente** si una página es una SPA y,
|
|
53
|
+
> si el modo SPA está instalado, la renderiza con el Chromium de Playwright (lo
|
|
54
|
+
> **descarga solo la primera vez**, ~280 MB, en la caché del usuario). Puedes
|
|
55
|
+
> forzar el render con `--spa` o desactivarlo con `--no-spa`. Si la descarga
|
|
56
|
+
> automática falla (sin conexión o tras un proxy), ejecuta `playwright install chromium`.
|
|
57
|
+
|
|
58
|
+
### Ejecutable
|
|
59
|
+
|
|
60
|
+
Descargar desde [Releases](https://github.com/DenReanin/gung12/releases) el binario para tu plataforma (Windows, Linux o macOS) y ejecutarlo directamente. No requiere Python instalado.
|
|
61
|
+
|
|
62
|
+
El binario incluye Playwright. La primera vez que se utilice `--spa`, Playwright descargará Chromium en la caché del usuario (~280 MB).
|
|
63
|
+
|
|
64
|
+
## Uso básico
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Escaneo rápido con XSS y SQLi
|
|
68
|
+
gung12 -u "http://target/form" -T xss,sqli
|
|
69
|
+
|
|
70
|
+
# Escaneo completo con login previo
|
|
71
|
+
gung12 -u "http://target/admin/profile" \
|
|
72
|
+
--login-url "http://target/login" \
|
|
73
|
+
--login-user "admin" --login-pass "secret" \
|
|
74
|
+
-T all -F -o report.html
|
|
75
|
+
|
|
76
|
+
# Modo SPA contra OWASP Juice Shop (Angular)
|
|
77
|
+
gung12 -u "http://localhost:3000/#/login" --spa -T sqli,nosql
|
|
78
|
+
|
|
79
|
+
# Rastreo automático: descubre y analiza todos los formularios del sitio
|
|
80
|
+
gung12 -u "http://target/" --crawl --crawl-depth 2 --max-forms 20 -T all -o crawl.html
|
|
81
|
+
|
|
82
|
+
# Escaneo concurrente: 8 peticiones de inyección en paralelo por formulario
|
|
83
|
+
gung12 -u "http://target/form" -T all -j 8
|
|
84
|
+
|
|
85
|
+
# Rastreo con 4 formularios analizados a la vez
|
|
86
|
+
gung12 -u "http://target/" --crawl --crawl-workers 4 -T all -o crawl.html
|
|
87
|
+
|
|
88
|
+
# Refresco de token CSRF en cada payload (Django, Laravel, ASP.NET MVC)
|
|
89
|
+
gung12 -u "http://target/profile" --refresh-csrf -T xss,sqli
|
|
90
|
+
|
|
91
|
+
# SQLi ciega booleana (análisis diferencial, requiere modo exhaustivo -F)
|
|
92
|
+
gung12 -u "http://target/status?id=1" -T sqli -F
|
|
93
|
+
|
|
94
|
+
# XSS almacenado: inyecta un canario y comprueba si persiste en otra página
|
|
95
|
+
gung12 -u "http://target/comment" --stored-xss --stored-url "http://target/wall" -T xss
|
|
96
|
+
|
|
97
|
+
# Wordlists externas (SecLists): archivos <tipo>.txt (xss.txt, sqli.txt...)
|
|
98
|
+
gung12 -u "http://target/form" -T sqli,xss --payloads-dir ./SecLists/gung12
|
|
99
|
+
|
|
100
|
+
# Modo GraphQL: introspección, fuga por sugerencias e inyección en argumentos
|
|
101
|
+
gung12 -u "http://target/graphql" --graphql -o graphql.html
|
|
102
|
+
|
|
103
|
+
# Modo WebSocket: inyección de payloads en mensajes
|
|
104
|
+
gung12 -u "ws://target:8080/chat" --websocket
|
|
105
|
+
|
|
106
|
+
# Modo gRPC: server reflection habilitada (pip install "gung12[grpc]")
|
|
107
|
+
gung12 -u "target:50051" --grpc
|
|
108
|
+
|
|
109
|
+
# Dashboard web (requiere Flask: pip install "gung12[dashboard]")
|
|
110
|
+
gung12 --serve # abre http://127.0.0.1:8012
|
|
111
|
+
|
|
112
|
+
# CI/CD: salida silenciosa con exit code útil
|
|
113
|
+
gung12 -u "$TARGET" -T all --quiet -o report.json
|
|
114
|
+
# exit 0 = sin hallazgos relevantes, 1 = ALTA/MEDIA, 2 = error
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Tests
|
|
118
|
+
|
|
119
|
+
La suite de pruebas levanta objetivos vulnerables locales (formularios, GraphQL,
|
|
120
|
+
WebSocket y gRPC) y verifica todos los escáneres de extremo a extremo:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pip install "gung12[test]"
|
|
124
|
+
pytest
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Modos de salida
|
|
128
|
+
|
|
129
|
+
| Modo | Flag | Uso recomendado |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| Por defecto | (ninguno) | Defensa, demos, ejecuciones manuales |
|
|
132
|
+
| Silencioso | `-q` / `--quiet` | Pipelines CI/CD (solo hallazgos) |
|
|
133
|
+
| Verboso | `-v` / `--verbose` | Debugging y pentesting (muestra payloads) |
|
|
134
|
+
|
|
135
|
+
## Códigos de retorno (CI/CD)
|
|
136
|
+
|
|
137
|
+
| Código | Significado |
|
|
138
|
+
|---|---|
|
|
139
|
+
| 0 | Sin hallazgos o solo de severidad BAJA |
|
|
140
|
+
| 1 | Hallazgos de severidad ALTA o MEDIA |
|
|
141
|
+
| 2 | Error de ejecución (URL inaccesible, argumentos inválidos) |
|
|
142
|
+
|
|
143
|
+
## Aviso legal
|
|
144
|
+
|
|
145
|
+
Esta herramienta está diseñada para **uso autorizado únicamente** sobre sistemas propios o con permiso explícito por escrito del propietario. El uso contra sistemas no autorizados constituye un delito tipificado en el artículo 197 bis del Código Penal español y en la normativa europea sobre ciberseguridad.
|
|
146
|
+
|
|
147
|
+
## Licencia
|
|
148
|
+
|
|
149
|
+
MIT. Proyecto académico desarrollado como Trabajo Fin de Máster en el Máster Universitario en Ciberseguridad de la Universidad de Alicante.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
import json
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from gung12.models import ScanResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AIAnalyzer:
|
|
10
|
+
|
|
11
|
+
def __init__(self, provider: str = "gemini", api_key: Optional[str] = None):
|
|
12
|
+
self.provider = provider.lower()
|
|
13
|
+
self.api_key = api_key or self._get_api_key()
|
|
14
|
+
|
|
15
|
+
if not self.api_key:
|
|
16
|
+
raise ValueError(
|
|
17
|
+
f"API key no proporcionada para '{provider}'. "
|
|
18
|
+
f"Usa --ai-key o la variable de entorno correspondiente: "
|
|
19
|
+
f"GEMINI_API_KEY, GROQ_API_KEY"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def _get_api_key(self) -> Optional[str]:
|
|
23
|
+
env_vars = {
|
|
24
|
+
"gemini": "GEMINI_API_KEY",
|
|
25
|
+
"groq": "GROQ_API_KEY",
|
|
26
|
+
}
|
|
27
|
+
var_name = env_vars.get(self.provider, "")
|
|
28
|
+
return os.environ.get(var_name)
|
|
29
|
+
|
|
30
|
+
def analyze_results(self, scan_result: ScanResult) -> str:
|
|
31
|
+
prompt = self._build_prompt(scan_result)
|
|
32
|
+
|
|
33
|
+
if self.provider == "gemini":
|
|
34
|
+
return self._call_gemini(prompt)
|
|
35
|
+
elif self.provider == "groq":
|
|
36
|
+
return self._call_groq(prompt)
|
|
37
|
+
else:
|
|
38
|
+
raise ValueError(f"Proveedor no soportado: {self.provider}. Usa 'gemini' o 'groq'.")
|
|
39
|
+
|
|
40
|
+
def _build_prompt(self, result: ScanResult) -> str:
|
|
41
|
+
vulns_summary = []
|
|
42
|
+
for v in result.vulnerabilities:
|
|
43
|
+
vulns_summary.append({
|
|
44
|
+
"tipo": v.vuln_type.value,
|
|
45
|
+
"campo": v.field_name,
|
|
46
|
+
"payload": v.payload[:100],
|
|
47
|
+
"evidencia": v.evidence[:200],
|
|
48
|
+
"confianza": f"{v.confidence:.0%}",
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return f"""Eres un experto en ciberseguridad web. Analiza estos resultados de un escaneo
|
|
52
|
+
de vulnerabilidades en un formulario web y proporciona:
|
|
53
|
+
|
|
54
|
+
1. VALIDACIÓN: ¿Cuáles de estas detecciones son probablemente verdaderos positivos
|
|
55
|
+
y cuáles podrían ser falsos positivos? Justifica brevemente.
|
|
56
|
+
2. RIESGO: Evalúa el riesgo global del formulario analizado.
|
|
57
|
+
3. RECOMENDACIONES: Lista 3-5 recomendaciones de mitigación priorizadas.
|
|
58
|
+
|
|
59
|
+
URL analizada: {result.url}
|
|
60
|
+
Método: {result.form.method}
|
|
61
|
+
Campos: {', '.join(f.name for f in result.form.fields)}
|
|
62
|
+
Modo de escaneo: {result.scan_mode}
|
|
63
|
+
|
|
64
|
+
Vulnerabilidades detectadas ({len(result.vulnerabilities)}):
|
|
65
|
+
{json.dumps(vulns_summary, indent=2, ensure_ascii=False)}
|
|
66
|
+
|
|
67
|
+
Responde en español, de forma concisa y técnica. Máximo 500 palabras."""
|
|
68
|
+
|
|
69
|
+
def _call_gemini(self, prompt: str) -> str:
|
|
70
|
+
import requests
|
|
71
|
+
|
|
72
|
+
response = requests.post(
|
|
73
|
+
f"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-lite:generateContent?key={self.api_key}",
|
|
74
|
+
headers={"Content-Type": "application/json"},
|
|
75
|
+
json={"contents": [{"parts": [{"text": prompt}]}]},
|
|
76
|
+
timeout=30,
|
|
77
|
+
)
|
|
78
|
+
response.raise_for_status()
|
|
79
|
+
data = response.json()
|
|
80
|
+
return data["candidates"][0]["content"]["parts"][0]["text"]
|
|
81
|
+
|
|
82
|
+
def _call_groq(self, prompt: str) -> str:
|
|
83
|
+
import requests
|
|
84
|
+
|
|
85
|
+
response = requests.post(
|
|
86
|
+
"https://api.groq.com/openai/v1/chat/completions",
|
|
87
|
+
headers={
|
|
88
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
},
|
|
91
|
+
json={
|
|
92
|
+
"model": "llama-3.1-8b-instant",
|
|
93
|
+
"messages": [
|
|
94
|
+
{"role": "system", "content": "Eres un experto en ciberseguridad web."},
|
|
95
|
+
{"role": "user", "content": prompt},
|
|
96
|
+
],
|
|
97
|
+
"max_tokens": 1024,
|
|
98
|
+
"temperature": 0.3,
|
|
99
|
+
},
|
|
100
|
+
timeout=30,
|
|
101
|
+
)
|
|
102
|
+
response.raise_for_status()
|
|
103
|
+
data = response.json()
|
|
104
|
+
return data["choices"][0]["message"]["content"]
|