Added logging
This commit is contained in:
parent
dd315d31d0
commit
347067ceb0
35
proxy.py
35
proxy.py
|
@ -34,21 +34,39 @@ class Proxy(Thread):
|
||||||
|
|
||||||
if c:
|
if c:
|
||||||
c_data, c_addr = client.recvfrom(self.BUFF_SIZE)
|
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:
|
||||||
|
"""
|
||||||
if c_data[:2] == b"\x08\x1e":
|
if c_data[:2] == b"\x08\x1e":
|
||||||
print("Editing port check: {}".format(c_data.hex()))
|
print("Editing port check: {}".format(c_data.hex()))
|
||||||
c_data = b"\x08\x1e\x77\xda"
|
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)
|
target.sendto(c_data, self.target)
|
||||||
|
|
||||||
(s, _, _) = select.select([target],[],[],0)
|
(s, _, _) = select.select([target],[],[],0)
|
||||||
|
|
||||||
if s:
|
if s:
|
||||||
s_data = target.recv(self.BUFF_SIZE)
|
s_data = target.recv(self.BUFF_SIZE)
|
||||||
print("[S] data:{}".format(s_data))
|
#print("[S] data:{}".format(s_data))
|
||||||
if 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.sendto(s_data, c_addr)
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
@ -62,6 +80,15 @@ LISTEN = ("0.0.0.0", int(sys.argv[1]))
|
||||||
TARGET = (sys.argv[2], int(sys.argv[3]))
|
TARGET = (sys.argv[2], int(sys.argv[3]))
|
||||||
|
|
||||||
##while True:
|
##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 = Proxy(LISTEN, TARGET)
|
||||||
proxy.start()
|
proxy.start()
|
||||||
proxy.join()
|
proxy.join()
|
||||||
|
|
Reference in New Issue
Block a user