Added logging

This commit is contained in:
Emily 2018-09-28 21:58:12 +02:00
parent dd315d31d0
commit 347067ceb0

View File

@ -34,21 +34,39 @@ class Proxy(Thread):
if c:
c_data, c_addr = client.recvfrom(self.BUFF_SIZE)
print("[C] data:{} addr:{}".format(c_data, c_addr))
#print("[C] data:{} addr:{}".format(c_data, c_addr))
if c_data:
"""
if c_data[:2] == b"\x08\x1e":
print("Editing port check: {}".format(c_data.hex()))
c_data = b"\x08\x1e\x77\xda"
print("[C] -> {}".format(c_data.hex()))
"""
print("[C] -> {}".format(c_data))
with open("logs/client-raw.log", "ab") as f:
f.write(c_data + b"\r\n")
with open("logs/client-hex.log", "a") as f:
f.write(c_data.hex() + "\r\n")
with open("logs/all-raw.log", "ab") as f:
f.write(c_data + b"\r\n")
with open("logs/all-hex.log", "a") as f:
f.write(c_data.hex() + "\r\n")
target.sendto(c_data, self.target)
(s, _, _) = select.select([target],[],[],0)
if s:
s_data = target.recv(self.BUFF_SIZE)
print("[S] data:{}".format(s_data))
#print("[S] data:{}".format(s_data))
if s_data:
print("[C] <- {}".format(s_data.hex()))
print("[C] <- {}".format(s_data))
with open("logs/server-raw.log", "ab") as f:
f.write(s_data + b"\r\n")
with open("logs/server-hex.log", "a") as f:
f.write(s_data.hex() + "\r\n")
with open("logs/all-raw.log", "ab") as f:
f.write(s_data + b"\r\n")
with open("logs/all-hex.log", "a") as f:
f.write(s_data.hex() + "\r\n")
client.sendto(s_data, c_addr)
client.close()
@ -62,6 +80,15 @@ LISTEN = ("0.0.0.0", int(sys.argv[1]))
TARGET = (sys.argv[2], int(sys.argv[3]))
##while True:
# Delete old log files
open("logs/client-raw.log", "w").close()
open("logs/client-hex.log", "w").close()
open("logs/server-raw.log", "w").close()
open("logs/server-hex.log", "w").close()
open("logs/all-raw.log", "w").close()
open("logs/all-hex.log", "w").close()
proxy = Proxy(LISTEN, TARGET)
proxy.start()
proxy.join()