-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevil-winrm
executable file
·54 lines (49 loc) · 1.4 KB
/
evil-winrm
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
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 -i <ip_address> -u <username> [-p <password> | -h <hash>]"
exit 1
}
# Check if the number of arguments is less than 4 (minimum required)
if [ $# -lt 4 ]; then
usage
fi
# Parse command line arguments
while getopts ":i:u:p:h:" opt; do
case $opt in
i)
ip_address=$OPTARG
;;
u)
username=$OPTARG
;;
p)
password=$OPTARG
;;
h)
hash=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
# Check if either password or hash is provided
if [[ -n $password && -n $hash ]]; then
echo "Specify only one of -p (password) or -h (hash), not both."
usage
elif [[ -z $password && -z $hash ]]; then
echo "Either -p (password) or -h (hash) must be provided."
usage
fi
# Run docker command based on provided arguments
if [ -n "$password" ]; then
docker run --rm -ti --name evil-winrm --platform linux/amd64 oscarakaelvis/evil-winrm -i "$ip_address" -u "$username" -p "$password"
elif [ -n "$hash" ]; then
docker run --rm -ti --name evil-winrm --platform linux/amd64 oscarakaelvis/evil-winrm -i "$ip_address" -u "$username" -H "$hash"
fi