|
@ -5,28 +5,31 @@ |
|
|
|
|
|
|
|
|
TARGET_IPSET='wan' |
|
|
TARGET_IPSET='wan' |
|
|
TARGET_ASN='2906' |
|
|
TARGET_ASN='2906' |
|
|
TARGET_FNAME="/var/tmp_AS${TARGET_ASN}" |
|
|
|
|
|
|
|
|
TARGET_FNAME="/var/vpn-policy-routing_tmp_AS${TARGET_ASN}" |
|
|
#DB_SOURCE='ipinfo.io' |
|
|
#DB_SOURCE='ipinfo.io' |
|
|
#DB_SOURCE='api.hackertarget.com' |
|
|
#DB_SOURCE='api.hackertarget.com' |
|
|
DB_SOURCE='api.bgpview.io' |
|
|
DB_SOURCE='api.bgpview.io' |
|
|
|
|
|
|
|
|
_ret=1 |
|
|
_ret=1 |
|
|
if [ "$DB_SOURCE" = "ipinfo.io" ]; then |
|
|
|
|
|
TARGET_URL="https://ipinfo.io/AS${TARGET_ASN}" |
|
|
|
|
|
curl "$TARGET_URL" 2>/dev/null | grep -E "a href.*${TARGET_ASN}\/" | grep -v ":" | sed "s/^.*<a href=\"\/AS${TARGET_ASN}\///; s/\" >//" > "$TARGET_FNAME" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$DB_SOURCE" = "api.hackertarget.com" ]; then |
|
|
|
|
|
TARGET_URL="https://api.hackertarget.com/aslookup/?q=AS${TARGET_ASN}" |
|
|
|
|
|
curl "$TARGET_URL" 2>/dev/null | sed '1d' > "$TARGET_FNAME" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ ! -s "$TARGET_FNAME" ]; then |
|
|
|
|
|
if [ "$DB_SOURCE" = "ipinfo.io" ]; then |
|
|
|
|
|
TARGET_URL="https://ipinfo.io/AS${TARGET_ASN}" |
|
|
|
|
|
curl "$TARGET_URL" 2>/dev/null | grep -E "a href.*${TARGET_ASN}\/" | grep -v ":" | sed "s/^.*<a href=\"\/AS${TARGET_ASN}\///; s/\" >//" > "$TARGET_FNAME" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$DB_SOURCE" = "api.hackertarget.com" ]; then |
|
|
|
|
|
TARGET_URL="https://api.hackertarget.com/aslookup/?q=AS${TARGET_ASN}" |
|
|
|
|
|
curl "$TARGET_URL" 2>/dev/null | sed '1d' > "$TARGET_FNAME" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$DB_SOURCE" = "api.bgpview.io" ]; then |
|
|
|
|
|
TARGET_URL="https://api.bgpview.io/asn/${TARGET_ASN}/prefixes" |
|
|
|
|
|
if command -v jq >/dev/null 2>&1; then |
|
|
|
|
|
curl -s "$TARGET_URL" 2>/dev/null | jq -r '.data.ipv4_prefixes[].prefix' > "$TARGET_FNAME" |
|
|
|
|
|
else |
|
|
|
|
|
curl -s "$TARGET_URL" 2>/dev/null | sed -ne 's/.*"ipv4_prefixes":\(.*\),"ipv6_prefixes":.*/\1\n/g; s/\}\},/&\n/g; s/"parent":{"prefix":/"parent":{"parent_prefix":/gp' | sed -ne 's/.*"prefix":"\(.\{0,20\}\)",".*/\1/g; s/\\//gp' > "$TARGET_FNAME" |
|
|
|
|
|
|
|
|
if [ "$DB_SOURCE" = "api.bgpview.io" ]; then |
|
|
|
|
|
TARGET_URL="https://api.bgpview.io/asn/${TARGET_ASN}/prefixes" |
|
|
|
|
|
if command -v jq >/dev/null 2>&1; then |
|
|
|
|
|
curl -s "$TARGET_URL" 2>/dev/null | jq -r '.data.ipv4_prefixes[].prefix' > "$TARGET_FNAME" |
|
|
|
|
|
else |
|
|
|
|
|
curl -s "$TARGET_URL" 2>/dev/null | sed -ne 's/.*"ipv4_prefixes":\(.*\),"ipv6_prefixes":.*/\1\n/g; s/\}\},/&\n/g; s/"parent":{"prefix":/"parent":{"parent_prefix":/gp' | sed -ne 's/.*"prefix":"\(.\{0,20\}\)",".*/\1/g; s/\\//gp' > "$TARGET_FNAME" |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|