-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart_pentest.sh
executable file
·88 lines (77 loc) · 1.77 KB
/
start_pentest.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
#!/bin/bash
function show_help() {
echo "usage: $0 <bot amount> [port] [chat file]"
echo "description:"
echo " creates <bot amount> penetration bots"
echo " and sends them to localhost:port (default 8303)"
echo "env:"
echo " SERVER_IP server ip to be used instead of localhost"
echo " SERVER_PW server password"
}
if [ $# -eq 0 ] || [ "$1" == "--help" ]
then
show_help
exit
fi
if [ ! -d ./src ]
then
echo "Error: source folder not found"
echo "make sure to execute the script from root of repo"
exit 1
fi
if [ ! -d ./build ] || [ ! -f ./build/chillerbot-ng ]
then
mkdir -p build
cd build || exit 1
cmake ..
make -j"$(nproc)"
cd ..
fi
arg_num=$1
arg_port=8303
arg_file=pentest.txt
arg_ip="${SERVER_IP:-localhost}"
arg_password="${SERVER_PW:-test}"
if [ $# -gt 1 ]
then
arg_port=$2
fi
if [ $# -gt 2 ]
then
arg_file=$3
fi
re='^[0-9]+$'
if ! [[ $arg_num =~ $re ]]
then
echo "Error: first argument is not a number '$arg_num'" >&2
exit 1
fi
if ! [[ $arg_port =~ $re ]]
then
echo "Error: second argument is not a number '$arg_port'" >&2
exit 1
fi
if [ ! -f "$arg_file" ]
then
echo "Error: chat file '$arg_file' not found."
echo "Do you want to create it? [y/N]"
read -r -n 1 yn
echo ""
if [[ "$yn" =~ [yY] ]]
then
vi "$arg_file"
else
echo "aborting due to missing file..."
exit 1
fi
fi
echo "starting bots on port: $arg_port"
echo "use ./stop_pentest.sh to stop them"
for (( i=0; i<arg_num; i++ ))
do
printf "."
nohup ./build/chillerbot-ng "cl_chiller_inp 0;cl_pentest 1;cl_pentest_file $arg_file;password $arg_password;connect $arg_ip:$arg_port" >/dev/null 2>&1 &
sleep 0.5
done
echo ""
echo "finished starting $arg_num pentest bots."