mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-23 20:11:10 +00:00
packet sniffer in python
This commit is contained in:
parent
5d4309d62f
commit
cc206b3124
23
scripts/packet_sniffer/README.md
Normal file
23
scripts/packet_sniffer/README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# PACKET SNIFFER
|
||||
|
||||
Hi all! This is a packet sniffer in python.
|
||||
|
||||
## Libraries
|
||||
I have used ```scapy``` library
|
||||
|
||||
## Getting started
|
||||
1. First of all -
|
||||
```
|
||||
pip install requirements.txt
|
||||
```
|
||||
|
||||
2. Secondly -
|
||||
```
|
||||
python main.py
|
||||
```
|
||||
OR
|
||||
```
|
||||
sudo python3 main.py
|
||||
```
|
||||
|
||||
That's all. This is how we can use the packet sniffer.
|
20
scripts/packet_sniffer/main.py
Normal file
20
scripts/packet_sniffer/main.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import scapy.all as scapy
|
||||
from scapy.layers import http
|
||||
|
||||
|
||||
def sniffing(interface):
|
||||
scapy.sniff(iface=interface,
|
||||
storage=False, prn=process_packet, filter='tcp')
|
||||
|
||||
|
||||
def process_packet(packet):
|
||||
if packet.haslayer(http.HTTPRequest):
|
||||
print(packet[http.HTTPRequest].Host)
|
||||
|
||||
|
||||
def main():
|
||||
sniffing("Wi-Fi")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
1
scripts/packet_sniffer/requirements.txt
Normal file
1
scripts/packet_sniffer/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
scapy==2.4.5
|
Loading…
Reference in New Issue
Block a user