Giter VIP home page Giter VIP logo

nemesis's Introduction

1b 2b 3b CodeDocs Status

Packet Construction and Injection

Libnet is an API to help with the construction and injection of network packets. It provides a portable framework for low-level network packet writing and handling (use libnet in conjunction with libpcap and you can write some really cool stuff). Libnet includes packet creation at the IP layer and at the link layer as well as a host of supplementary and complementary functionality.

Libnet is very handy with which to write network tools and network test code. Some projects, available in Debian/Ubuntu and OpenBSD, using libnet are:

NOTE: Legacy code written for libnet-1.0.x is unfortunately incompatible with libnet-1.1.x and later.
See the Migration Guide for porting help.

Using -lnet

Libnet is installed as a library and a set of include files. The main include file to use in your program is:

#include <libnet.h>

To get the correct search paths to both the header and library files, use the standard pkg-config tool (old libnet-config is deprecated):

$ pkg-config --libs --static --cflags libnet
-I/usr/local/include -L/usr/local/lib -lnet

The prefix path /usr/local/ shown here is only the default. Use the configure script to select a different prefix when installing libnet.

For GNU autotools based projects, use the following in configure.ac:

# Check for required libraries
PKG_CHECK_MODULES([libnet], [libnet >= 1.2])

and in your Makefile.am:

proggy_CFLAGS = $(libnet_CFLAGS)
proggy_LDADD  = $(libnet_LIBS)

Online docs available at https://codedocs.xyz/libnet/libnet/. See the man page and sample test code for more information.

Building

First download the latest release from GitHub. Libnet employs the GNU configure and build system. The release tarballs and zip files ship with a pre-built configure script:

$ tar xf libnet-x.y.z.tar.gz
$ cd libnet-x.y.z/
$ ./configure && make
$ sudo make install

To list available options, type ./configure --help

Building from GIT/GitHub

When building from GIT, use ./autogen.sh to generate the configure script. For this you need the full suite of the GNU autotools: autoconf (>=2.69), automake (>=1.14), libtool (>=2.4.2).

How to install the dependencies varies by system, but on many Debian derived systems, apt can be used:

$ sudo apt install autoconf automake libtool
$ ./autogen.sh
$ ./configure && make
$ sudo make install

Using Conan

Libnet is available on Conan Center. To use, add libnet/1.2 to your conanfile.txt

Building with Docker

First build the dev. contrainer:

$ cd .devcontainer
$ docker build -t libnet-builder .

Then compile libnet with docker:

$ cd ..
$ docker run -it --rm -v $(pwd):$(pwd) --workdir=$(pwd) libnet-builder
$ ./autogen.sh                 # If you've cloned from GitHub
$ ./configure
$ make

Running Unit Tests with CMocka

Running tests in the dev. container (above):

$ ./autogen.sh                 # If you've cloned from GitHub
$ ./configure --enable-tests
$ make check
make  check-TESTS
PASS: udld 1 - libnet_udld__checksum_calculation
PASS: udld 2 - libnet_build_udld__pdu_header_only
PASS: udld 3 - libnet_build_udld__tlv_device_id
PASS: udld 4 - libnet_build_udld__tlv_port_id
PASS: udld 5 - libnet_build_udld__tlv_echo
PASS: udld 6 - libnet_build_udld__tlv_message_interval
PASS: udld 7 - libnet_build_udld__tlv_timeout_interval
PASS: udld 8 - libnet_build_udld__tlv_device_name
PASS: udld 9 - libnet_build_udld__tlv_sequence_number
PASS: udld 10 - libnet_build_udld__build_whole_packet_with_checksum
PASS: ethernet 1 - test_libnet_build_ethernet
============================================================================
Testsuite summary for libnet 1.3
============================================================================
# TOTAL: 11
# PASS:  11
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

Note: on Linux the tests run in a separate network namespace (using unshare), so no root (sudo) access is needed, but on other systems you may need to to be root, or have to correct capabilities or permissions.

Building the Documentation

To build the documentation (optional) you need doxygen and pod2man:

$ sudo apt install doxygen
$ sudo apt install pod2man || sudo apt install perl

For neat graphics in the HTML documentation, also install graphviz. There is also a PDF version of the docs, to build that you need quite a few more packages:

$ sudo apt install texlive-extra-utils texlive-latex-extra \
                   texlive-fonts-recommended latex-xcolor  \
                   texlive-font-utils

For Microsoft CHM docs you need the HTML Help Workshop, which is part of Visual Studio: http://go.microsoft.com/fwlink/p/?linkid=154968, on UNIX and GNU/Linux systems, see chmcmd, which is available in the FreePascal suite:

$ sudo apt install fp-utils-3.0.4

Origin & References

Libnet is widely used, but had been unmaintained for a long time and its author unreachable. This version was forked from the 1.1.3 release candidate from packetfactory.net, bug fixed, developed, and re-released.

Use GitHub issues and pull request feature for questions and patches:

http://github.com/libnet/libnet

Some old docs are available at:

http://packetfactory.openwall.net/projects/libnet/index.html



nemesis's People

Contributors

droberson avatar fullaxx avatar matt-kowalski avatar samyk avatar sgeto avatar troglobit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nemesis's Issues

Binary link fails due to multiple definition of varables

Nemesis does not successfully compile

Expected Behavior

Successful creation of nemesis binary

Actual Behavior

ld fails to link nemesis

/usr/bin/ld: nemesis-proto_dns.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-dns.h:32: multiple definition of `state'; nemesis-dns.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-dns.h:32: first defined here
/usr/bin/ld: nemesis-proto_icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:42: multiple definition of `mode'; nemesis-icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:42: first defined here
/usr/bin/ld: nemesis-proto_icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:43: multiple definition of `got_origoptions'; nemesis-icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:43: first defined here
/usr/bin/ld: nemesis-ospf.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-ospf.h:46: multiple definition of `mode'; nemesis-icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:42: first defined here
/usr/bin/ld: nemesis-proto_ospf.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-ospf.h:46: multiple definition of `mode'; nemesis-icmp.o:/home/RL/packages/nemesis/nemesis-20210419/src/nemesis-icmp.h:42: first defined here

Steps to Reproduce the Problem

  1. make V=1

Sending IGMP v3 Join

Hi all,
I'm having an issue sending an IGMP v3 packet. I doubt it's an issue with nemesis itself, but rather my knowledge of it - I am hoping someone here is able to assist.

I modified the example in the docs for an IGMP v2 join, to:

sudo nemesis igmp -v -p 0x22 -S 192.168.69.62 -g 224.0.1.116 -D 224.0.0.2

However, watching with Wireshark shows an IGMPv3 Membership Report, but it indicates that it is a malformed packet. I found 0x22 as an option under nemesis igmp help. I attempted to craft a payload, but with my limited knowledge it did not go too well!

If anyone is able to provide any suggestions, it would be much appreciated. And if it is possible to send a v3 join packet, this may be useful in the docs.

Thank you

default timeout when sending only one frame

Expected Behavior

nemesis should quit after the last frame has been sent and not wait for -i or the default of 1 second.

Actual Behavior

nemesis waits for -i after the last frame has been sent.

Steps to Reproduce the Problem

send a frame ;)

Specifications

  • Version: 1.6
  • Platform: Ubuntu bionic

Solution

For me, it seem line 344 of nemesis-functions.c isn't working as it should.

344                 if (count != 0 && interval >= 0)
345                         usleep(interval);

If count would be 0, it should not sleep. So I think there's an issue with the counter (off by one?)

Error calling dns_exit instead dhcp_exit

nemesis-dchp.c

Call to dns_exit on nemesis-dhcp.c instead of calling dhcp_exit on line 368
on versions 1.6 and master one.
`#if defined(WIN32)
case 'Z':
if ((ifacetmp = pcap_lookupdev(errbuf)) == NULL)
perror(errbuf);

		PrintDeviceList(ifacetmp);
		dhcp_exit /*dns_exit(1)*/;
		/* fallthrough */

#endif`

  • Version: 1.6 and trunk one
  • Platform: Windows.
    please correct.

Nemesis won't update

It tells me to check to see if it has permission, but I have no idea how to do that.

ICMP packets generate invalid IP header length

If generating ICMP packets, IP header's length field doesn't include the length of the IP header itself, producing invalid IP packets. Other protocols are correct.

Tested on latest master 0123747 on macOS 10.13.6.

Example:

nemesis icmp -d en0
# generates invalid ip len of 8
18:54:16.086289 IP bad-len 8
	0x0000:  4500 0008 7395 0000 ff01 cae4 12c6 791e  E...s.........y.
	0x0010:  e31b 0e7b 0800 8241 0331 728d            ...{...A.1r.

nemesis udp -d en0
# ip length in udp packet is correct
18:53:17.276246 IP 24.220.67.47.45058 > 204.54.51.44.33435: UDP, length 0
	0x0000:  4500 001c 3f13 0000 ff11 2150 18dc 432f  E...?.....!P..C/
	0x0010:  cc36 332c b002 829b 0008 71d2            .63,......q.

RIP Injection: -i 0.0.0.0 option results in random RIP Address

I have builded nemesis 1.7 release.

Run the following command:

$ nemesis rip -v -d wlan0 -c 1 -V 1 -a 0 -R 0 -i  0.0.0.0 -k 0.0.0.0 -h 0.0.0.0 -m 16 -S 10.10.10.1                                                                                     
                                                                                                                                       
RIP Packet Injection -=- The NEMESIS Project v1.7                                                                                      

               [MAC] 20:7C:8F:11:39:13 > FF:FF:FF:FF:FF:FF
     [Ethernet type] IP (0x0800)

                [IP] 10.10.10.1 > 224.0.0.9
             [IP ID] 39436
          [IP Proto] UDP (17)
            [IP TTL] 1
            [IP TOS] 0x10
    [IP Frag offset] 0x0000
     [IP Frag flags]
         [UDP Ports] 520 > 520

       [RIP Command] Request (1)
       [RIP Version] 1
[RIP Routing domain] 0
[RIP Address family] Unknown (0)
     [RIP Route tag] 0
       [RIP Address] 117.64.14.67
  [RIP Network mask] 0.0.0.0
      [RIP Next hop] 0.0.0.0
        [RIP Metric] 16

Wrote 66 byte RIP packet through linktype DLT_EN10MB.

The [RIP Address] should have been set by -i 0.0.0.0 option, but as showed above, it is randomized.

If setting -i with a non 0.0.0.0 IP, everything is fine.

The all-zero IP address is useful for the purpose of RIP testing, so it might be better to leave the choice to the users.

bug while trying display interfaces

Error executing command
c:\GNU>nemesis.exe icmp -Z
PacketGetAdapterNames: The data area passed to a system call is too small. (122): No error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.