pcap_sniffer

A simple CLI packet sniffer written in C

GPL-3.0 License

Stars
2

A simple and efficient packet sniffer library built using libpcap 0.8. This library provides an easy-to-use API for capturing, parsing, and analyzing network packets in real-time. It's perfect for network debugging, monitoring, and research purposes.

GETTING STARTED

IMPORTANT:

  • This program requires SUDO privileges to be run
  • To compile this source code you will need to install "libpcap0.8-dev".
  • This software is in beta stage, so it may contain a few programming errors.
  • Any help & feedback is greatly appreciated.
  • This software is under GPL3.0 license and open-source.

INSTALLATION:

  • The source code must be compiled with gcc/clang (or any other compiler)
  • You must have "libpcap0.8-dev" installed:

sudo apt install libpcap0.8-dev

  • then build with the following command (with GCC):

gcc pcap_sniffer.c pcap_functions.c print_colors.c -o pcap_sniffer -lcap

  • Enjoy the sniffer (with a lot of colors!)

USAGE:

sudo ./pcap_sniffer --help -i : interface on which to sniff -p : protocol to sniff -s : source port to filter -d <dest. port>: destination port to filter -S : source IP to filter -D <dest. IP>: destination IP to filter -r : port range (from x-y) -l: list all network interfaces -n <# of packets>: number of packet to sniff (10 by default) --help: displays this menu

EXAMPLES:

Sniffs for 100 packets on interface wlan0:

sudo ./pcap_sniffer -i wlan0 -n 100

Sniffs for 100 TCP packet on interface wlan0:

sudo ./pcap_sniffer -i wlan0 -n 100 -p tcp

SCREENSHOTS:

CONTRIBUTING:

Contributions are welcome! If you encounter any bugs or have suggestions for improvement, please submit an issue or pull request. Make sure to follow our Contributing Guidelines when submitting changes.