Sniffing & Spoofingnetworkgreppcaptrafficregexsniffing

ngrep

ngrep is a pcap-aware tool that applies GNU grep features to network traffic, allowing extended regular expressions to match packet data payloads. It supports TCP, UDP, and ICMP across various interfaces and understands BPF filter logic like tcpdump.

Description

ngrep strives to provide most of GNU grep’s common features, applying them to the network layer. It is designed for searching and matching patterns in network packet payloads using extended regular expressions. This makes it powerful for analyzing network traffic in real-time or from captures.

Use cases include protocol analysis, debugging network issues, security monitoring for specific patterns in traffic, and extracting data from packet contents. It works across Ethernet, PPP, SLIP, and null interfaces, supporting common packet sniffing workflows.

ngrep recognizes TCP, UDP, and ICMP protocols and integrates BPF filters, enabling precise traffic selection similar to tools like tcpdump and snoop.

How It Works

ngrep operates as a pcap-aware tool, capturing network packets and applying extended regular expressions to match against data payloads. It understands BPF filter logic for selecting traffic and supports TCP, UDP, and ICMP protocols across Ethernet, PPP, SLIP, and null interfaces. Matches are displayed with packet details, mimicking grep's output style on network data.

Installation

bash
sudo apt install ngrep

Flags

-his help/usage
-Vis version information
-qis be quiet (don't print packet reception hash marks)
-eis show empty packets
-iis ignore case
-Nlisted in usage
-Xlisted in usage
-d devspecify device

Examples

Display help/usage information for ngrep
ngrep -h
Read or write pcap dump file
ngrep <-IO pcap_dump>
Limit number of packets to capture
ngrep -n num
Specify network device to listen on
ngrep -d dev
Specify ASCII snaplen
ngrep -A num
Set snaplen for packet capture
ngrep -s snaplen
Match regex expression with BPF filter on network traffic
ngrep <match expression> <bpf filter>
Updated 2026-04-16kali.org ↗