| 4 | import locale |
| 5 | |
| 6 | def server_program(): |
| 7 | host = '0.0.0.0' |
| 8 | port = 5656 |
| 9 | |
| 10 | server_socket = socket.socket() |
| 11 | server_socket.bind((host, port)) |
| 12 | |
| 13 | server_socket.listen(1) |
| 14 | conn, address = server_socket.accept() # accept new connection |
| 15 | conn.settimeout(60) # 60 second timeout |
| 16 | print("Connection from: " + str(address)) |
| 17 | |
| 18 | |
| 19 | timestr = time.strftime("%Y%m%d-%H%M%S") |
| 20 | print("[+] Writing dump to dump-" + timestr + ".bin...") |
| 21 | |
| 22 | total_received = 0 |
| 23 | with open("dump-" + timestr + ".bin", "wb") as f: |
| 24 | while True: |
| 25 | try: |
| 26 | data = conn.recv(0x10000) |
| 27 | total_received += len(data) |
| 28 | print("Received " + str(total_received) + " bytes...") |
| 29 | if not data: |
| 30 | break |
| 31 | f.write(data); |
| 32 | except: |
| 33 | break |
| 34 | f.close() |
| 35 | conn.close() |
| 36 | server_socket.close() |
| 37 | |
| 38 | if __name__ == '__main__': |
| 39 | server_program() |