-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterceptor.py
44 lines (37 loc) · 1.42 KB
/
interceptor.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
from serializer import deserialize, is_serialized, token
import time
import csv
def interceptor(d: bytes, a_src: list) -> bytes:
try:
data = deserialize(d) if is_serialized(d) else token(d)
if (
d.isascii()
and (data[0].upper() == b"AUTH" and 2 <= len(data) <= 3)
or (
(
data[0].upper() == b"HELLO"
and data[2].upper() == b"AUTH"
and len(data) == 5
)
)
):
if len(data) == 3:
row = [a_src[0], data[1].decode(), data[2].decode()]
elif len(data) == 5:
row = [a_src[0], data[3].decode(), data[4].decode()]
else:
row = [a_src[0], "", data[1].decode()]
print(f"{a_src[0]}:{a_src[1]} >", row)
with open("auth.log", "a") as f:
wr = csv.writer(f, quoting=csv.QUOTE_ALL)
wr.writerow(row)
print(f"{a_src[0]}:{a_src[1]} >", d[:50])
with open(f"payload_{a_src[0]}:{a_src[1]}_{int(time.time())}.log", "ab") as f:
f.write(d)
except Exception as e:
with open("err.log", "ab") as f:
f.write(b"------------------------------------------------------\n")
f.write(b"IP: " + a_src[0].encode() + b"\n")
f.write(b"ERR: " + str(e).encode() + b"\n")
f.write(d + b"\n")
return d