-
Notifications
You must be signed in to change notification settings - Fork 167
/
aem_server.py
49 lines (33 loc) · 1.21 KB
/
aem_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
from http.server import BaseHTTPRequestHandler, HTTPServer
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
def do_print(self, method):
print('\n\n[+] {0} request: {1}'.format(method, self.path))
print('===[HEADERS]===')
for name, value in sorted(self.headers.items()):
print('\t{0}={1}'.format(name, value))
try:
print('===[BODY]===\n' + self.rfile.read(int(self.headers.get('content-length'))).decode('utf-8'))
except:
pass
def do_POST(self):
self.do_print('POST')
self.send_response(200)
self.end_headers()
return
def do_GET(self):
self.do_print('GET')
self.send_response(200)
data = open('response.bin', 'rb').read()
self.send_header('Content-type', 'application/octet-stream')
self.send_header('Content-length', len(data))
self.end_headers()
self.wfile.write(data)
return
def run():
print('starting fake AEM server...')
server_address = ('0.0.0.0', 80)
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
print('running server...')
httpd.serve_forever()
if __name__ == '__main__':
run()