-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploit.sh
50 lines (44 loc) · 853 Bytes
/
exploit.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
#!/bin/bash
usage() {
echo "Usage: $0 -u <user> -d <hostname> -p <port> -pwd <password>"
exit 1
}
# Initialize variables
destination=""
username=""
port=""
password=""
# Parse command-line options
while [[ "$#" -gt 0 ]]; do
case "$1" in
-d)
destination="$2"
shift 2
;;
-u)
username="$2"
shift 2
;;
-p)
port="$2"
shift 2
;;
-pwd)
password="$2"
shift 2
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
# Check if all required arguments are provided
if [[ -z "$destination" || -z "$username" || -z "$port" || -z "$password" ]]; then
echo "Error: Missing required arguments."
usage
fi
function get_flag() {
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$username@$destination" -p "$port" 2>&1 | grep -v 'Connection to .* closed' | cut -d ':' -f 2
}
echo "$(get_flag)"