11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

;;<br />

*) echo "Cancellazione del file \"$file\".";;<br />

esac<br />

Capitolo 12. Filtri, programmi e coman<strong>di</strong> esterni<br />

<strong>di</strong>m_file=$(ls -l "$file" | awk ’{print $5}’) # Il 5 campo è la <strong>di</strong>mensione<br />

#+ del file.<br />

conta_passi=1<br />

chmod u+w "$file" # Consente <strong>di</strong> sovrascrivere/cancellare il file.<br />

echo<br />

while [ "$conta-passi" -le "$PASSI" ]<br />

do<br />

echo "Passaggio nr.$conta_passi"<br />

sync # Scarica i buffer.<br />

dd if=/dev/urandom of=$file bs=$DIMBLOCCO count=$<strong>di</strong>m_file<br />

# Sovrascrive con byte casuali.<br />

sync # Scarica ancora i buffer.<br />

dd if=/dev/zero of=$file bs=$DIMBLOCCO count=$<strong>di</strong>m_file<br />

# Sovrascrive con zeri.<br />

sync # Scarica ancora una volta i buffer.<br />

let "conta_passi += 1"<br />

echo<br />

done<br />

rm -f $file # Infine, cancella il file.<br />

sync # Scarica i buffer un’ultima volta.<br />

echo "Il file \"$file\" è stato cancellato."; echo<br />

exit 0<br />

# È un metodo abbastanza sicuro, sebbene lento ed inefficiente, per rendere un<br />

#+ file completamente "irriconoscibile".<br />

# Il comando "shred", che fa parte del pacchetto GNU "fileutils", esegue lo<br />

#+ stesso lavoro, ma in maniera molto più efficiente.<br />

# La cancellazione non può essere "annullata" né il file recuperato con i<br />

#+ meto<strong>di</strong> consueti.<br />

# Tuttavia . . .<br />

#+ questo semplice metodo probabilmente *non* resisterebbe<br />

#+ ad una sofisticata analisi forense.<br />

# Questo script potrebbe non funzionare correttamente con un file system journaled.<br />

# Esercizio (<strong>di</strong>fficile): risolvete questo problema.<br />

# Il pacchetto per la cancellazione sicura <strong>di</strong> file "wipe" <strong>di</strong> Tom Vier esegue<br />

336

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!