-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploit.py
52 lines (38 loc) · 1.28 KB
/
exploit.py
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
import argparse
import base64
import requests
def get_url():
parser = argparse.ArgumentParser()
parser.add_argument("URL", help="the file's URL.")
args = parser.parse_args()
return args.URL
def get_b64_string(url):
response = requests.get(url)
response.raise_for_status()
return response.content.decode("utf-8")
def double_base64_decode(encoded_str):
first_decode = base64.b64decode(encoded_str)
cleaned_str = first_decode.decode(
'utf-8').strip("b'").strip().replace("'", "")
second_decode = base64.b64decode(cleaned_str)
return second_decode.decode('utf-8')
def rot19(decoded_str):
def rotN(s, n):
result = []
for char in s:
if 'a' <= char <= 'z':
result.append(chr((ord(char) - ord('a') + n) % 26 + ord('a')))
elif 'A' <= char <= 'Z':
result.append(chr((ord(char) - ord('A') + n) % 26 + ord('A')))
else:
result.append(char)
return ''.join(result)
return rotN(decoded_str, 19)
def get_flag(url):
b64_string = get_b64_string(url)
decoded_b64 = double_base64_decode(b64_string)
decoded_rot19 = rot19(decoded_b64)
return decoded_rot19
if __name__ == "__main__":
url = get_url()
print("Flag:", get_flag(url))