Created
April 8, 2021 12:51
-
-
Save deftonesclimb/a2c81633fc549ff90a207fe5823e7901 to your computer and use it in GitHub Desktop.
ips.txt dosyasına tek satır halinde yazılmış ipleri whois çeker
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 | |
| file="ips.txt" | |
| if [ ! -f "$file" ]; then | |
| echo "$file .txt dosyasi bulunamadi!." | |
| exit | |
| fi | |
| lines=`cat $file` | |
| echo "# Query,Subnet,Registrant,AS Number,Country,Issuer" | |
| for IP in $lines; do | |
| REVERSE_IP=$(echo $IP | awk -F "." '{print $4"."$3"."$2"."$1}') | |
| ASN_INFO=$(dig +short $REVERSE_IP.origin.asn.cymru.com TXT) | |
| PEER_INFO=$(dig +short $REVERSE_IP.peer.asn.cymru.com TXT) | |
| NUMBER=$(echo $ASN_INFO | cut -d'|' -f 1 | cut -d'"' -f 2 | cut -d' ' -f 1) | |
| ASN="AS$NUMBER" | |
| ASN_REPORT=$(dig +short $ASN.asn.cymru.com TXT) | |
| SUBNET=$(echo $ASN_INFO | cut -d'|' -f 2) | |
| COUNTRY=$(echo $ASN_INFO | cut -d'|' -f 3) | |
| ISSUER=$(echo $ASN_INFO | cut -d'|' -f 4) | |
| PEERS=$(echo $PEER_INFO | cut -d'|' -f 1 | cut -d'"' -f 2) | |
| REGISTRY_DATE=$(echo $ASN_REPORT | cut -d'|' -f 4) | |
| REGISTRANT=$(echo $ASN_REPORT | cut -d'|' -f 5 | cut -d'"' -f 1) | |
| if [[ $REGISTRANT == *${1^^}* || $ASN == *${1^^}* ]]; then | |
| echo -e "$IP\t$SUBNET\t$ASN\t$COUNTRY\t$REGISTRANT" | |
| fi | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dnsutils kurulu olması gerekir.
Ubuntu - Debian için apt-get install dnsutils
Centos için dnf install bind-utils
Centos 7 ve öncesi için yum install bind-utils