commit ebfeb2aee8c73cf18762e0e5f06b5b3c9cad7a9b Author: Alexandre Dulaunoy Date: Sun Apr 3 12:11:39 2011 +0200 added some ~/bin scripts diff --git a/bin/encrypt-from-ssl.sh b/bin/encrypt-from-ssl.sh new file mode 100644 index 0000000..b1f7823 --- /dev/null +++ b/bin/encrypt-from-ssl.sh @@ -0,0 +1,26 @@ +# from http://dpaste.de/61O8/raw/ + +set -e + +echo "Encrypting $2 for $1." + +# make a directory to store results for this site +mkdir -p results/$1 + +# get that site's SSL certificate, validating it with the cacert.pem we have +echo "QUIT" | openssl s_client -CAfile cacert.pem -connect $1:443 > results/$1/cert.pem + +# generate a random password from urandom +dd if=/dev/urandom of=results/$1/pass.txt bs=1 count=96 + +# use the raw password and AES to encrypt the output +openssl enc -a -aes-256-cbc -salt -in $2 -out results/$1/file.enc -pass file:results/$1/pass.txt + +# then, use the above public cert to encrypt the pass key +openssl rsautl -encrypt -inkey results/$1/cert.pem -pubin -certin -in results/$1/pass.txt -out results/$1/pass.enc + +# finally, delete the password so it's not around and accidentally leaked +rm results/$1/pass.txt + +echo "ALL DONE" + diff --git a/bin/ip2asn.pl b/bin/ip2asn.pl new file mode 100644 index 0000000..69a979b --- /dev/null +++ b/bin/ip2asn.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl +# +# Takes as input IP address (one per line) +# and output the guessed IP location along with ASN origin and its description +# +# perl iporigin.pl +# 8.8.8.8 +# US;AS15169;GOOGLE - Google Inc.;8.8.8.8 +# 8.8.4.4 +# US;AS15169;GOOGLE - Google Inc.;8.8.4.4 +# 4.4.4.4 +# US;AS3356;LEVEL3 Level 3 Communications;4.4.4.4 +# +# +# This file is in the public domain. +# +# Alexandre Dulaunoy - http://github.com/adulau + +use Net::Whois::RIS; +use IP::Country::Fast; +my $country = IP::Country::Fast->new(); +$| = 1; + +while () { + next if /^#/; + chomp(); + @v = split(/ /, $_); + $v[0]; + $l = Net::Whois::RIS->new(); + $l->getIPInfo($v[0]); + print $country->inet_atocc($v[0]).";".$l->getOrigin().";".$l->getDescr().";".$v[0]."\n"; +}