Last active
April 9, 2021 21:01
-
-
Save hateshape/603fac04ab6a542414defd5f00e725c4 to your computer and use it in GitHub Desktop.
curl/awk/sed shenanigans for ipv4info.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Domain Search Broke Currently on ipv4info.com | |
# ASN Search I Don't Care Enough to Do it | |
# ./ipv4info.sh COMPANYNAME | |
# ./ipv4info.sh IPADDRESS | |
ipv4info-compname(){ | |
URL="$(echo 'http://ipv4info.com/?act=check&ip='${COMPANYNAME} )" | |
curl -sLk $URL -o $COMPANYNAME.html | |
html2csv $COMPANYNAME.html > $COMPANYNAME.csv | |
sed 1,4d $COMPANYNAME.csv | awk -F',' '{print $1","$7","$9","$8","$3","$4","$5}' | sed 's#"##g' | head -n -1 > ipv4info-$COMPANYNAME.csv | |
if [[ -s $COMPANYNAME.csv ]];then rm $COMPANYNAME.csv;fi | |
if [[ -s $COMPANYNAME.html ]];then rm $COMPANYNAME.html;fi | |
} | |
ipv4info-ipaddress(){ | |
URL="$(echo 'http://ipv4info.com/?act=check&ip='${IPADDRESS} )" | |
curl -sLk $URL -o $IPADDRESS.html | |
html2csv $IPADDRESS.html > $IPADDRESS.csv | |
sed 1,4d $IPADDRESS.csv | sed '/Recent requests/,$d' | head -14 | sed 's#<<#,#g'| sed 's#>>##g'| sed 's#Domains in block# Domains in block#g' | sed 's# -#-#g' | sed 's#- #-#g' | sed 's#, #-#g' | sed 's# ##g' | sed 's#"##g' > ipv4info-$IPADDRESS.csv | |
if [[ -s $IPADDRESS.csv ]];then rm $IPADDRESS.csv;fi | |
if [[ -s $IPADDRESS.html ]];then rm $IPADDRESS.html;fi | |
} | |
echo $1 | grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" &>/dev/null | |
WHATVALUECHECK=$? | |
if [[ WHATVALUECHECK -eq 0 ]]; then | |
IPADDRESS=$1 | |
ipv4info-ipaddress $IPADDRESS | |
else | |
COMPANYNAME=$1 | |
ipv4info-compname $COMPANYNAME | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment