Sniffing & Spoofingnetworkpacketeditormanipulationforgingauditingfuzzing

netsed

NetSED is a network packet-altering stream editor that modifies the contents of packets in real time as they are forwarded through the network. It supports tasks like protocol auditing, fuzzing, integrity testing, and content filtering.

Description

NetSED is a small utility designed to alter, forge, or manipulate network packets in real time. It is particularly useful for black-box protocol auditing where proprietary systems communicate using undocumented protocols, allowing testers to enforce changes in transmissions to assess application security. Additional use cases include fuzz generating experiments and integrity tests to evaluate application stability and data handling.

Common applications also encompass deceptive transfers, content filtering, and protocol conversion, making it versatile for various network manipulation tasks. It complements tools like ngrep, netcat, and tcpdump in a testing suite.

The tool operates by intercepting traffic on specified local ports and forwarding modified packets to remote hosts, applying user-defined replacement rules to packet contents.

How It Works

NetSED listens on a local port (lport) for specified protocols (tcp or udp), forwards connections to a remote host (rhost) and port (rport), and applies sed-like replacement rules (s/pat1/pat2[/expire]) to matching packets. Rules replace occurrences of pat1 with pat2, with optional expiration after NUM substitutions (e.g., /1 for first occurrence). Direction restrictions use CHAR 'iIoO' for incoming/outgoing packets from client perspective. Rules evaluate sequentially per connection, not across packet boundaries, supporting hex escapes for special characters.

Installation

bash
sudo apt install netsed

Flags

--ipv4Force address resolution in IPv4
-4Force address resolution in IPv4
--ipv6Force address resolution in IPv6
-6Force address resolution in IPv6
--ipanyResolve the address in either IPv4 or IPv6
--helpDisplay usage information
-hDisplay usage information

Examples

Replace 'andrew' with 'mike' only the first time
netsed 's/andrew/mike/1'
Replace all occurrences of 'andrew' with 'mike'
netsed 's/andrew/mike'
Replace 'andrew' with 'mike\x00\x00' (padding to keep original size)
netsed 's/andrew/mike%00%00'
Replace the first 20 occurrences of '%' with '/'
netsed 's/%%/%2f/20'
Server always sees 'mike', never 'andrew' (outgoing only)
netsed 's/andrew/mike/o'
Let Rilke travel incognito as Proust (outgoing to Proust, incoming to Rilke)
netsed 's/Rilke/Proust/o s/Proust/Rilke/i'
Display usage information
netsed -h
Updated 2026-04-16kali.org ↗