Sniffer (version 1.0.1)
index
sniffer.py

This file implements a network sniffer.
 
>>> sniffer = Sniffer(PacketPrinter())
>>> sniffer.start()
>>> sniffer.stop()
>>> sniffer = Sniffer(PacketPrinter(), "tcp port 80 or udp", "capture.pcap", None, "172.16.10.")
>>> sniffer = Sniffer(PacketPrinter(), filetoread="capture.pcap")
 
~# python3 Sniffer.py
[22/06/2022 02:53:11] WARNING  (30) {__main__ - Sniffer.py:302} Start the network sniffer on WIFI (IP: 172.16.10.55, MAC: ee:80:3d:0a:f9:2f).
<packets ...>
[22/06/2022 02:53:11] CRITICAL (50) {__main__ - Sniffer.py:312} Network traffic analysis is stopped.
~# python3 Sniffer.py -v -H -s -d -D -p -r -i -f "tcp port 80 or udp" -S capture.pcap -I 172.16.10.
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:280} Logging is configured.
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:291} PacketPrinter is created.
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:165} Start network interface detection...
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:181} Use network interface WIFI
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:300} Sniffer is created.
[22/06/2022 02:53:11] WARNING  (30) {__main__ - Sniffer.py:302} Start the network sniffer on WIFI (IP: 172.16.10.55, MAC: ee:80:3d:0a:f9:2f).
[22/06/2022 02:53:11] DEBUG    (10) {__main__ - Sniffer.py:142} Start the scapy.sendrecv.sniff function...
<packets ...>
[22/06/2022 02:53:11] INFO     (20) {__main__ - Sniffer.py:192} Save the captured traffic.
[22/06/2022 02:53:11] CRITICAL (50) {__main__ - Sniffer.py:312} Network traffic analysis is stopped.
~# python3 Sniffer.py -R capture.pcap
[22/06/2022 02:53:11] WARNING  (30) {__main__ - Sniffer.py:302} Start the network sniffer on WIFI (IP: 172.16.10.55, MAC: ee:80:3d:0a:f9:2f).
<packets ...>
[22/06/2022 02:53:11] CRITICAL (50) {__main__ - Sniffer.py:312} Network traffic analysis is stopped.

 
Modules
       
logging
scapy
sys

 
Classes
       
builtins.object
Sniffer

 
class Sniffer(builtins.object)
    Sniffer(packet_printer: PacketPrinter.PacketPrinter, filter_: str = None, savefile: str = None, filetoread: str = None, iface: str = None, **kwargs)
 
This class sniffs, filters and saves packets.
 
  Methods defined here:
__init__(self, packet_printer: PacketPrinter.PacketPrinter, filter_: str = None, savefile: str = None, filetoread: str = None, iface: str = None, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
get_iface(self) -> scapy.interfaces.NetworkInterface
This function get a NetworkInterface from iface arguments
(a string of IP or MAC address or interface name).
start(self) -> None
This function starts the network sniffer.
stop(self) -> None
This function stops the sniffer and writes
the pcap file to save the package.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
main() -> None
This function start the network
sniffer from the command line.

 
Data
        __all__ = ['Sniffer', 'main']
__annotations__ = {'logger': <class 'logging.Logger'>}
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nPacketAnalysis Copyright (C) 2021 Maurice Lam...ome to redistribute it\nunder certain conditions.\n'
__description__ = '\nThis file implements a network sniffer.\n'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/PacketAnalysis'

 
Author
        Maurice Lambert