Publicado el 30/03/2023 12:03:00 en Hacking Tools.
Author: p0mb3r0 | Total de votos: 7 Vote
Analisis de Archivos automatizados
Calculos de hash MD5, SHA1, Analisis de cabeceras de archivos, Analisis de metadatos utilizando exiftool, presentados en un Html.
#!/bin/bash # Pregunta por la ruta a analizar read -p "Introduce la ruta a analizar: " folder # Crea el archivo HTML html_file="$(date +'%Y-%m-%d_%H-%M-%S')_resultado.html" touch "$html_file" # Escribe la cabecera HTML en el archivo echo "<html><head><title>Análisis de Datos DFIR</title> <style> body { background-color: #f2f2f2; color: #333; font-family: Arial, sans-serif; } h1 { text-align: center; font-size: 2.5rem; color: #006699; margin-top: 1.5rem; margin-bottom: 1rem; } h2 { font-size: 1.5rem; margin-top: 2rem; color: #333; } table { border-collapse: collapse; width: 100%; margin-top: 1rem; } th, td { text-align: left; padding: 0.5rem; border: 1px solid #ddd; } th { background-color: #006699; color: #fff; } </style> </head><body>" >> "$html_file" # Iterar sobre los archivos de la carpeta y sus subcarpetas find "${folder}" -type f -print0 | while IFS= read -r -d '' file do # Obtiene el nombre del archivo filename=$(basename "$file") # Obtiene los hash en MD5 y SHA1 del archivo md5=$(md5sum "$file" | cut -d ' ' -f 1) sha1=$(sha1sum "$file" | cut -d ' ' -f 1) # Obtiene los metadatos con exiftool metadata=$(exiftool "$file") # Escribe la información en el archivo HTML echo "<h2>${filename}</h2>" >> "$html_file" echo "<table>" >> "$html_file" echo "<tr><td>Cabecera:</td><td>$(file "$file")</td></tr>" >> "$html_file" echo "<tr><td>MD5:</td><td>${md5}</td></tr>" >> "$html_file" echo "<tr><td>SHA1:</td><td>${sha1}</td></tr>" >> "$html_file" echo "<tr><td>Metadatos:</td><td><pre>${metadata}</pre></td></tr>" >> "$html_file" echo "</table><br>" >> "$html_file" done # Escribe el cierre del archivo HTML echo "</body></html>" >> "$html_file" echo "El análisis se ha guardado en el archivo ${html_file}" # Abrir el archivo HTML con el navegador web predeterminado xdg-open "$html_file"