-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASHijacking.sh
More file actions
20 lines (17 loc) · 798 Bytes
/
ASHijacking.sh
File metadata and controls
20 lines (17 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# Set your AS number , Example : AS57027
AS_NUMBER="YourASN"
# Fetch the prefixes from the URL and get the list of prefixes
PREFIXES=$(curl -s "https://stat.ripe.net/data/announced-prefixes/data.json?resource=$AS_NUMBER" | jq -r '.data.prefixes[].prefix')
# Read the allowed ranges from the ranges.txt file
ALLOWED_RANGES=$(cat ranges.txt)
# Loop through the prefixes and check if they are in the allowed ranges
for PREFIX in $PREFIXES; do
if echo "$ALLOWED_RANGES" | grep -q "$PREFIX"; then
# If the prefix is allowed, print in green
echo -e "\033[0;32m$PREFIX is allowed\033[0m"
else
# If the prefix is not allowed, print in red and show the prefix
echo -e "\033[0;31mWarning: $PREFIX is not an allowed range! AS $AS_NUMBER might be hijacked.\033[0m"
fi
done