-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_sha256_hashes.sh
36 lines (27 loc) · 939 Bytes
/
generate_sha256_hashes.sh
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
#!/bin/bash
# Nome do diretório alvo
TARGET_DIR="forense_tools"
# Nome do arquivo de saída
OUTPUT_FILE="forense_tools_sha256_hashes.txt"
# Verifica se o diretório alvo existe
if [ ! -d "$TARGET_DIR" ]; then
echo "Erro: O diretório $TARGET_DIR não existe."
exit 1
fi
# Remove o arquivo de saída se já existir
if [ -f "$OUTPUT_FILE" ]; then
rm "$OUTPUT_FILE"
fi
# Gera os hashes
find "$TARGET_DIR" -type f -print0 | while IFS= read -r -d '' file; do
sha256sum "$file" >> "$OUTPUT_FILE"
done
# Ordena o arquivo de saída alfabeticamente pelos nomes dos arquivos
sort -k 2 "$OUTPUT_FILE" -o "$OUTPUT_FILE"
echo "Hashes SHA256 gerados e salvos em $OUTPUT_FILE"
# Exibe as primeiras linhas do arquivo de saída
echo "Primeiras linhas do arquivo de hashes:"
head "$OUTPUT_FILE"
# Conta o número total de arquivos processados
total_files=$(wc -l < "$OUTPUT_FILE")
echo "Total de arquivos processados: $total_files"