-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubnetScrape.sh
86 lines (71 loc) · 2.59 KB
/
subnetScrape.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Filenane: subnetScrape.sh
# Purpose: run (with ./subnetScrape x.x.x. or 204.185.1.)
# Function to display a progress bar
function show_progress_bar() {
local width=50
local percentage=$1
local filled=$(($percentage * $width / 100))
local empty=$(($width - $filled))
local progress_bar="["
for ((i = 0; i < filled; i++)); do
progress_bar+="*"
done
for ((i = 0; i < empty; i++)); do
progress_bar+=" "
done
progress_bar+="]"
printf "\r$progress_bar %3d%% %s" $percentage "$1"
}
# Function to perform a reverse DNS lookup for the /24 subnet
function reverse_dns_lookup() {
local subnet="$1"
local total=256
local count=0
echo "IP ADDR Hostname of Pointer"
echo "--------------------------------"
for i in $(seq 0 255); do
ip_address="${subnet}${i}"
reverse_dns=$(host "$ip_address")
if grep -q "domain name pointer" <<< "$reverse_dns"; then
ptr_record=$(awk '{print $NF}' <<< "$reverse_dns")
printf "%-12s%s\n" "$ip_address" "$ptr_record"
fi
((count++))
percentage=$((count * 100 / total))
show_progress_bar $percentage "$ip_address"
done
}
if [ -z "$1" ]; then
echo "Usage: $0 <subnet>"
exit 1
fi
# Check if $1 is a valid /24 subnet
if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.$ ]]; then
echo "Invalid subnet format. Please provide a valid /24 subnet (e.g., 192.168.1.)"
exit 1
fi
echo "Starting reverse DNS lookup for the subnet: $1"
# Perform the reverse DNS lookup for the provided /24 subnet
reverse_dns_lookup "$1"
echo "Reverse DNS lookup completed."
echo
##################### eof ##################
# EXAMPLE ouput of a running version:
:[~/sh]
[subz@pvehost]$ ./SS.sh 204.182.1.
Starting reverse DNS lookup for the subnet: 204.182.1.
IP ADDR Hostname of Pointer # THIS IS REV DNS SCANNING 204.182.1.0/24 and only found 7 o so
--------------------------------
[************************************* ] 75% 75204.182.1.194mail5.zotosintl.com.
mail5.zotos.com.
mail.siclegal.com.
[************************************** ] 76% 76204.182.1.197mail3.zotosintl.com.
mail2.siclegal.com.
mail3.zotos.com.
[************************************** ] 77% 77204.182.1.199mail4.zotos.com.
mail4.zotosintl.com.
[**************************************** ] 81% 81204.182.1.209email4.joico.com.
[***************************************** ] 82% 82204.182.1.210email.joico.com.
email3.joico.com.
[**************************************************] 100% 100Reverse DNS lookup completed.