Enhance FTP packet logging to include source IP and avoid empty payload prints
This commit is contained in:
parent
fb68cd0375
commit
f3bc0c1ad0
@ -41,6 +41,7 @@ def ftp_packet_callback(packet):
|
|||||||
if packet.haslayer('IP') and packet.haslayer('TCP'):
|
if packet.haslayer('IP') and packet.haslayer('TCP'):
|
||||||
if packet['TCP'].dport == 21 or packet['TCP'].sport == 21:
|
if packet['TCP'].dport == 21 or packet['TCP'].sport == 21:
|
||||||
payload = bytes(packet['TCP'].payload).decode(errors='ignore')
|
payload = bytes(packet['TCP'].payload).decode(errors='ignore')
|
||||||
|
if payload != "":
|
||||||
print(f"the FTP payload: {payload}")
|
print(f"the FTP payload: {payload}")
|
||||||
# print(f"FTP Packet: {packet.summary()}")
|
# print(f"FTP Packet: {packet.summary()}")
|
||||||
if b"RETR" in bytes(packet['TCP'].payload):
|
if b"RETR" in bytes(packet['TCP'].payload):
|
||||||
@ -51,7 +52,8 @@ def ftp_packet_callback(packet):
|
|||||||
idx = parts.index("RETR")
|
idx = parts.index("RETR")
|
||||||
if idx + 1 < len(parts):
|
if idx + 1 < len(parts):
|
||||||
filename = parts[idx + 1]
|
filename = parts[idx + 1]
|
||||||
print(f"\033[92mFTP file download detected: {filename}\033[0m")
|
src_ip = packet['IP'].src
|
||||||
|
print(f"\033[92mFTP file download detected: {filename} from {src_ip}\033[0m")
|
||||||
|
|
||||||
def start_sniffing(interface=conf.iface):
|
def start_sniffing(interface=conf.iface):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user