-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
109 lines (99 loc) · 3.08 KB
/
server.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import asyncio
import aiohttp
import aiofiles
from aiohttp import web
from multidict import CIMultiDict
import os
import uuid
Clients = {}
def clear_console() -> None:
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
def Log(message, client):
if client in Clients:
print(message)
if not os.path.exists("Logs"):
os.mkdir("Logs")
with open("Logs/" + str(Clients[client]) + ".log", "a") as f:
f.write(message + "\n")
def ClearLogs():
for log in os.listdir("Logs"):
os.remove("Logs/" + log)
async def handle(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/html',
}
)
async with aiofiles.open('pwn.html', mode='r') as f:
html_content = await f.read()
return web.Response(text=html_content, headers=headers)
async def util(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('util.js', mode='r') as f:
js_content = await f.read()
return web.Response(text=js_content, headers=headers)
async def int64(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('int64.js', mode='r') as f:
js_content = await f.read()
return web.Response(text=js_content, headers=headers)
async def helper(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('helper.js', mode='r') as f:
js_content = await f.read()
return web.Response(text=js_content, headers=headers)
async def wshandler(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
Clients[ws] = uuid.uuid4()
clear_console()
print("UUID: " + str(Clients[ws]))
try:
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
Log(f"{msg.data}", ws)
await ws.send_str(f"copy_that")
elif msg.type == aiohttp.WSMsgType.ERROR:
print(f"WebSocket closed with exception: {ws.exception()}")
except ConnectionResetError:
pass
print("WebKit Crash")
return ws
try:
ClearLogs()
app = web.Application()
app.router.add_get('/', handle)
app.router.add_get('/util.js', util)
app.router.add_get('/int64.js', int64)
app.router.add_get('/helper.js', helper)
app.router.add_get('/WebSocket', wshandler)
web.run_app(app, host='0.0.0.0', port=8080)
except KeyboardInterrupt:
exit(0)