-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploit.sh
52 lines (42 loc) · 1.46 KB
/
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
51
52
#!/bin/bash
# Function to decode base64 data repeatedly until fully decoded
decode_multiple_times() {
local encoded_data="$encoded_data"
local previous_data=""
local phase=1
echo "Encoded Data: $encoded_data"
# Loop until the data stops changing (fully decoded)
while true; do
echo "-----------------------------------------------------------------"
# Try to decode the data
local new_decoded_data
new_decoded_data=$(echo "$encoded_data" | base64 -d 2>/dev/null)
# Check if the decoding was successful
if [[ $? -ne 0 ]]; then
echo "Decoding success!!!"
echo "The flag is: $encoded_data"
break
fi
# Check if the data has stopped changing
if [[ "$new_decoded_data" == "$previous_data" ]]; then
break
fi
# Update the data for the next iteration
previous_data="$encoded_data"
encoded_data="$new_decoded_data"
echo "Decoded phase $phase: $encoded_data"
((phase++))
done
echo "$decoded_data"
}
# Check if a valid url is provided as an argument
if ! [[ "$1" =~ ^(https?://)?([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,})(:[0-9]+)?(/.*)?$ ]]; then
echo "Error: Please provide the valid file's URL as an argument."
echo "Usage: $0 <url>"
exit 1
fi
url=$1
wget -q $url -O file
encoded_data=$(cat file)
decoded_data=$(decode_multiple_times "$encoded_data")
echo "$decoded_data"