-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexplorarweb.sh
More file actions
75 lines (63 loc) · 1.84 KB
/
Copy pathexplorarweb.sh
File metadata and controls
75 lines (63 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# =============================================
# WEB_RESOURCES_SCAN v1.0
# Lista recursos web (Bash 1.x+ compatible)
# =============================================
# Configuración
TMPFILE="/tmp/webscan_$$.html"
# Verificar dependencias
for cmd in wget grep sed; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "ERROR: Falta el comando '$cmd'"
exit 1
fi
done
# Verificar argumentos
if [ $# -lt 1 ]; then
echo "Uso: $0 [URL]"
echo "Ejemplo: $0 http://ejemplo.com"
exit 1
fi
URL="$1"
BASE_URL=$(echo "$URL" | sed 's|^\(https\?://[^/]*\).*|\1|')
# Descargar página principal
echo "Descargando página principal..."
wget -q -O "$TMPFILE" "$URL" || {
echo "ERROR: No se pudo descargar la URL"
exit 1
}
# Extraer y mostrar recursos
echo ""
echo "=== RECURSOS ENCONTRADOS EN: $URL ==="
echo ""
# 1. Recursos JavaScript
echo "Archivos JavaScript (.js):"
grep -i 'src="[^"]*\.js"' "$TMPFILE" |
sed 's/.*src="//;s/".*//' |
awk -v base="$BASE_URL" '{print (index($0,"http") ? "" : base) $0}' |
sort -u | sed 's/^/ /'
echo ""
# 2. Hojas de estilo
echo "Archivos CSS (.css):"
grep -i 'href="[^"]*\.css"' "$TMPFILE" |
sed 's/.*href="//;s/".*//' |
awk -v base="$BASE_URL" '{print (index($0,"http") ? "" : base) $0}' |
sort -u | sed 's/^/ /'
echo ""
# 3. Imágenes
echo "Archivos de imagen:"
grep -i 'src="[^"]*\.\(png\|jpg\|jpeg\|gif\|svg\)"' "$TMPFILE" |
sed 's/.*src="//;s/".*//' |
awk -v base="$BASE_URL" '{print (index($0,"http") ? "" : base) $0}' |
sort -u | sed 's/^/ /'
echo ""
# 4. Recursos externos
echo "Otros recursos externos:"
grep -i 'src="[^"]*"' "$TMPFILE" | grep -v -i '\.\(js\|css\|png\|jpg\|jpeg\|gif\|svg\)"' |
sed 's/.*src="//;s/".*//' |
awk -v base="$BASE_URL" '{print (index($0,"http") ? "" : base) $0}' |
sort -u | sed 's/^/ /'
echo ""
# Limpieza
rm -f "$TMPFILE"
echo "Escaneo completado."