Proxy log different port
This commit is contained in:
parent
347067ceb0
commit
9af92cc75c
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -94,3 +94,5 @@ ENV/
|
||||||
# Rope project settings
|
# Rope project settings
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
|
40
proxy.py
40
proxy.py
|
@ -1,4 +1,5 @@
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import socket
|
import socket
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import select
|
import select
|
||||||
|
@ -42,14 +43,14 @@ class Proxy(Thread):
|
||||||
c_data = b"\x08\x1e\x77\xda"
|
c_data = b"\x08\x1e\x77\xda"
|
||||||
"""
|
"""
|
||||||
print("[C] -> {}".format(c_data))
|
print("[C] -> {}".format(c_data))
|
||||||
with open("logs/client-raw.log", "ab") as f:
|
with open("logs/{}-client-raw.log".format(LISTEN[1]), "ab") as f:
|
||||||
f.write(c_data + b"\r\n")
|
f.write(c_data + b"\r\n")
|
||||||
with open("logs/client-hex.log", "a") as f:
|
with open("logs/{}-client-hex.log".format(LISTEN[1]), "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")
|
f.write(c_data.hex() + "\r\n")
|
||||||
|
with open("logs/{}-all-raw.log".format(LISTEN[1]), "ab") as f:
|
||||||
|
f.write(b"[C] -> " + c_data + b"\r\n")
|
||||||
|
with open("logs/{}-all-hex.log".format(LISTEN[1]), "a") as f:
|
||||||
|
f.write("[C] -> " + 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)
|
||||||
|
@ -59,14 +60,14 @@ class Proxy(Thread):
|
||||||
#print("[S] data:{}".format(s_data))
|
#print("[S] data:{}".format(s_data))
|
||||||
if s_data:
|
if s_data:
|
||||||
print("[C] <- {}".format(s_data))
|
print("[C] <- {}".format(s_data))
|
||||||
with open("logs/server-raw.log", "ab") as f:
|
with open("logs/{}-server-raw.log".format(LISTEN[1]), "ab") as f:
|
||||||
f.write(s_data + b"\r\n")
|
f.write(s_data + b"\r\n")
|
||||||
with open("logs/server-hex.log", "a") as f:
|
with open("logs/{}-server-hex.log".format(LISTEN[1]), "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")
|
f.write(s_data.hex() + "\r\n")
|
||||||
|
with open("logs/{}-all-raw.log".format(LISTEN[1]), "ab") as f:
|
||||||
|
f.write(b"[C] <- " + s_data + b"\r\n")
|
||||||
|
with open("logs/{}-all-hex.log".format(LISTEN[1]), "a") as f:
|
||||||
|
f.write("[C] <- " + s_data.hex() + "\r\n")
|
||||||
client.sendto(s_data, c_addr)
|
client.sendto(s_data, c_addr)
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
@ -81,13 +82,16 @@ TARGET = (sys.argv[2], int(sys.argv[3]))
|
||||||
|
|
||||||
##while True:
|
##while True:
|
||||||
|
|
||||||
|
if not os.path.exists("logs"):
|
||||||
|
os.makedirs("logs")
|
||||||
|
|
||||||
# Delete old log files
|
# Delete old log files
|
||||||
open("logs/client-raw.log", "w").close()
|
open("logs/{}-client-raw.log".format(LISTEN[1]), "w").close()
|
||||||
open("logs/client-hex.log", "w").close()
|
open("logs/{}-client-hex.log".format(LISTEN[1]), "w").close()
|
||||||
open("logs/server-raw.log", "w").close()
|
open("logs/{}-server-raw.log".format(LISTEN[1]), "w").close()
|
||||||
open("logs/server-hex.log", "w").close()
|
open("logs/{}-server-hex.log".format(LISTEN[1]), "w").close()
|
||||||
open("logs/all-raw.log", "w").close()
|
open("logs/{}-all-raw.log".format(LISTEN[1]), "w").close()
|
||||||
open("logs/all-hex.log", "w").close()
|
open("logs/{}-all-hex.log".format(LISTEN[1]), "w").close()
|
||||||
|
|
||||||
proxy = Proxy(LISTEN, TARGET)
|
proxy = Proxy(LISTEN, TARGET)
|
||||||
proxy.start()
|
proxy.start()
|
||||||
|
|
Reference in New Issue
Block a user