-
Notifications
You must be signed in to change notification settings - Fork 23
/
stop.sh
executable file
·57 lines (44 loc) · 1.48 KB
/
stop.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
#!/bin/bash
# Stop Damn Vulnerable Drone simulator
if [ "$EUID" -ne 0 ]; then
echo "This script must be run with sudo privileges."
echo "Please run it again with 'sudo ./stop.sh'"
exit 1
fi
echo "[+] Stopping Damn Vulnerable Drone Lab Environment - $(date)"
# Check if a card is virtual
check_virtual_interface() {
interface=$1
phy_device=$(readlink -f "/sys/class/net/$interface/device/ieee80211" 2>/dev/null)
if [[ -n "$phy_device" && "$phy_device" =~ "mac80211_hwsim" ]]; then
return 1
else
return 0
fi
}
# Clean up
clean_up_and_setup() {
echo -e "${CYAN}[+] Running System clean up...${NC}"
# Stop Docker Compose services
echo "[+] Stopping Docker Compose services..."
docker compose down
# Function to delete wireless interfaces
delete_wireless_interface() {
sudo iw dev "$1" del >/dev/null 2>&1
}
# Get a list of all wireless interfaces
wireless_interfaces=$(iw dev | awk '$1=="Interface"{print $2}' | tac)
# Iterate over each wireless interface and delete if check_virtual_interface returns 1
for interface in $wireless_interfaces; do
if ! check_virtual_interface "$interface"; then
echo "Removing $interface..."
delete_wireless_interface "$interface"
fi
done
# Start services
sudo modprobe -r mac80211_hwsim
sudo service networking start
sudo service NetworkManager start
echo -e "${CYAN}[+] System Ready...${NC}"
}
clean_up_and_setup