-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkalibox
99 lines (87 loc) · 3.74 KB
/
kalibox
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
#!/bin/bash
# LICENSE: https://github.com/sakibulalikhan/pentestbox/blob/main/LICENSE
set -e
print_banner() {
printf " ▄▄▄ ▄ ▄▄▄▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄ ▄▄ \n"
printf "█ █ █ █ █ █ █ █ ▄ █ █ █▄█ █ \n"
printf "█ █▄█ █ ▄ █ █ █ █ █▄█ █ ▄ █ █ \n"
printf "█ ▄█ █▄█ █ █ █ █ █ █ █ █ █ \n"
printf "█ █▄█ █ █▄▄▄█ █ ▄ ██ █▄█ ██ █ \n"
printf "█ ▄ █ ▄ █ █ █ █▄█ █ █ ▄ █ \n"
printf "█▄▄▄█ █▄█▄█ █▄▄█▄▄▄▄▄▄▄█▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄█ █▄▄█ \n"
printf "+---------------------------------------------------+\n"
printf "| Author : @sakibulalikhan |\n"
printf "+---------------------------------------------------+\n\n"
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
container_exists() {
local container_name="$1"
docker ps -a --format '{{.Names}}' | grep -w "$container_name" >/dev/null 2>&1
}
create_container() {
echo "Cannot find container kalibox."
read -p "Create it now, out of image kalilinux/kali-rolling? [Y/n]: " create_container
while [[ ! "$create_container" =~ ^[YyNn]$ ]]; do
read -p "Invalid input. Please enter Y or N: " create_container
done
if [[ "$create_container" =~ ^[Yy]$ ]]; then
read -p "Do you want to use NVIDIA support? [Y/n]: " use_nvidia
while [[ ! "$use_nvidia" =~ ^[YyNn]$ ]]; do
read -p "Invalid input. Please enter Y or N: " use_nvidia
done
if [[ "$use_nvidia" =~ ^[Yy]$ ]]; then
distrobox create --nvidia -n kalibox -i kalilinux/kali-rolling || {
echo "Failed to create container with NVIDIA support."
exit 1
}
else
distrobox create -n kalibox -i kalilinux/kali-rolling || {
echo "Failed to create container."
exit 1
}
fi
else
echo "For creating it, run this command:"
echo " distrobox create -n <name-of-container> -i <image>"
fi
}
print_banner
if ! command_exists "distrobox"; then
echo "distrobox command not found. Installing..."
wget -qO- https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh
fi
sudo systemctl start docker || { echo "Failed to start Docker service."; exit 1; }
sudo chmod 666 /var/run/docker.sock || { echo "Failed to change permissions on Docker socket."; exit 1; }
case "$1" in
""|start)
echo "Starting services..."
if ! container_exists "kalibox"; then
create_container
fi
distrobox enter kalibox
;;
stop)
echo "Stopping services..."
distrobox stop kalibox || echo "Failed to stop kalibox."
;;
remove)
echo "Removing container kalibox..."
if container_exists "kalibox"; then
distrobox rm kalibox || echo "Failed to remove kalibox."
else
echo "Container kalibox does not exist."
fi
;;
help)
echo "Usage: kalibox [start|stop|remove|help]"
echo " kalibox start : Start the kalibox services"
echo " kalibox stop : Stop the kalibox services"
echo " kalibox remove : Remove the kalibox container"
echo " kalibox help : Show the help message"
;;
*)
echo "Invalid command. Use 'kalibox help' for usage information."
;;
esac