bpfc

title: bpfc(8)

text:
# bpfc(8)

## NAME
bpfc - a Berkeley Packet Filter assembler and compiler

## SYNOPSIS
bpfc { [options] | [source-file] }

## DESCRIPTION
bpfc is a small Berkeley Packet Filter assembler and compiler which is able to translate BPF assembler-like mnemonics into a numerical or C-like format, that can be read by tools such as netsniff-ng, iptables (xt_bpf) and many others. BPF is the one and only upstream filtering construct that is used in combination with packet(7) sockets, but also seccomp-BPF for system call sandboxing.

The Linux kernel and also BSD kernels implement "virtual machine" like constructs and JIT compilers that mimic a small register-based machine in BPF architecture and execute filter code that is, for example, composed by bpfc on a data buffer that is given by network packets. The purpose of this is to shift computation in time, so that the kernel can drop or truncate incoming packets as early as possible without having to push them to user space for further analysis first. Meanwhile, BPF constructs also find application in other areas such as in the communication between user and kernel space like system call sand-boxing.

At the time of writing this man page, the only other available BPF compiler is part of the pcap(3) library and accessible through a high-level filter language that might be familiar to many people as tcpdump-like filters.

However, it is quite often useful to bypass that compiler and write optimized code that cannot be produced by the pcap(3) compiler, or is wrongly optimized, or is defective on purpose in order to debug test kernel code. Also, a reason to use bpfc could be to try out some new BPF extensions that are not supported by other compilers. Furthermore, bpfc can be useful to verify JIT compiler behavior or to find possible bugs that need to be fixed.

bpfc is implemented with the help of flex(1) and bison(1), tokenizes the source file in the first stage and parses its content into an AST. In two code generation stages it emits target opcodes. bpfc furthermore supports Linux kernel BPF extensions. More about that can be found in the syntax section.

The Linux kernel BPF JIT compiler is automatically turned on if detected by netsniff-ng. However, it can also be manually turned on through the command ''echo "1" > /proc/sys/net/core/bpf_jit_enable'' (normal working mode) or ''echo "2" > /proc/sys/net/core/bpf_jit_enable'' (debug mode where emitted opcodes of the image are printed to the kernel log). An architecture agnostic BPF JIT image disassembler can be found in the kernel source tree under ''tools/net/bpf_jit_disasm.c'' or within the netsniff-ng Git repository.

## OPTIONS
-i <source-file/->, --input <source-file/->

Read BPF assembly instruction from an input file or from stdin.

-p, --cpp

Pass the bpf program through the C preprocessor before reading it in bpfc. This allows #define and #include directives (e.g. to include definitions from system headers) to be used in the bpf program.

-D <name>=<definition>, --define <name>=<definition>

Add macro definition for the C preprocessor to use it within bpf file. This option is used in combination with the -p/--cpp option.

-f <format>, --format <format>

Specify a different output format than the default that is netsniff-ng compatible. The <format> specifier can be: C, netsniff-ng, xt_bpf, tcpdump.

-b, --bypass

Bypass basic filter validation when emitting opcodes. This can be useful for explicitly creating malformed BPF expressions for injecting into the kernel, for example, for bug testing.

-V, --verbose

Be more verbose and display some bpfc debugging information.

-d, --dump

Dump all supported instructions to stdout.

-v, --version

Show version information and exit.

-h, --help

Show user help and exit.

## SYNTAX
The BPF architecture resp. register machine consists of the following elements:

Element Description

A 32 bit wide accumulator

X 32 bit wide X register

M[] 16 x 32 bit wide misc registers aka “scratch memory store”, addressable from 0 to 15

A program, that is translated by bpfc into ''opcodes'' is an array that consists of the following elements:

o:16, jt:8, jf:8, k:32

The element o is a 16 bit wide opcode that has a particular instruction encoded, jt and jf are two 8 bit wide jump targets, one for condition

''true'', one for condition ''false''. Last but not least the 32 bit wide element k contains a miscellaneous argument that can be interpreted in different ways depending on the given instruction resp. opcode.

The instruction set consists of load, store, branch, alu, miscellaneous and return instructions that are also represented in bpfc syntax. This table also includes bpfc's own extensions. All operations are based on unsigned data structures:

Instruction Addressing mode Description

ld 1, 2, 3, 4, 10 Load word into A

ldi 4 Load word into A

ldh 1, 2 Load half-word into A

ldb 1, 2 Load byte into A

ldx 3, 4, 5, 10 Load word into X

ldxi 4 Load word into X

ldxb 5 Load byte into X

st 3 Copy A into M[]

stx 3 Copy X into M[]

jmp 6 Jump to label

ja 6 Jump to label

jeq 7, 8 Jump on k == A

jneq 8 Jump on k != A

jne 8 Jump on k != A

jlt 8 Jump on k < A

jle 8 Jump on k <= A

jgt 7, 8 Jump on k > A

jge 7, 8 Jump on k >= A

jset 7, 8 Jump on k & A

add 0, 4 A + <x>

sub 0, 4 A - <x>

mul 0, 4 A * <x>

div 0, 4 A / <x>

mod 0, 4 A % <x>

neg 0, 4 !A

and 0, 4 A & <x>

or 0, 4 A | <x>

xor 0, 4 A ^ <x>

lsh 0, 4 A << <x>

rsh 0, 4 A >> <x>

tax Copy A into X

txa Copy X into A

ret 4, 9 Return

Addressing mode Syntax Description

0 x/%x Register X

1 [k] BHW at byte offset k in the packet

2 [x + k] BHW at the offset X + k in the packet

3 M[k] Word at offset k in M[]

4 #k Literal value stored in k

5 4*([k]&0xf) Lower nibble * 4 at byte offset k in the packet

6 L Jump label L

7 #k,Lt,Lf Jump to Lt if true, otherwise jump to Lf

8 #k,Lt Jump to Lt if predicate is true

9 a/%a Accumulator A

10 extension BPF extension (see next table)

Extension (and alias) Description

\#len, len, #pktlen, pktlen Length of packet (skb->len)

\#pto, pto, #proto, proto Ethernet type field (skb->protocol)

\#type, type Packet type (**) (skb->pkt_type)

\#poff, poff Detected payload start offset

\#ifx, ifx, #ifidx, ifidx Interface index (skb->dev->ifindex)

\#nla, nla Netlink attribute of type X with offset A

\#nlan, nlan Nested Netlink attribute of type X with offset A

\#mark, mark Packet mark (skb->mark)

\#que, que, #queue, queue, #Q, Q NIC queue index (skb->queue_mapping)

\#hat, hat, #hatype, hatype NIC hardware type (**) (skb->dev->type)

\#rxh, rxh, #rxhash, rxhash Receive hash (skb->rxhash)

\#cpu, cpu Current CPU (raw_smp_processor_id())

\#vlant, vlant, #vlan_tci, vlan_tci VLAN TCI value (vlan_tx_tag_get(skb))

\#vlanp, vlanp VLAN present (vlan_tx_tag_present(skb))

Further extension details (**) Value

\#type, type 0 - to us / host

1 - to all / broadcast

2 - to group / multicast

3 - to others (promiscuous mode)

4 - outgoing of any type

\#hat, hat, #hatype, hatype 1 - Ethernet 10Mbps

8 - APPLEtalk

19 - ATM

24 - IEEE 1394 IPv4 - RFC 2734

32 - InfiniBand

768 - IPIP tunnel

769 - IP6IP6 tunnel

772 - Loopback device

778 - GRE over IP

783 - Linux-IrDA

801 - IEEE 802.11

802 - IEEE 802.11 + Prism2 header

803 - IEEE 802.11 + radiotap header

823 - GRE over IP6

824 - Netlink

[...] See include/uapi/linux/if_arp.h

Note that the majority of BPF extensions are available on Linux only.

There are two types of comments in bpfc source-files:

1. Multi-line C-style comments: /* put comment here */

2. Single-line ASM-style comments: ; put comment here

Used Abbreviations:

BHW: byte, half-word, or word

## SOURCE EXAMPLES
In this section, we give a couple of examples of bpfc source files, in other words, some small example filter programs:

Only return packet headers (truncate packets):

ld poff

ret a

Only allow ARP packets:

ldh [12]

jne #0x806, drop

ret #-1

drop: ret #0

Only allow IPv4 TCP packets:

ldh [12]

jne #0x800, drop

ldb [23]

jneq #6, drop

ret #-1

drop: ret #0

Only allow IPv4 TCP SSH traffic:

ldh [12]

jne #0x800, drop

ldb [23]

jneq #6, drop

ldh [20]

jset #0x1fff, drop

ldxb 4 * ([14] & 0xf)

ldh [x + 14]

jeq #0x16, pass

ldh [x + 16]

jne #0x16, drop

pass: ret #-1

drop: ret #0

A loadable x86_64 seccomp-BPF filter to allow a given set of syscalls:

ld [4] /* offsetof(struct seccomp_data, arch) */

jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */

ld [0] /* offsetof(struct seccomp_data, nr) */

jeq #15, good /* __NR_rt_sigreturn */

jeq #231, good /* __NR_exit_group */

jeq #60, good /* __NR_exit */

jeq #0, good /* __NR_read */

jeq #1, good /* __NR_write */

jeq #5, good /* __NR_fstat */

jeq #9, good /* __NR_mmap */

jeq #14, good /* __NR_rt_sigprocmask */

jeq #13, good /* __NR_rt_sigaction */

jeq #35, good /* __NR_nanosleep */

bad: ret #0 /* SECCOMP_RET_KILL */

good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */

Allow any (hardware accelerated) VLAN:

ld vlanp

jeq #0, drop

ret #-1

drop: ret #0

Only allow traffic for (hardware accelerated) VLAN 10:

ld vlant

jneq #10, drop

ret #-1

drop: ret #0

More pedantic check for the above VLAN example:

ld vlanp

jeq #0, drop

ld vlant

jneq #10, drop

ret #-1

drop: ret #0

Filter rtnetlink messages:

ldh #proto /* A = skb->protocol */

jneq #0, skip /* check for NETLINK_ROUTE */

ldb [4] /* A = nlmsg_type */

jneq #0x10, skip /* check type == RTNL_NEWLINK */

ldx #16 /* X = offset(ifinfomsg) */

ldb [x + 4] /* offset(ifi_index) */

jneq #0x3, skip /* check ifindex == 3 */

ld #32 /* A = len(nlmsghdr) + len(ifinfomsg), payload offset */

ldx #16 /* X = IFLA_OPERSTATE */

ld #nla /* A = offset(IFLA_OPERSTATE) */

jeq #0, skip

tax

ldb [x + 4] /* A = value(IFLA_OPERSTATE) */

jneq #0x6, skip /* check oper state is UP */

ret #-1

skip: ret #0

## USAGE EXAMPLE
bpfc fubar

Compile the source file ''fubar'' into BPF opcodes. Opcodes will be directed to stdout.

bpfc -f xt_bpf -b -p -i fubar, resp. iptables -A INPUT -m bpf --bytecode `bpfc -f xt_bpf -i fubar` -j LOG

Compile the source file ''fubar'' into BPF opcodes, bypass basic filter validation and emit opcodes in netfilter's xt_bpf readable format. Note that the source file ''fubar'' is first passed to the C preprocessor for textual replacements before handing over to the bpfc compiler.

cat fubar | bpfc -

Read bpfc instruction from stdin and emit opcodes to stdout.

bpfc foo > bar && netsniff-ng -f bar ...

Compile filter instructions from file foo and redirect bpfc's output into the file bar, that can then be read by netsniff-ng(8) through option -f.

bpfc -f tcpdump -i fubar

Output opcodes from source file fubar in the same behavior as ''tcpdump -ddd''.

## LEGAL
bpfc is licensed under the GNU GPL version 2.0.

## HISTORY
bpfc was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.

## SEE ALSO
netsniff-ng(8), trafgen(8), mausezahn(8), ifpps(8), flowtop(8), astraceroute(8), curvetun(8)

## AUTHOR
Manpage was written by Daniel Borkmann.

## COLOPHON
This page is part of the Linux netsniff-ng toolkit project. A description of the project, and information about reporting bugs, can be found at http://netsniff-ng.org/.


curvetun

package: netsniff-ng

title: curvetun(8)

summary: a lightweight curve25519 ip4/6 tunnel

text:
# curvetun(8)

## NAME
curvetun - a lightweight curve25519 ip4/6 tunnel

## SYNOPSIS
curvetun [options]

## DESCRIPTION
curvetun is a lightweight, high-speed ECDH multiuser IP tunnel for Linux that is based on epoll(2). curvetun uses the Linux TUN/TAP interface and supports {IPv4, IPv6} over {IPv4, IPv6} with UDP or TCP as carrier protocols.

It has an integrated packet forwarding tree, thus multiple users with different IPs can be handled via a single tunnel device on the server side, and flows are scheduled for processing in a CPU efficient way, at least in the case of TCP as the carrier protocol.

For key management, public-key cryptography based on elliptic curves are used and packets are encrypted end-to-end by the symmetric stream cipher Salsa20 and authenticated by the MAC Poly1305, where keys have previously been computed with the ECDH key agreement protocol Curve25519.

Cryptography is based on Daniel J. Bernstein's networking and cryptography library “NaCl”. By design, curvetun does not provide any particular pattern or default port numbers that gives certainty that the connection from a particular flow is actually running curvetun.

However, if you have a further need to bypass censorship, you can try using curvetun in combination with Tor's obfsproxy or Telex. Furthermore, curvetun also protects you against replay attacks and DH man-in-the-middle attacks. Additionally, server-side syslog event logging can also be disabled to avoid revealing critical user connection data.

1.

obfsproxy from the TOR project

https://www.torproject.org/projects/obfsproxy.html.en

2.

Telex, anti-censorship in the network infrastructure

https://telex.cc/

## OPTIONS
-d <tundev>, --dev <tundev>

Defines the name of the tunnel device that is being created. If this option is not set, then the default names, curves{0,1,2,..} for a curvetun server, and curvec{0,1,2,...} for a curvetun client are used.

-p <num>, --port <num>

Defines the port the curvetun server should listen on. There is no default port for curvetun, so setting this option for server bootstrap is mandatory. This option is for servers only.

-t <server>, --stun <server>

If needed, this options enables an STUN lookup in order to show public IP to port mapping and to punch a hole into the firewall. In case you are unsure what STUN server to use, simply use ''--stun stunserver.org''.

-c[=alias], --client[=alias]

Starts curvetun in client mode and connects to the given connection alias that is defined in the configuration file.

-k, --keygen

Generate private and public keypair. This must be done initially.

-x, --export

Export user and key combination to stdout as a one-liner.

-C, --dumpc

Dump all known clients that may connect to the local curvetun server and exit.

-S, --dumps

Dump all known servers curvetun as a client can connect to, and exit.

-D, --nofork

Do not fork off as a client or server on startup.

-s, --server

Start curvetun in server mode. Additional parameters are needed, at least the definition of the port that clients can connect to is required.

-N, --no-logging

Disable all curvetun logging of user information. This option can be used to enable curvetun users to connect more anonymously. This option is for servers only.

-u, --udp

Use UDP as a carrier protocol instead of TCP. By default, TCP is the carrier protocol. This option is for servers only.

-4, --ipv4

Defines IPv4 as the underlying network protocol to be used on the tunnel device. IPv4 is the default. This option is for servers only.

-6, --ipv6

Defines IPv6 as the underlying network protocol to be used on the tunnel device. This option is for servers only.

-v, --version

Show version information and exit.

-h, --help

Show user help and exit.

## USAGE EXAMPLE
curvetun --server -4 -u -N --port 6666 --stun stunserver.org

Starts curvetun in server mode with IPv4 as network protocol and UDP as a transport carrier protocol. The curvetun server listens for incoming connections on port 6666 and performs an STUN lookup on startup to stunserver.org.

curvetun --client=ethz

Starts curvetun in client mode and connects to the defined connection alias ''ethz'' that is defined in the curvetun ~/.curvetun/servers configuration file.

curvetun --keygen

Generates initial keypairs and stores them in the ~/.curvetun/ directory.

curvetun --export

Export user data to stdout for configuration of a curvetun server.

## CRYPTOGRAPHY
Encrypted IP tunnels are often used to create virtual private networks (VPN), where parts of the network can only be reached via an insecure or untrusted medium such as the Internet. Only a few software utilities exist to create such tunnels, or, VPNs. Two popular representatives of such software are OpenVPN and VTUN.

The latter also introduced the TUN/TAP interfaces into the Linux kernel. VTUN only has a rather basic encryption module, that does not fit today's cryptographic needs. By default, MD5 is used to create 128-Bit wide keys for the symmetric BlowFish cipher in ECB mode [1].

Although OpenSSL is used in both VTUN and OpenVPN, OpenVPN is much more feature rich regarding ciphers and user authentication. Nevertheless, letting people choose ciphers or authentication methods is not necessarily a good thing: administrators could either prefer speed over security and therefore choose weak ciphers, so that the communication system will be as good as without any cipher; they could choose weak passwords for symmetric encryption or they could misconfigure the communication system by having too much choice of ciphers and too little experience for picking the right one.

Next to the administration issues, there are also software development issues. Cryptographic libraries like OpenSSL are a huge mess and too low-level and complex to fully understand or correctly apply, so that they form further ground for vulnerabilities of such software.

In 2010, the cryptographers Tanja Lange and Daniel J. Bernstein have therefore created and published a cryptographic library for networking, which is named NaCl (pronounced ''salt''). NaCl addresses such problems as mentioned in OpenSSL and, in contrast to the rather generic use of OpenSSL, was created with a strong focus on public-key authenticated encryption based on elliptic curve cryptography, which is used in curvetun. Partially quoting Daniel J. Bernstein:

"RSA is somewhat older than elliptic-curve cryptography: RSA was introduced in 1977, while elliptic-curve cryptography was introduced in 1985. However, RSA has shown many more weaknesses than elliptic-curve cryptography. RSA's effective security level was dramatically reduced by the linear sieve in the late 1970s, by the quadratic sieve and ECM in the 1980s, and by the number-field sieve in the 1990s. For comparison, a few attacks have been developed against some rare elliptic curves having special algebraic structures, and the amount of computer power available to attackers has predictably increased, but typical elliptic curves require just as much computer power to break today as they required twenty years ago.

IEEE P1363 standardized elliptic-curve cryptography in the late 1990s, including a stringent list of security criteria for elliptic curves. NIST used the IEEE P1363 criteria to select fifteen specific elliptic curves at five different security levels. In 2005, NSA issued a new ''Suite B'' standard, recommending the NIST elliptic curves (at two specific security levels) for all public-key cryptography and withdrawing previous recommendations of RSA."

curvetun uses a particular elliptic curve, Curve25519, introduced in the following paper: Daniel J. Bernstein, ''Curve25519: new Diffie-Hellman speed records,'' pages 207-228 in Proceedings of PKC 2006, edited by Moti Yung, Yevgeniy Dodis, Aggelos Kiayias, and Tal Malkin, Lecture Notes in Computer Science 3958, Springer, 2006, ISBN 3-540-33851-9.

This elliptic curve follows all of the standard IEEE P1363 security criteria. It also follows new recommendations that achieve ''side-channel immunity'' and ''twist security'' while improving speed. What this means is that secure implementations of Curve25519 are considerably simpler and faster than secure implementations of, for example, NIST P-256; there are fewer opportunities for implementors to make mistakes that compromise security, and mistakes are more easily caught by reviewers.

An attacker who spends a billion dollars on special-purpose chips to attack Curve25519, using the best attacks available today, has about 1 chance in 1000000000000000000000000000 of breaking Curve25519 after a year of computation. One could achieve similar levels of security with 3000-bit RSA, but encryption and authentication with 3000-bit RSA are not nearly fast enough to handle tunnel traffic and would require much more space in network packets.

1.

Security analysis of VTun

http://www.off.net/~jme/vtun_secu.html

2.

NaCl: Networking and Cryptography library

http://nacl.cr.yp.to/

## SETUP HOWTO
If you have not run curvetun before, you need to do an initial setup once.

First, make sure that the servers and clients clocks are periodically synced, for example, by running an NTP daemon. This is necessary to protect against replay attacks. Also, make sure you have read and write access to /dev/net/tun. You should not run curvetun as root! Then, after you have assured this, the first step is to generate keys and config files. On both the client and server do:

curvetun -k

You are asked for a user name. You can use an email address or whatever suits you. Here, we assume you have entered 'mysrv1' on the server and 'myclient1' on the client side.

Now, all necessary files have been created under ~/.curvetun. Files include “priv.key”, “pub.key”, “username”, “clients” and “servers”.

“clients” and “servers” are empty at the beginning and need to be filled. The “clients” file is meant for the server, so that it knows what clients are allowed to connect. The “servers” file is for the client, where it can select curvetun servers to connect to. Both files are kept very simple, so that a single configuration line per client or server is sufficient.

The client needs to export its public key data for the server

curvetun -x

where it prints a string in the following format:

myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11

\_______/ \_____________________________________________________________________________________________/

username 32 byte public key for 'myclient1'

This line is transferred to the server admin (yes, we assume a manual on-site key exchange scenario where, for example, the admin sets up server and clients), where the admin then adds this entry into his ''clients'' file like:

server$ echo "myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:" \

"11:11:11:11:11:11:11:11:11:11:11:11:11:11:11" >> ~/.curvetun/clients

The server admin can check if the server has registered it properly as follows:

server$ curvetun -C

which prints all parsed clients from ''~/.curvetun/clients''. This process could easily be automated or scripted with, for example, Perl and LDAP.

Now, the client ''myclient1'' is known to the server; that completes the server configuration. The next step is to tell the client where it needs to connect to the server.

We assume in this example that the tunnel server has a public IP address, e.g. 1.2.3.4, runs on port 6666 and uses UDP as a carrier protocol. In case you are behind NAT, you can use curvetun's ''--stun'' option for starting the server, to obtain your mapping. However, in this example we continue with 1.2.3.4 and 6666, UDP.

First, the server needs to export its key to the client, as follows:

server$ curvetun -x

where it prints a string in the following format:

mysrv1;22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22

\____/ \_____________________________________________________________________________________________/

username 32 byte public key for 'mysrv1'

^-- you need this public key

Thus, you now have the server IP address, server port, server transport protocol and the server's public key at hand. On the client side it can be put all together in the config as follows:

client$ echo "myfirstserver;1.2.3.4;6666;udp;22:22:22:22:22:22:22:22:22:22:" \

"22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:" \

"22:22" >> ~/.curvetun/servers

The client can check its config using:

client$ curvetun -S

Then we start the server with:

server$ curvetun -s -p 6666 -u

server# ifconfig curves0 up

server# ifconfig curves0 10.0.0.1/24

Then, we start the client with:

client$ curvetun -c=myfirstserver

client# ifconfig curvec0 up

client# ifconfig curvec0 10.0.0.2/24

Also, client-side information, errors, or warnings will appear in syslog! By now we should be able to ping the server:

client$ ping 10.0.0.1

That's it! Routing example:

Server side's public IP on eth0 is, for example, 1.2.3.4:

server$ ... start curvetun server ...

server# ifconfig curves0 up

server# ifconfig curves0 10.0.0.1/24

server# echo 1 > /proc/sys/net/ipv4/ip_forward

server# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

server# iptables -A FORWARD -i eth0 -o curves0 -m state --state RELATED,ESTABLISHED -j ACCEPT

server# iptables -A FORWARD -i curves0 -o eth0 -j ACCEPT

Client side's IP on eth0 is, for example, 5.6.7.8:

client$ ... start curvetun client ...

client# ... lookup your default gateway (e.g. via route, here: 5.6.7.9) ...

client# ifconfig curvec0 up

client# ifconfig curvec0 10.0.0.2/24

client# route add -net 1.2.3.0 netmask 255.255.255.0 gw 5.6.7.9 dev eth0

client# route add default gw 10.0.0.1

client# route del default gw 5.6.7.9

That should be it, happy browsing and emailing via curvetun tunnels!

## NOTE
This software is an experimental prototype intended for researchers. It will most likely mature over time, but it is currently not advised to use this software when life is put at risk.

## BUGS
Blackhole tunneling is currently not supported.

## LEGAL
curvetun is licensed under the GNU GPL version 2.0.

## HISTORY
curvetun was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.

## SEE ALSO
netsniff-ng(8), trafgen(8), mausezahn(8), bpfc(8), ifpps(8), flowtop(8), astraceroute(8)

## AUTHOR
Manpage was written by Daniel Borkmann.

## COLOPHON
This page is part of the Linux netsniff-ng toolkit project. A description of the project, and information about reporting bugs, can be found at http://netsniff-ng.org/.


flowtop

title: flowtop(8)

text:
# flowtop(8)

## NAME
flowtop - top-like netfilter TCP/UDP/SCTP/DCCP/ICMP(v6) flow tracking

## SYNOPSIS
flowtop { [options] }

## DESCRIPTION
flowtop is a top-like connection tracking tool that can run on an end host or small home router. It is able to present TCP, UDP/UDP-lite, SCTP, DCCP, and ICMP(v6) flows that have been collected by the kernel's netfilter connection tracking framework, thus no packet capturing in user space needs to be done.

flowtop is able to give you a quick overview of current connections on your local system, e.g. for debugging purposes or to answer questions like:

* If you access website X, what other connections are being opened in

the background that I'm not aware of?

* What connections are active that pass one's router?

* I have this proprietary binary Y, to where does it connect?

* To which countries am I sending data?

* Are there any suspicious background connections on my machine?

* How many active connections does binary Y have?

* How long are connections active already?

* At which rate am I sending/receiving data?

The following information will be presented in flowtop's output:

* Application name and PID when run on local machine

* Reverse DNS for source and destination

* Geo-location information (country, city)

* Used protocols (IPv4, IPv6, TCP, UDP, SCTP, ICMP, ...)

* Flow port's service name heuristic

* Transport protocol state machine information

* Byte/packet counters (if they are enabled)

* Connection duration (if timestamping is enabled)

* Flow send/receive rate (if byte/packet counters are enabled)

In order for flowtop to work, netfilter must be active and running on your machine, thus kernel-side connection tracking is active. If netfilter is not running, you can activate it with iptables(8):

iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT

iptables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT

or by loading the following kernel modules:

modprobe nf_conntrack_ipv4

modprobe nf_conntrack_ipv6

To dump byte/packet counters flowtop enables the sysctl(8) parameter net.netfilter.nf_conntrack_acct via:

echo 1 > /proc/sys/net/netfilter/nf_conntrack_acct

and resets it to the previously set value on exit. These counters will only be active on connections which were created after accounting was enabled. Thus, to have these counters be active all the time the parameter should be enabled after the system is up. To automatically enable it, sysctl.conf(8) or sysctl.d(8) might be used.

To calculate the connection duration flowtop enables the sysctl(8) parameter net.netfilter.nf_conntrack_timestamp via:

echo 1 > /proc/sys/net/netfilter/nf_conntrack_timestamp

and resets it to the previously set value on exit.

flowtop's intention is just to get a quick look over your active connections. If you want logging support, have a look at netfilter's conntrack(8) tools instead.

## OPTIONS
-4, --ipv4

Display IPv4 flows. That is the default when flowtop is started without any arguments.

-6, --ipv6

Display IPv6 flows. That is the default when flowtop is started without any arguments.

-T, --tcp

Display TCP flows. That is the default when flowtop is started without any arguments.

-U, --udp

Display UDP and UDP-lite flows.

-D, --dccp

Display DCCP flows.

-I, --icmp

Display ICMP version 4 and version 6 flows.

-S, --sctp

Display SCTP flows.

-n, --no-dns

Don't perform hostname lookup. Only numeric addresses will be shown for flow endpoints.

-G, --no-geoip

Don't perform GeoIP lookup. No geographical information will be shown for flow endpoints.

-s, --show-src

Also show source information of the flow, not only destination information.

-b, --bits

Show flow rates in bits per second instead of bytes per second.

-u, --update

The built-in database update mechanism will be invoked to get Maxmind's latest database. To configure search locations for databases, the file /etc/netsniff-ng/geoip.conf contains possible addresses. Thus, to save bandwidth or for mirroring Maxmind's databases (to bypass their traffic limit policy), different hosts or IP addresses can be placed into geoip.conf, separated by a newline.

-t <time>, --interval <time>

Flow info refresh interval in seconds, default is 1s.

-v, --version

Show version information and exit.

-h, --help

Show user help and exit.

## USAGE EXAMPLE
flowtop

Default ncurses output for flowtop that tracks IPv4, IPv6 flows for TCP.

flowtop -46UTDISs

This example enables the maximum display options for flowtop.

## CONFIG FILES
Files under /etc/netsniff-ng/ can be modified to extend flowtop's service resolution and lookup information.

* tcp.conf - TCP port/services map

* udp.conf - UDP port/services map

* geoip.conf - GeoIP database mirrors

## BUGS
With a fairly high rate of connection tracking updates, flowtop can become unresponsive for short periods of time while scrolling. The right fix would be to replace flowtop's connection management backend with a better design with respect to the locking approach. This is still on the "todo" list.

## LEGAL
flowtop is licensed under the GNU GPL version 2.0.

## HISTORY
flowtop was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.

## SEE ALSO
netsniff-ng(8), trafgen(8), mausezahn(8), ifpps(8), bpfc(8), astraceroute(8), curvetun(8), iptables(8), sysctl(8), sysctl.conf(8), sysctl.d(8)

## AUTHOR
Manpage was written by Daniel Borkmann.

## COLOPHON
This page is part of the Linux netsniff-ng toolkit project. A description of the project, and information about reporting bugs, can be found at http://netsniff-ng.org/.


ifpps

title: ifpps(8)

text:
# ifpps(8)

## NAME
ifpps - top-like networking and system statistics

## SYNOPSIS
ifpps { [options] | [device] }

## DESCRIPTION
ifpps is a small utility which periodically provides top-like networking and system statistics from the kernel. ifpps gathers its data directly from procfs files and does not make use of any user space monitoring libraries which would falsify statistics under high load.

For instance, consider the following scenario: two directly connected Linux machines with Intel Core 2 Quad Q6600 2.40GHz CPUs, 4 GB RAM, and an Intel 82566DC-2 Gigabit Ethernet NIC are used for performance evaluation. One machine generates 64 byte network packets by using the kernel space packet generator pktgen with a maximum possible packet rate. The other machine displays statistics about incoming network packets by using i) iptraf(8) and ii) ifpps.

iptraf which incorporates pcap(3) shows an average packet rate of 246,000 pps while on the other hand ifpps shows an average packet rate of 1,378,000 pps. Hence, due to packet copies and deferring statistics creation into user space, a measurement error of approximately 460 percent occurs. Tools like iptraf might display much more information such as TCP per flow statistics (hence the use of the pcap library). This is not possible with ifpps, because overall networking statistics are its focus; statistics, which are also fairly reliable under high packet load.

ifpps also periodically displays CPU load, interrupt, software interrupt data per sample interval as well as total interrupts, all per CPU. In case the number of CPUs exceeds 5 or the number specified by the user with the -n command line option, ifpps will only display this number top heavy hitters. The topmost heavy hitter CPU will be marked with “+”. The least heavy hitter will always be displayed and is marked with “-”. In addition, the average for all the above per-CPU data is shown. Optionally the median values can be displayed using the -m command line option.

ifpps also supports directly the gnuplot(1) data sample format. This facilitates creation of gnuplot figures from ifpps time series.

## OPTIONS
-d <netdev>, --dev <netdev>

Networking device to fetch statistics from, for example eth0, wlan0.

-n, --num-cpus

Set maximum number of top hitter CPUs (in terms of time spent in system/user mode) to display in ncurses mode, default is 10.

-t <time>, --interval <time>

Statistics refresh interval in milliseconds, default is 1000ms.

-c, --csv

Output (once) the ncurses data to the terminal as gnuplot(1)-ready data.

-l, --loop

Continuously output the terminal data after a refresh interval. This option is only available if option -c is given. For -l it is usually recommended to redirect the output into a file that is to be processed later with gnuplot(1).

-m, --median

Show median values across all CPUs for CPU load, interrupts (per interval and absolute) and software interrupts.

-o, --omit-header

Omit printing the CSV header. This option is only available if -c is given.

-p, --promisc

Turn on promiscuous mode for the given networking device.

-P, --percentage

Show percentage of current throughput in relation to theoretical line rate.

-W, --no-warn

Suppress possible warnings in the ncurses output, e.g. about a too low sampling interval that could cause performance regression.

-v, --version

Show version information.

-h, --help

Show user help.

## USAGE EXAMPLE
ifpps eth0

Default ncurses output for the eth0 device.

ifpps -pd eth0

Ncurses output for the eth0 device in promiscuous mode.

ifpps -lpcd wlan0 > plot.dat

Continuous terminal output for the wlan0 device in promiscuous mode.

## NOTE
On 10Gbit/s cards or higher, receive and transmit statistics are usually accumulated at a higher duration interval than 1 second. Thus, it might be advisable to alter the timing to a higher accumulation interval for such cards.

## LEGAL
ifpps is licensed under the GNU GPL version 2.0.

## HISTORY
ifpps was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.

## SEE ALSO
netsniff-ng(8), trafgen(8), mausezahn(8), bpfc(8), flowtop(8), astraceroute(8), curvetun(8)

## AUTHOR
Manpage was written by Daniel Borkmann.

## COLOPHON
This page is part of the Linux netsniff-ng toolkit project. A description of the project, and information about reporting bugs, can be found at http://netsniff-ng.org/.


mausezahn

title: mausezahn(8)

text:
# mausezahn(8)

## NAME
mausezahn - a fast versatile packet generator with Cisco-cli

## SYNOPSIS
mausezahn { [options] "<arg-string> | <hex-string>" }

## DESCRIPTION
mausezahn is a fast traffic generator which allows you to send nearly every possible and impossible packet. In contrast to trafgen(8), mausezahn's packet configuration is on a protocol-level instead of byte-level and mausezahn also comes with a built-in Cisco-like command-line interface, making it suitable as a network traffic generator box in your network lab.

Next to network labs, it can also be used as a didactical tool and for security audits including penetration and DoS testing. As a traffic generator, mausezahn is also able to test IP multicast or VoIP networks. Packet rates close to the physical limit are reachable, depending on the hardware platform.

mausezahn supports two modes, ''direct mode'' and a multi-threaded ''interactive mode''.

The ''direct mode'' allows you to create a packet directly on the command line and every packet parameter is specified in the argument list when calling mausezahn.

The ''interactive mode'' is an advanced multi-threaded configuration mode with its own command line interface (CLI). This mode allows you to create an arbitrary number of packet types and streams in parallel, each with different parameters.

The interactive mode utilizes a completely redesigned and more flexible protocol framework called ''mops'' (mausezahn's own packet system). The look and feel of the CLI is very close to the Cisco IOS^tm command line interface.

You can start the interactive mode by executing mausezahn with the ''-x'' argument (an optional port number may follow, otherwise it is 25542). Then use telnet(1) to connect to this mausezahn instance. If not otherwise specified, the default login and password combination is mz:mz and the enable password is: mops. This can be changed in /etc/netsniff-ng/mausezahn.conf.

The direct mode supports two specification schemes: The ''raw-layer-2'' scheme, where every single byte to be sent can be specified, and ''higher-layer'' scheme, where packet builder interfaces are used (using the ''-t'' option).

To use the ''raw-layer-2'' scheme, simply specify the desired frame as a hexadecimal sequence (the ''hex-string''), such as:

mausezahn eth0 "00:ab:cd:ef:00 00:00:00:00:00:01 08:00 ca:fe:ba:be"

In this example, whitespaces within the byte string are optional and separate the Ethernet fields (destination and source address, type field, and a short payload). The only additional options supported are ''-a'', ''-b'', ''-c'', and ''-p''. The frame length must be greater than or equal to 15 bytes.

The ''higher-layer'' scheme is enabled using the ''-t <packet-type>'' option. This option activates a packet builder, and besides the ''packet-type'', an optional ''arg-string'' can be specified. The ''arg-string'' contains packet- specific parameters, such as TCP flags, port numbers, etc. (see example section).

## OPTIONS
mausezahn provides a built-in context-specific help. Append the keyword

''help'' after the configuration options. The most important options are:

### -x [<port>]
Start mausezahn in interactive mode with a Cisco-like CLI. Use telnet to log into the local mausezahn instance. If no port has been specified, port 25542 is used by default.

### -6
Specify IPv6 mode (IPv4 is the default).

### -l <IP>
Specify the IP address mausezahn should bind to when in interactive mode, default: 0.0.0.0.

### -R <PRIO>
Set priority of sent packets. This configures SO_PRIORITY at the socket through which the packets are sent. Usual priority numbers are 0..15, but the value can also be a class ID for purposes of Qdisc classification. In that case, a class ID such is 1234:5678 would be specified as 0x12345678.

### -v
Verbose mode. Capital -V is even more verbose.

### -S
Simulation mode, i.e. don't put anything on the wire. This is typically combined with the verbose mode.

### -q
Quiet mode where only warnings and errors are displayed.

### -c <count>
Send the packet count times (default: 1, infinite: 0).

### -d <delay>
Apply delay between transmissions. The delay value can be specified in usec (default, no additional unit needed), or in msec (e.g. 100m or 100msec), or in seconds (e.g. 100s or 100sec). Note: mops also supports nanosecond delay resolution if you need it (see interactive mode).

### -r
Multiply the specified delay with a random value.

### -p <length>
Pad the raw frame to specified length using zero bytes. Note that for raw layer 2 frames the specified length defines the whole frame length, while for higher layer packets the number of additional padding bytes are specified.

### -a <src-mac|keyword>
Use specified source MAC address with hexadecimal notation such as 00:00:aa:bb:cc:dd. By default the interface MAC address will be used. The keywords ''rand'' and ''own'' refer to a random MAC address (only unicast addresses are created) and the own address, respectively. You can also use the keywords mentioned below although broadcast-type source addresses are officially invalid.

### -b <dst-mac|keyword>
Use specified destination MAC address. By default, a broadcast is sent in raw layer 2 mode or to the destination hosts or gateway interface MAC address in normal (IP) mode. You can use the same keywords as mentioned above, as well as ''bc'' or ''bcast'', ''cisco'', and ''stp''.

### -A <src-ip|range|rand>
Use specified source IP address, default is own interface address. Optionally, the keyword ''rand'' can again be used for a random source IP address or a range can be specified, such as ''192.168.1.1-192.168.1.100'' or ''10.1.0.0/16''. Also, a DNS name can be specified for which mausezahn tries to determine the corresponding IP address automatically.

### -B <dst-ip|range>
Use specified destination IP address (default is broadcast i.e. 255.255.255.255). As with the source address (see above) you can also specify a range or a DNS name.

### -t <packet-type [help] | help>
Create the specified packet type using the built-in packet builder. Currently, supported packet types are: ''arp'', ''bpdu'', ''ip'', ''udp'', ''tcp'', ''rtp'', and ''dns''. Currently, there is also limited support for ''icmp''. Type

''-t help'' to verify which packet builders your actual mausezahn version supports. Also, for any particular packet type, for example ''tcp'' type

''mausezahn -t tcp help'' to receive a more in-depth context specific help.

### -T <packet-type>
Make this mausezahn instance the receiving station. Currently, only ''rtp'' is an option here and provides precise jitter measurements. For this purpose, start another mausezahn instance on the sending station and the local receiving station will output jitter statistics. See ''mausezahn -T rtp help'' for a detailed help.

### -Q <[CoS:]vlan> [, <[CoS:]vlan>, ...]
Specify 802.1Q VLAN tag and optional Class of Service. An arbitrary number of VLAN tags can be specified (that is, you can simulate QinQ or even QinQinQinQ..). Multiple tags must be separated via a comma or a period (e.g. "5:10,20,2:30"). VLAN tags are not supported for ARP and BPDU packets (in which case you could specify the whole frame in hexadecimal using the raw layer 2 interface of mausezahn).

### -M <label[:cos[:ttl]][bos]> [, <label...>]
Specify a MPLS label or even a MPLS label stack. Optionally, for each label the experimental bits (usually the Class of Service, CoS) and the Time To Live (TTL) can be specified. If you are really crazy you can set and unset the Bottom of Stack (BoS) bit for each label using the ''S'' (set) and ''s'' (unset) option. By default, the BoS is set automatically and correctly. Any other setting will lead to invalid frames. Enter ''-M help'' for detailed instructions and examples.

### -P <ascii-payload>
Specify a cleartext payload. Alternatively, each packet type supports a hexadecimal specification of the payload (see for example ''-t udp help'').

### -f <filename>
Read the ASCII payload from the specified file.

### -F <filename>
Read the hexadecimal payload from the specified file. Actually, this file must be also an ASCII text file, but must contain hexadecimal digits, e.g. "aa:bb:cc:0f:e6...". You can use also spaces as separation characters.

## USAGE EXAMPLE
For more comprehensive examples, have a look at the two following HOWTO sections.

### mausezahn eth0 -c 0 -d 2s -t bpdu vlan=5
Send BPDU frames for VLAN 5 as used with Cisco's PVST+ type of STP. By default mausezahn assumes that you want to become the root bridge.

### mausezahn eth0 -c 128000 -a rand -p 64
Perform a CAM table overflow attack.

### mausezahn eth0 -c 0 -Q 5,100 -t tcp flags=syn,dp=1-1023 -p 20 -A rand -B 10.100.100.0/24
Perform a SYN flood attack to another VLAN using VLAN hopping. This only works if you are connected to the same VLAN which is configured as native VLAN on the trunk. We assume that the victim VLAN is VLAN 100 and the native VLAN is VLAN 5. Lets attack every host in VLAN 100 which use an IP prefix of 10.100.100.0/24, also try out all ports between 1 and 1023 and use a random source IP address.

### mausezahn eth0 -c 0 -d 10msec -B 230.1.1.1 -t udp dp=32000,dscp=46 -P Multicast test packet
Send IP multicast packets to the multicast group 230.1.1.1 using a UDP header with destination port 32000 and set the IP DSCP field to EF (46). Send one frame every 10 msec.

### mausezahn eth0 -Q 6:420 -M 100,200,300:5 -A 172.30.0.0/16 -B target.anynetwork.foo -t udp sp=666,dp=1-65535 -p 1000 -c 10
Send UDP packets to the destination host target.anynetwork.foo using all possible destination ports and send every packet with all possible source addresses of the range 172.30.0.0/16; additionally use a source port of 666 and three MPLS labels, 100, 200, and 300, the outer (300) with QoS field 5. Send the frame with a VLAN tag 420 and CoS 6; eventually pad with 1000 bytes and repeat the whole thing 10 times.

### mausezahn -t syslog sev=3 -P Main reactor reached critical temperature. -A 192.168.33.42 -B 10.1.1.9 -c 6 -d 10s
Send six forged syslog messages with severity 3 to a Syslog server 10.1.1.9; use a forged source IP address 192.168.33.42 and let mausezahn decide which local interface to use. Use an inter-packet delay of 10 seconds.

### mausezahn -t tcp flags=syn|urg|rst, sp=145, dp=145, win=0, s=0-4294967295, ds=1500, urg=666 -a bcast -b bcast -A bcast -B 10.1.1.6 -p 5
Send an invalid TCP packet with only a 5 byte payload as layer-2 broadcast and also use the broadcast MAC address as source address. The target should be 10.1.1.6 but use a broadcast source address. The source and destination port shall be 145 and the window size 0. Set the TCP flags SYN, URG, and RST simultaneously and sweep through the whole TCP sequence number space with an increment of 1500. Finally set the urgent pointer to 666, i.e. pointing to nowhere.

## CONFIGURATION FILE
When mausezahn is run in interactive mode it automatically looks for and reads a configuration file located at /etc/netsniff-ng/mausezahn.conf for custom options if the file is available, otherwise it uses defaults set at compile time.

### Config file: /etc/netsniff-ng/mausezahn.conf
The configuration file contains lines of the form:

option = value

Options supported in the configuration file are:

Option: Description:

user Username for authentication (default: mz)

password Password for authentication (default: mz)

enable Password to enter privilege mode (default: mops)

port The listening port for the CLI (default: 25542)

listen-addr IP address to bind CLI to (default: 0.0.0.0)

management-only Set management interface (no data traffic is allowed to pass through)

cli-device Interface to bind CLI to (default: all) *not fully implemented*

automops Path to automops file (contains XML data describing protocols) *in development*

### Example:

$ cat /etc/netsniff-ng/mausezahn.conf

user = mzadmin

password = mzpasswd

enable = privilege-mode-passwd

port = 65000

listen-addr = 127.0.0.1

## INTERACTIVE MODE HOWTO

### Telnet:
Using the interactive mode requires starting mausezahn as a server:

\# mausezahn -x

Now you can telnet(1) to that server using the default port number 25542, but also an arbitrary port number can be specified:

\# mausezahn -x 99

mausezahn accepts incoming telnet connections on port 99.

mz: Problems opening config file. Will use defaults

Either from another terminal or from another host try to telnet to the mausezahn server:

caprica$ telnet galactica 99

Trying 192.168.0.4...

Connected to galactica.

Escape character is '^]'.

mausezahn <version>

Username: mz

Password: mz

mz> enable

Password: mops

mz#

It is recommended to configure your own login credentials in /etc/netsniff-ng/mausezahn.conf, (see configuration file section)

### Basics:
Since you reached the mausezahn prompt, lets try some common commands. You can use the '?' character at any time for context-specific help. Note that Cisco-like short form of commands are accepted in interactive mode. For example, one can use "sh pac" instead of "show packet"; another common example is to use "config t" in place of "configure terminal". For readability, this manual will continue with the full commands.

First try out the show command:

mz# show ?

mausezahn maintains its own ARP table and observes anomalies. There is an entry for every physical interface (however this host has only one):

mz# show arp

Intf Index IP address MAC address last Ch UCast BCast Info

----------------------------------------------------------------------------------

eth0 [1] D 192.168.0.1 00:09:5b:9a:15:84 23:44:41 1 1 0 0000

The column Ch tells us that the announced MAC address has only changed one time (= when it was learned). The columns Ucast and BCast tell us how often this entry was announced via unicast or broadcast respectively.

Let's check our interfaces:

mz# show interface

Available network interfaces:

real real used (fake) used (fake)

device IPv4 address MAC address IPv4 address MAC address

---------------------------------------------------------------------------------------

> eth0 192.168.0.4 00:30:05:76:2e:8d 192.168.0.4 00:30:05:76:2e:8d

lo 127.0.0.1 00:00:00:00:00:00 127.0.0.1 00:00:00:00:00:00

2 interfaces found.

Default interface is eth0.

### Defining packets:
Let's check the current packet list:

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

1 packets defined, 0 active.

We notice that there is already one system-defined packet process; it has been created and used only once (during startup) by mausezahn's ARP service. Currently, its state is config which means that the process is sleeping.

### General packet options:
Now let's create our own packet process and switch into the global configuration mode:

mz# configure terminal

mz(config)# packet

Allocated new packet PKT0002 at slot 2

mz(config-pkt-2)# ?

...

name Assign a unique name

description Assign a packet description text

bind Select the network interface

count Configure the packet count value

delay Configure the inter-packet delay

interval Configure a greater interval

type Specify packet type

mac Configure packet's MAC addresses

tag Configure tags

payload Configure a payload

port Configure packet's port numbers

end End packet configuration mode

ethernet Configure frame's Ethernet, 802.2, 802.3, or SNAP settings

ip Configure packet's IP settings

udp Configure packet's UDP header parameters

tcp Configure packet's TCP header parameters

Here are a lot of options but normally you only need a few of them. When you configure lots of different packets you might assign a reasonable name and description for them:

mz(config-pkt-2)# name Test

mz(config-pkt-2)# description This is just a test

You can, for example, change the default settings for the source and destination MAC or IP addresses using the mac and ip commands:

mz(config-pkt-2)# ip address destination 10.1.1.0 /24

mz(config-pkt-2)# ip address source random

In the example above, we configured a range of addresses (all hosts in the network 10.1.1.0 should be addressed). Additionally we spoof our source IP address. Of course, we can also add one or more VLAN and, or, MPLS tag(s):

mz(config-pkt-2)# tag ?

dot1q Configure 802.1Q (and 802.1P) parameters

mpls Configure MPLS label stack

mz(config-pkt-2)# tag dot ?

Configure 802.1Q tags:

VLAN[:CoS] [VLAN[:CoS]] ... The leftmost tag is the outer tag in the frame

remove <tag-nr> | all Remove one or more tags (<tag-nr> starts with 1),

by default the first (=leftmost,outer) tag is removed,

keyword 'all' can be used instead of tag numbers.

cfi | nocfi [<tag-nr>] Set or unset the CFI-bit in any tag (by default

assuming the first tag).

mz(config-pkt-2)# tag dot 1:7 200:5

### Configure count and delay:

mz(config-pkt-2)# count 1000

mz(config-pkt-2)# delay ?

delay <value> [hour | min | sec | msec | usec | nsec]

Specify the inter-packet delay in hours, minutes, seconds, milliseconds, microseconds or nanoseconds. The default unit is milliseconds (i.e. when no unit is given).

mz(config-pkt-2)# delay 1 msec

Inter-packet delay set to 0 sec and 1000000 nsec

mz(config-pkt-2)#

### Configuring protocol types:
mausezahn's interactive mode supports a growing list of protocols and only relies on the MOPS architecture (and not on libnet as is the case with the legacy direct mode):

mz(config-pkt-2)# type

Specify a packet type from the following list:

arp

bpdu

igmp

ip

lldp

tcp

udp

mz(config-pkt-2)# type tcp

mz(config-pkt-2-tcp)#

....

seqnr Configure the TCP sequence number

acknr Configure the TCP acknowledgement number

hlen Configure the TCP header length

reserved Configure the TCP reserved field

flags Configure a combination of TCP flags at once

cwr Set or unset the TCP CWR flag

ece Set or unset the TCP ECE flag

urg Set or unset the TCP URG flag

ack set or unset the TCP ACK flag

psh set or unset the TCP PSH flag

rst set or unset the TCP RST flag

syn set or unset the TCP SYN flag

fin set or unset the TCP FIN flag

window Configure the TCP window size

checksum Configure the TCP checksum

urgent-pointer Configure the TCP urgent pointer

options Configure TCP options

end End TCP configuration mode

mz(config-pkt-2-tcp)# flags syn fin rst

Current setting is: --------------------RST-SYN-FIN

mz(config-pkt-2-tcp)# end

mz(config-pkt-2)# payload ascii This is a dummy payload for my first packet

mz(config-pkt-2)# end

Now configure another packet, for example let's assume we want an LLDP process:

mz(config)# packet

Allocated new packet PKT0003 at slot 3

mz(config-pkt-3)# type lldp

mz(config-pkt-3-lldp)# exit

mz(config)# exit

In the above example we only use the default LLDP settings and don't configure further LLDP options or TLVs. Back in the top level of the CLI let's verify what we had done:

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 Test E-Q-IT 125 config eth0 1000 usec 1000/1000 (0%)

3 PKT0003 E----- LLDP 36 config eth0 30 sec 0/0 (0%)

3 packets defined, 0 active.

The column Layers indicates which major protocols have been combined. For example the packet with packet-id 2 ("Test") utilizes Ethernet (E), IP (I), and TCP (T). Additionally an 802.1Q tag (Q) has been inserted. Now start one of these packet processes:

mz# start slot 3

Activate [3]

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 Test E-Q-IT 125 config eth0 1000 usec 1000/1000 (0%)

3 PKT0003 E----- LLDP 36 config eth0 30 sec 0/1 (0%)

3 packets defined, 1 active.

Let's have a more detailed look at a specific packet process:

mz# show packet 2

Packet [2] Test

Description: This is just a test

State: config, Count=1000, delay=1000 usec (0 s 1000000 nsec), interval= (undefined)

Headers:

Ethernet: 00-30-05-76-2e-8d => ff-ff-ff-ff-ff-ff [0800 after 802.1Q tag]

Auto-delivery is ON (that is, the actual MAC is adapted upon transmission)

802.1Q: 0 tag(s); (VLAN:CoS)

IP: SA=192.168.0.4 (not random) (no range)

DA=255.255.255.255 (no range)

ToS=0x00 proto=17 TTL=255 ID=0 offset=0 flags: -|-|-

len=49664(correct) checksum=0x2e8d(correct)

TCP: 83 bytes segment size (including TCP header)

SP=0 (norange) (not random), DP=0 (norange) (not random)

SQNR=3405691582 (start 0, stop 4294967295, delta 0) -- ACKNR=0 (invalid)

Flags: ------------------------SYN----, reserved field is 00, urgent pointer= 0

Announced window size= 100

Offset= 0 (times 32 bit; value is valid), checksum= ffff (valid)

(No TCP options attached) - 0 bytes defined

Payload size: 43 bytes

Frame size: 125 bytes

1 ff:ff:ff:ff:ff:ff:00:30 05:76:2e:8d:81:00:e0:01 81:00:a0:c8:08:00:45:00 00:67:00:00:00:00:ff:06

33 fa:e4:c0:a8:00:04:ff:ff ff:ff:00:00:00:00:ca:fe ba:be:00:00:00:00:a0:07 00:64:f7:ab:00:00:02:04

65 05:ac:04:02:08:0a:19:35 90:c3:00:00:00:00:01:03 03:05:54:68:69:73:20:69 73:20:61:20:64:75:6d:6d

97 79:20:70:61:79:6c:6f:61 64:20:66:6f:72:20:6d:79 20:66:69:72:73:74:20:70 61:63:6b:65:74

mz#

If you want to stop one or more packet processes, use the stop command. The "emergency stop" is when you use stop all:

mz# stop all

Stopping

[3] PKT0003

Stopped 1 transmission processe(s)

The launch command provides a shortcut for commonly used packet processes. For example to behave like a STP-capable bridge we want to start an BPDU process with typical parameters:

mz# launch bpdu

Allocated new packet sysBPDU at slot 5

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 Test E-Q-IT 125 config eth0 1000 usec 1000/1000 (0%)

3 PKT0003 E----- LLDP 36 config eth0 30 sec 0/12 (0%)

4 PKT0004 E---I- IGMP 46 config eth0 100 msec 0/0 (0%)

5 sysBPDU ES---- BPDU 29 active eth0 2 sec 0/1 (0%)

5 packets defined, 1 active.

Now a Configuration BPDU is sent every 2 seconds, claiming to be the root bridge (and usually confusing the LAN. Note that only packet 5 (i.e. the last row) is active and therefore sending packets while all other packets are in state config (i.e. they have been configured but they are not doing anything at the moment).

### Configuring a greater interval:
Sometimes you may want to send a burst of packets at a greater interval:

mz(config)# packet 2

Modify packet parameters for packet Test [2]

mz(config-pkt-2)# interval

Configure a greater packet interval in days, hours, minutes, or seconds

Arguments: <value> <days | hours | minutes | seconds>

Use a zero value to disable an interval.

mz(config-pkt-2)# interval 1 hour

mz(config-pkt-2)# count 10

mz(config-pkt-2)# delay 15 usec

Inter-packet delay set to 0 sec and 15000 nsec

Now this packet is sent ten times with an inter-packet delay of 15 microseconds and this is repeated every hour. When you look at the packet list, an interval is indicated with the additional flag 'i' when inactive or 'I' when active:

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 Test E-Q-IT 125 config-i eth0 15 usec 10/10 (0%)

3 PKT0003 E----- LLDP 36 config eth0 30 sec 0/12 (0%)

4 PKT0004 E---I- IGMP 46 config eth0 100 msec 0/0 (0%)

5 sysBPDU ES---- BPDU 29 active eth0 2 sec 0/251 (0%)

5 packets defined, 1 active.

mz# start slot 2

Activate [2]

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 Test E-Q-IT 125 config+I eth0 15 usec 10/0 (100%)

3 PKT0003 E----- LLDP 36 config eth0 30 sec 0/12 (0%)

4 PKT0004 E---I- IGMP 46 config eth0 100 msec 0/0 (0%)

5 sysBPDU ES---- BPDU 29 active eth0 2 sec 0/256 (0%)

5 packets defined, 1 active.

Note that the flag 'I' indicates that an interval has been specified for packet 2. The process is not active at the moment (only packet 5 is active here) but it will become active at a regular interval. You can verify the actual interval when viewing the packet details via the 'show packet 2' command.

### Load prepared configurations:
You can prepare packet configurations using the same commands as you would type them in on the CLI and then load them to the CLI. For example, assume we have prepared a file 'test.mops' containing:

configure terminal

packet

name IGMP_TEST

desc This is only a demonstration how to load a file to mops

type igmp

Then we can add this packet configuration to our packet list using the load command:

mz# load test.mops

Read commands from test.mops...

Allocated new packet PKT0002 at slot 2

mz# show packet

Packet layer flags: E=Ethernet, S=SNAP, Q=802.1Q, M=MPLS, I/i=IP/delivery_off, U=UDP, T=TCP

PktID PktName Layers Proto Size State Device Delay Count/CntX

1 sysARP_servic... E----- ARP 60 config lo 100 msec 1/0 (100%)

2 IGMP_TEST E---I- IGMP 46 config eth0 100 msec 0/0 (0%)

2 packets defined, 0 active.

The file src/examples/mausezahn/example_lldp.conf contains another example list of commands to create a bogus LLDP packet. You can load this configuration from the mausezahn command line as follows:

mz# load /home/hh/tmp/example_lldp.conf

In case you copied the file in that path. Now when you enter 'show packet' you will see a new packet entry in the packet list. Use the 'start slot <nr>' command to activate this packet.

You can store your own packet creations in such a file and easily load them when you need them. Every command within such configuration files is executed on the command line interface as if you had typed it in -- so be careful about the order and don't forget to use 'configure terminal' as first command.

You can even load other files from within a central config file.

## DIRECT MODE HOWTO

### How to specify hexadecimal digits:
Many arguments allow direct byte input. Bytes are represented as two hexadecimal digits. Multiple bytes must be separated either by spaces, colons, or dashes - whichever you prefer. The following byte strings are equivalent:

"aa:bb cc-dd-ee ff 01 02 03-04 05"

"aa bb cc dd ee ff:01:02:03:04 05"

To begin with, you may want to send an arbitrary fancy (possibly invalid) frame right through your network card:

mausezahn ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:08:00:ca:fe:ba:be

or equivalent but more readable:

mausezahn ff:ff:ff:ff:ff:ff-ff:ff:ff:ff:ff:ff-08:00-ca:fe:ba:be

### Basic operations:
All major command line options are listed when you execute mausezahn without arguments. For practical usage, keep the following special (not so widely known) options in mind:

-r Multiplies the specified delay with a random value.

-p <length> Pad the raw frame to specified length (using random bytes).

-P <ASCII Payload> Use the specified ASCII payload.

-f <filename> Read the ASCII payload from a file.

-F <filename> Read the hexadecimal payload from a file.

-S Simulation mode: DOES NOT put anything on the wire.

This is typically combined with one of the verbose

modes (-v or V).

Many options require a keyword or a number but the -t option is an exception since it requires both a packet type (such as ip, udp, dns, etc) and an argument string which is specific for that packet type. Here are some simple examples:

mausezahn -t help

mausezahn -t tcp help

mausezahn eth3 -t udp sp=69,dp=69,p=ca:fe:ba:be

Note: Don't forget that on the CLI the Linux shell (usually the Bash) interprets spaces as a delimiting character. That is, if you are specifying an argument that consists of multiple words with spaces in between, you MUST group these within quotes. For example, instead of

mausezahn eth0 -t udp sp=1,dp=80,p=00:11:22:33

you could either omit the spaces

mausezahn eth0 -t udp sp=1,dp=80,p=00:11:22:33

or, for greater safety, use quotes:

mausezahn eth0 -t udp "sp=1,dp=80,p=00:11:22:33"

In order to monitor what's going on, you can enable the verbose mode using the -v option. The opposite is the quiet mode (-q) which will keep mausezahn absolutely quiet (except for error messages and warnings.)

Don't confuse the payload argument p=... with the padding option -p. The latter is used outside the quotes!

### The automatic packet builder:
An important argument is -t which invokes a packet builder. Currently there are packet builders for ARP, BPDU, CDP, IP, partly ICMP, UDP, TCP, RTP, DNS, and SYSLOG. (Additionally you can insert a VLAN tag or a MPLS label stack but this works independently of the packet builder.)

You get context specific help for every packet builder using the help keyword, such as:

mausezahn -t bpdu help

mausezahn -t tcp help

For every packet you may specify an optional payload. This can be done either via hexadecimal notation using the payload (or short p) argument or directly as ASCII text using the -P option:

mausezahn eth0 -t ip -P "Hello World" # ASCII payload

mausezahn eth0 -t ip p=68:65:6c:6c:6f:20:77:6f:72:6c:64 # hex payload

mausezahn eth0 -t ip "proto=89, \

p=68:65:6c:6c:6f:20:77:6f:72:6c:64, \ # same with other

ttl=1" # IP arguments

Note: The raw link access mode only accepts hexadecimal payloads (because you specify everything in hexadecimal here.)

### Packet count and delay:
By default only one packet is sent. If you want to send more packets then use the count option -c <count>. When count is zero then mausezahn will send forever. By default, mausezahn sends at maximum speed (and this is really fast ;-)). If you don't want to overwhelm your network devices or have other reasons to send at a slower rate then you might want to specify a delay using the -d <delay> option.

If you only specify a numeric value it is interpreted in microsecond units. Alternatively, for easier use, you might specify units such as seconds, sec, milliseconds, or msec. (You can also abbreviate this with s or m.) Note: Don't use spaces between the value and the unit! Here are typical examples:

Send an infinite number of frames as fast as possible:

mausezahn -c 0 "aa bb cc dd ...."

Send 100,000 frames with a 50 msec interval:

mausezahn -c 100000 -d 50msec "aa bb cc dd ...."

Send an unlimited number of BPDU frames in a 2 second interval:

mausezahn -c 0 -d 2s -t bpdu conf

Note: mausezahn does not support fractional numbers. If you want to specify for example 2.5 seconds then express this in milliseconds (2500 msec).

### Source and destination addresses:
As a mnemonic trick keep in mind that all packets run from "A" to "B". You can always specify source and destination MAC addresses using the -a and -b options, respectively. These options also allow keywords such as rand, own, bpdu, cisco, and others.

Similarly, you can specify source and destination IP addresses using the -A and -B options, respectively. These options also support FQDNs (i.e. domain names) and ranges such as 192.168.0.0/24 or 10.0.0.11-10.0.3.22. Additionally, the source address option supports the rand keyword (ideal for "attacks").

Note: When you use the packet builder for IP-based packets (e.g. UDP or TCP) then mausezahn automatically cares about correct MAC and IP addresses (i.e. it performs ARP, DHCP, and DNS for you). But when you specify at least a single link-layer address (or any other L2 option such as a VLAN tag or MPLS header) then ARP is disabled and you must care for the Ethernet destination address for yourself.

### `-- Direct link access:
mausezahn allows you to send ANY chain of bytes directly through your Ethernet interface:

mausezahn eth0 "ff:ff:ff:ff:ff:ff ff:ff:ff:ff:ff:ff 00:00 ca:fe:ba:be"

This way you can craft every packet you want but you must do it by hand. Note: On Wi-Fi interfaces the header is much more complicated and automatically created by the Wi-Fi driver. As an example to introduce some interesting options, lets continuously send frames at max speed with random source MAC address and broadcast destination address, additionally pad the frame to 1000 bytes:

mausezahn eth0 -c 0 -a rand -b bcast -p 1000 "08 00 aa bb cc dd"

The direct link access supports automatic padding using the -p <total frame length> option. This allows you to pad a raw L2 frame to the desired length. You must specify the total length, and the total frame length must have at least 15 bytes for technical reasons. Zero bytes are used for padding.

### `-- ARP:
mausezahn provides a simple interface to the ARP packet. You can specify the ARP method (request|reply) and up to four arguments: sendermac, targetmac, senderip, targetip, or short smac, tmac, sip, tip. By default, an ARP reply is sent with your own interface addresses as source MAC and IP address, and a broadcast destination MAC and IP address. Send a gratuitous ARP request (as used for duplicate IP address detection):

mausezahn eth0 -t arp

ARP cache poisoning:

mausezahn eth0 -t arp "reply, senderip=192.168.0.1, targetmac=00:00:0c:01:02:03, \

targetip=172.16.1.50"

where by default your interface MAC address will be used as sendermac, senderip denotes the spoofed IP address, targetmac and targetip identifies the receiver. By default, the Ethernet source address is your interface MAC and the destination address is the broadcast address. You can change this using the flags -a and -b.

### `-- BPDU:
mausezahn provides a simple interface to the 802.1D BPDU frame format (used to create the Spanning Tree in bridged networks). By default, standard IEEE 802.1D BPDUs are sent and it is assumed that your computer wants to become the root bridge (rid=bid). Optionally the 802.3 destination address can be a specified MAC address, broadcast, own MAC, or Cisco's PVST+ MAC address. The destination MAC can be specified using the -b command which, besides MAC addresses, accepts keywords such as bcast, own, pvst, or stp (default). PVST+ is supported as well. Simply specify the VLAN for which you want to send a BPDU:

mausezahn eth0 -t bpdu "vlan=123, rid=2000"

See mausezahn -t bpdu help for more details.

### `-- CDP:
mausezahn can send Cisco Discovery Protocol (CDP) messages since this protocol has security relevance. Of course lots of dirty tricks are possible; for example arbitrary TLVs can be created (using the hex-payload argument for example p=00:0e:00:07:01:01:90) and if you want to stress the CDP database of some device, mausezahn can send each CDP message with another system-id using the change keyword:

mausezahn -t cdp change -c 0

Some routers and switches may run into deep problems ;-) See mausezahn -t cdp help for more details.

### `-- 802.1Q VLAN Tags:
mausezahn allows simple VLAN tagging for IP (and other higher layer) packets. Simply use the option -Q <[CoS:]VLAN>, such as -Q 10 or -Q 3:921. By default CoS=0. For example send a TCP packet in VLAN 500 using CoS=7:

mausezahn eth0 -t tcp -Q 7:500 "dp=80, flags=rst, p=aa:aa:aa"

You can create as many VLAN tags as you want! This is interesting to create QinQ encapsulations or VLAN hopping: Send a UDP packet with VLAN tags 100 (outer) and 651 (inner):

mausezahn eth0 -t udp "dp=8888, sp=13442" -P "Mausezahn is great" -Q 100,651

Don't know if this is useful anywhere but at least it is possible:

mausezahn eth0 -t udp "dp=8888, sp=13442" -P "Mausezahn is great" \

-Q 6:5,7:732,5:331,5,6

Mix it with MPLS:

mausezahn eth0 -t udp "dp=8888, sp=13442" -P "Mausezahn is great" -Q 100,651 -M 314

When in raw Layer 2 mode you must create the VLAN tag completely by yourself. For example if you want to send a frame in VLAN 5 using CoS 0 simply specify 81:00 as type field and for the next two bytes the CoS (PCP), DEI (CFI), and VLAN ID values (all together known as TCI):

mausezahn eth0 -b bc -a rand "81:00 00:05 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa"

### `-- MPLS labels:
mausezahn allows you to insert one or more MPLS headers. Simply use the option -M <label:CoS:TTL:BoS> where only the label is mandatory. If you specify a second number it is interpreted as the experimental bits (the CoS usually). If you specify a third number it is interpreted as TTL. By default the TTL is set to 255. The Bottom of Stack flag is set automatically, otherwise the frame would be invalid, but if you want you can also set or unset it using the S (set) and s (unset) argument. Note that the BoS must be the last argument in each MPLS header definition. Here are some examples:

Use MPLS label 214:

mausezahn eth0 -M 214 -t tcp "dp=80" -P "HTTP..." -B myhost.com

Use three labels (the 214 is now the outer):

mausezahn eth0 -M 9999,51,214 -t tcp "dp=80" -P "HTTP..." -B myhost.com

Use two labels, one with CoS=5 and TTL=1, the other with CoS=7:

mausezahn eth0 -M 100:5:1,500:7 -t tcp "dp=80" -P "HTTP..." -B myhost.com

Unset the BoS flag (which will result in an invalid frame):

mausezahn eth0 -M 214:s -t tcp "dp=80" -P "HTTP..." -B myhost.com

### Layer 3-7:
IP, UDP, and TCP packets can be padded using the -p option. Currently 0x42 is used as padding byte ('the answer'). You cannot pad DNS packets (would be useless anyway).

### `-- IP:
mausezahn allows you to send any malformed or correct IP packet. Every field in the IP header can be manipulated. The IP addresses can be specified via the -A and -B options, denoting the source and destination address, respectively. You can also specify an address range or a host name (FQDN). Additionally, the source address can also be random. By default the source address is your interface IP address and the destination address is a broadcast address. Here are some examples:

ASCII payload:

mausezahn eth0 -t ip -A rand -B 192.168.1.0/24 -P "hello world"

Hexadecimal payload:

mausezahn eth0 -t ip -A 10.1.0.1-10.1.255.254 -B 255.255.255.255 p=ca:fe:ba:be

Will use correct source IP address:

mausezahn eth0 -t ip -B www.xyz.com

The Type of Service (ToS) byte can either be specified directly by two hexadecimal digits, which means you can also easily set the Explicit Congestion Notification (ECN) bits (LSB 1 and 2), or you may only want to specify a common DSCP value (bits 3-8) using a decimal number (0..63):

Packet sent with DSCP = Expedited Forwarding (EF):

mausezahn eth0 -t ip dscp=46,ttl=1,proto=1,p=08:00:5a:a2:de:ad:be:af

If you leave the checksum as zero (or unspecified) the correct checksum will be automatically computed. Note that you can only use a wrong checksum when you also specify at least one L2 field manually.

### `-- UDP:
mausezahn supports easy UDP datagram generation. Simply specify the destination address (-B option) and optionally an arbitrary source address (-A option) and as arguments you may specify the port numbers using the dp (destination port) and sp (source port) arguments and a payload. You can also easily specify a whole port range which will result in sending multiple packets. Here are some examples:

Send test packets to the RTP port range:

mausezahn eth0 -B 192.168.1.1 -t udp "dp=16384-32767, \

p=A1:00:CC:00:00:AB:CD:EE:EE:DD:DD:00"

Send a DNS request as local broadcast (often a local router replies):

mausezahn eth0 -t udp dp=53,p=c5-2f-01-00-00-01-00-00-00-00-00-00-03-77-77-\

77-03-78-79-7a-03-63-6f-6d-00-00-01-00-01"

Additionally you may specify the length and checksum using the len and sum arguments (will be set correctly by default). Note: several protocols have same arguments such as len (length) and sum (checksum). If you specified a UDP type packet (via -t udp) and want to modify the IP length, then use the alternate keyword iplen and ipsum. Also note that you must specify at least one L2 field which tells mausezahn to build everything without the help of your kernel (the kernel would not allow modifying the IP checksum and the IP length).

### `-- ICMP:
mausezahn currently only supports the following ICMP methods: PING (echo request), Redirect (various types), Unreachable (various types). Additional ICMP types will be supported in future. Currently you would need to tailor them by yourself, e.g. using the IP packet builder (setting proto=1). Use the mausezahn -t icmp help for help on currently implemented options.

### `-- TCP:
mausezahn allows you to easily tailor any TCP packet. Similarly as with UDP you can specify source and destination port (ranges) using the sp and dp arguments. Then you can directly specify the desired flags using an "|" as delimiter if you want to specify multiple flags. For example, a SYN-Flood attack against host 1.1.1.1 using a random source IP address and periodically using all 1023 well-known ports could be created via:

mausezahn eth0 -A rand -B 1.1.1.1 -c 0 -t tcp "dp=1-1023, flags=syn" \

-P "Good morning! This is a SYN Flood Attack. \

We apologize for any inconvenience."

Be careful with such SYN floods and only use them for firewall testing. Check your legal position! Remember that a host with an open TCP session only accepts packets with correct socket information (addresses and ports) and a valid TCP sequence number (SQNR). If you want to try a DoS attack by sending a RST-flood and you do NOT know the target's initial SQNR (which is normally the case) then you may want to sweep through a range of sequence numbers:

mausezahn eth0 -A legal.host.com -B target.host.com \

-t tcp "sp=80,dp=80,s=1-4294967295"

Fortunately, the SQNR must match the target host's acknowledgement number plus the announced window size. Since the typical window size is something between 40000 and 65535 you are MUCH quicker when using an increment via the ds argument:

mausezahn eth0 -A legal.host.com -B target.host.com \

-t tcp "sp=80, dp=80, s=1-4294967295, ds=40000"

In the latter case mausezahn will only send 107375 packets instead of 4294967295 (which results in a duration of approximately 1 second compared to 11 hours!). Of course you can tailor any TCP packet you like. As with other L4 protocols mausezahn builds a correct IP header but you can additionally access every field in the IP packet (also in the Ethernet frame).

### `-- DNS:
mausezahn supports UDP-based DNS requests or responses. Typically you may want to send a query or an answer. As usual, you can modify every flag in the header. Here is an example of a simple query:

mausezahn eth0 -B mydns-server.com -t dns "q=www.ibm.com"

You can also create server-type messages:

mausezahn eth0 -A spoofed.dns-server.com -B target.host.com \

"q=www.topsecret.com, a=172.16.1.1"

The syntax according to the online help (-t dns help) is:

query|q = <name>[:<type>] ............. where type is per default "A"

(and class is always "IN")

answer|a = [<type>:<ttl>:]<rdata> ...... ttl is per default 0.

= [<type>:<ttl>:]<rdata>/[<type>:<ttl>:]<rdata>/...

Note: If you only use the 'query' option then a query is sent. If you additionally add an 'answer' then an answer is sent. Examples:

q = www.xyz.com

q = www.xyz.com, a=192.168.1.10

q = www.xyz.com, a=A:3600:192.168.1.10

q = www.xyz.com, a=CNAME:3600:abc.com/A:3600:192.168.1.10

Please try out mausezahn -t dns help to see the many other optional command line options.

### `-- RTP and VoIP path measurements:
mausezahn can send arbitrary Real Time Protocol (RTP) packets. By default a classical G.711 codec packet of 20 ms segment size and 160 bytes is assumed. You can measure jitter, packet loss, and reordering along a path between two hosts running mausezahn. The jitter measurement is either done following the variance low-pass filtered estimation specified in RFC 3550 or using an alternative "real-time" method which is even more precise (the RFC-method is used by default). For example on Host1 you start a transmission process:

mausezahn -t rtp -B 192.168.1.19

And on Host2 (192.168.1.19) a receiving process which performs the measurement:

mausezahn -T rtp

Note that the option flag with the capital "T" means that it is a server RTP process, waiting for incoming RTP packets from any mausezahn source. In case you want to restrict the measurement to a specific source or you want to perform a bidirectional measurement, you must specify a stream identifier. Here is an example for bidirectional measurements which logs the running jitter average in a file:

Host1# mausezahn -t rtp id=11:11:11:11 -B 192.168.2.2 &

Host1# mausezahn -T rtp id=22:22:22:22 "log, path=/tmp/mz/"

Host2# mausezahn -t rtp id=22:22:22:22 -B 192.168.1.1 &

Host2# mausezahn -T rtp id=11:11:11:11 "log, path=/tmp/mz/"

In any case the measurements are printed continuously onto the screen; by default it looks like this:

0.00 0.19 0.38 0.57

|-------------------------|-------------------------|-------------------------|

\######### 0.07 msec

\#################### 0.14 msec

\## 0.02 msec

\### 0.02 msec

\######### 0.07 msec

\#### 0.03 msec

\######### 0.07 msec

\############# 0.10 msec

\## 0.02 msec

\########################################### 0.31 msec

\######### 0.07 msec

\############################################## 0.33 msec

\############### 0.11 msec

\########## 0.07 msec

\############### 0.11 msec

\########################################################## 0.42 msec

\##### 0.04 msec

More information is shown using the txt keyword:

mausezahn -T rtp txt

Got 100 packets from host 192.168.0.3: 0 lost (0 absolute lost), 1 out of order

Jitter_RFC (low pass filtered) = 30 usec

Samples jitter (min/avg/max) = 1/186/2527 usec

Delta-RX (min/avg/max) = 2010/20167/24805 usec

Got 100 packets from host 192.168.0.3: 0 lost (0 absolute lost), 1 out of order

Jitter_RFC (low pass filtered) = 17 usec

Samples jitter (min/avg/max) = 1/53/192 usec

Delta-RX (min/avg/max) = 20001/20376/20574 usec

Got 100 packets from host 192.168.0.3: 0 lost (0 absolute lost), 1 out of order

Jitter_RFC (low pass filtered) = 120 usec

Samples jitter (min/avg/max) = 0/91/1683 usec

Delta-RX (min/avg/max) = 18673/20378/24822 usec

See mausezahn -t rtp help and mz -T rtp help for more details.

### `-- Syslog:
The traditional Syslog protocol is widely used even in professional networks and is sometimes vulnerable. For example you might insert forged Syslog messages by spoofing your source address (e.g. impersonate the address of a legit network device):

mausezahn -t syslog sev=3 -P "You have been mausezahned." -A 10.1.1.109 -B 192.168.7.7

See mausezahn -t syslog help for more details.

## NOTE
When multiple ranges are specified, e.g. destination port ranges and destination address ranges, then all possible combinations of ports and addresses are used for packet generation. Furthermore, this can be mixed with other ranges e.g. a TCP sequence number range. Note that combining ranges can lead to a very huge number of frames to be sent. As a rule of thumb you can assume that about 100,000 frames and more are sent in a fraction of one second, depending on your network interface.

mausezahn has been designed as a fast traffic generator so you might easily overwhelm a LAN segment with myriads of packets. And because mausezahn could also support security audits it is possible to create malicious or invalid packets, SYN floods, port and address sweeps, DNS and ARP poisoning, etc.

Therefore, don't use this tool when you are not aware of the possible consequences or have only a little knowledge about networks and data communication. If you abuse mausezahn for 'unallowed' attacks and get caught, or damage something of your own, then this is completely your fault. So the safest solution is to try it out in a lab environment.

Also have a look at the netsniff-ng(8) note section on how you can properly setup and tune your system.

## LEGAL
mausezahn is licensed under the GNU GPL version 2.0.

## HISTORY
mausezahn was originally written by Herbert Haas. According to his website [1], he unfortunately passed away in 2011 thus leaving this tool unmaintained. It has been adopted and integrated into the netsniff-ng toolkit and is further being maintained and developed from there. Maintainers are Tobias Klauser <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.

[1] http://www.perihel.at/

## SEE ALSO
netsniff-ng(8), trafgen(8), ifpps(8), bpfc(8), flowtop(8), astraceroute(8), curvetun(8)

## AUTHOR
Manpage was written by Herbert Haas and modified by Daniel Borkmann.

## COLOPHON
This page is part of the Linux netsniff-ng toolkit project. A description of the project, and information about reporting bugs, can be found at http://netsniff-ng.org/.