3AHITS-SYTB-Schauer-Alexander

Arbeitsbericht

Übersicht

Übung (Maximum)

Angabe:

PuTTY ist als SSH Client für Windows sehr beliebt. Genauso beliebt ist aber auch einen Trojaner in einem PuTTY Download zu verstecken. Um das zu verhindern werden Downloads gerne mit einem Hashwert (in diesem Zusammenhang auch Checksum genannt) abgesichert.

alt text

alt text

Im Script soll automatisiert geprüft werden ob die Checksum (=SHA-512 Hash) des geladenen Files mit der Checksum aus dem Checksumfile übereinstimmt. Also zum Beispiel eine Ausgabe kommen: HASH OK.

Eine Liste aller u.U. brauchbarer Tools:

Lösung:

if [ ! -f "putty.zip" ]
then
        curl -O -L "https://the.earth.li/~sgtatham/putty/latest/w64/putty.zip"
fi

tmpFolder=$(mktemp -d)
tmpDatei="${tmpFolder}/sha512sums"

curl -o $tmpDatei "https://the.earth.li/~sgtatham/putty/0.83/sha512sums"

tmpdownHash="${tmpFolder}/downloadedHash"
tmpcalcHash="${tmpFolder}/calulatedHash"

grep w64/putty.zip $tmpDatei | cut -d " " -f1 | tr -d [:space:] > $tmpdownHash
sha512sum putty.zip | cut -d " " -f1 | tr -d [:space:] > $tmpcalcHash

if cmp -s $tmpdownHash $tmpcalcHash
then
        echo "HASH OK"
else
        echo "HASH NOT OK"
fi

Erklärung

Output:

┌──(kali㉿kali)-[~/SYTB/260512]
└─$ ./checkSum.sh   
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   342  100   342    0     0   2265      0 --:--:-- --:--:-- --:--:--  2280
100 3998k  100 3998k    0     0  3325k      0  0:00:01  0:00:01 --:--:-- 5467k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26626  100 26626    0     0   145k      0 --:--:-- --:--:-- --:--:--  146k
HASH OK

┌──(kali㉿kali)-[~/SYTB/260512]
└─$ ./checkSum.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26626  100 26626    0     0   135k      0 --:--:-- --:--:-- --:--:--  135k
HASH OK

Nicht erledigt

Diese Übung ist sich nicht mehr ausgegangen.