A python3 wrapper around libsniff
Project description
libsniffpy
Motivation
I wanted to have a nice cython/python wrapper around libsniff. This name might confuse you, I just care about sniffing wifi packets from a nic in monitor mode.
Installation
pip install libsniffpy
Usage
Simple: Low level usage
from sniff import get_socket
# You might have to adjust
s = get_socket("wlan0mon")
# or whatever big number, forgot how big those frames are lel
raw = s.recv(3000)
Advanced: Iterate over the Radiotap frames
from sniff import get_socket, type_predicate, subtype_predicate, loop
from sys import stderr
from dpkt import ieee80211
from dpkt.radiotap import Radiotap
if __name__ == "__main__":
mgmt_predicate = type_predicate(ieee80211.MGMT_TYPE)
probe_request_predicate = subtype_predicate(ieee80211.M_PROBE_REQ)
mgmt_packets = filter(mgmt_predicate, loop("wlan0mon"))
probe_requests = filter(probe_request_predicate, mgmt_packets)
for pkg in probe_requests:
print(pkg)
Guidance for n00bs
This lib opens a raw socket for a monitor mode enabled interface. It needs privs that your user probably don't have.
Either you run this stuff as root
or you do sth like this:
sudo setcap cap_net_raw,cap_net_admin=eip
on a wrapper script that calls your python interpreter.
License
This project is licensed under the GPL-3 license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
libsniffpy-0.3.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for libsniffpy-0.3.1-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f4ca0350b4d1bdcb64345e2579a7cce9ba06545f07f78b9189dac3fc10b8085 |
|
MD5 | a5d6ad5e069b690ae48c3ddf4cd3da68 |
|
BLAKE2b-256 | 32981c4d2d50895f7ad5203e6b93134916c2d5cdd590d78b567e9c2417550f2c |