-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·151 lines (138 loc) · 4.41 KB
/
server.py
File metadata and controls
executable file
·151 lines (138 loc) · 4.41 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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('index.html', mode='r') as f:
html_content = await f.read()
return web.Response(text=html_content, headers=headers)
async def utils(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('utils.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 pwn(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('pwn.js', mode='r') as f:
js_content = await f.read()
return web.Response(text=js_content, headers=headers)
async def stages(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('stages.js', mode='r') as f:
js_content = await f.read()
return web.Response(text=js_content, headers=headers)
async def offsets(request):
headers = CIMultiDict(
{
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Content-Type': 'text/javascript',
}
)
async with aiofiles.open('offsets.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('/utils.js', utils)
app.router.add_get('/int64.js', int64)
app.router.add_get('/helper.js', helper)
app.router.add_get('/pwn.js', pwn)
app.router.add_get('/stages.js', stages)
app.router.add_get('/offsets.js', offsets)
app.router.add_get('/WebSocket', wshandler)
web.run_app(app, host='0.0.0.0', port=1337)
except KeyboardInterrupt:
exit(0)