Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Last active August 29, 2015 14:25
Show Gist options
  • Save DylanLukes/5fefa55f693f380d03fb to your computer and use it in GitHub Desktop.
Save DylanLukes/5fefa55f693f380d03fb to your computer and use it in GitHub Desktop.
#!/bin/bash
function atoi {
IP=$1; IPNUM=0
for (( i=0 ; i<4 ; ++i )); do
((IPNUM+=${IP%%.*}*$((256**$((3-${i}))))))
IP=${IP#*.}
done
echo $IPNUM
}
function itoa {
echo -n $(($(($(($((${1}/256))/256))/256))%256)).
echo -n $(($(($((${1}/256))/256))%256)).
echo -n $(($((${1}/256))%256)).
echo $((${1}%256))
}
goal="f04031af5ee9939a931a062b836c385eb2ee681fd704ed919534b78329ae34e173e13c31ebfd03db1eb9e9759cd3365195d0d7d53028256038b24975ace8c83d"
for ip in 172.16.{0..255}.{0..255} ; do
echo "Checking " $ip " (" $(atoi $ip) ")"
digest=$(atoi $ip | openssl dgst -sha512)
if [ "$goal" = "$digest" ]
then echo "Success. The answer is: " $ip; exit
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment