Code Monkey home page Code Monkey logo

packeth's Introduction

packETH

packETH is GUI and CLI packet generator tool for ethernet. It allows you to create and send any possible packet or sequence of packets on the ethernet link. It is very simple to use, powerful and supports many adjustments of parameters while sending packets. It runs on Linux.

With the GUI version (packETH) you can create and send packets. With the CLI version (packETHcli) you can only send already stored packets from pcap file. The CLI version also has a receiver mode, that can count packets and check if all packets that were sent were also received.

Some more information about installation, usage, GUI and CLI version and FAQ can also be found here.

Blog with some use cases.

NEWS

OCT&NOV 2023

  • migrated to GTK3 (many thanks to @qarkai)
  • vlan id field now accepts interger instead of HEX value

JUL 2019

  • packETHcli added burst mode (-m -6)

27.11.2018

  • packETHcli added receiver option (mode -m -9) to count received packets
  • packETHcli added option to incluce pattern (predifined or custom) which can be checked by packETHcli in receiver mode if all packets that were sent were also correctly received at the receiver site
  • packETHcli - nanoseconds support
  • Receiver mode
  • CLI tips

INSTALLATION

GUI

git clone https://github.com/jemcek/packETH.git

cd packETH  
./autogen.sh      # you will need aclocal, autoconf, autoheader and automake installed to run this
autoreconf -f -i  # optional - in case you get automake version mismatch, missing files etc...
./configure  
make  
make install      # optional
./packETH

Depending on your Linux distribution and type of installation additional packages may be needed. For example:

Centos 7.4 (minimal)

yum groupinstall 'Development Tools'  
yum install gtk3-devel.x86_64  
yum install dbus-x11

Ubuntu 18.04 server

sudo apt-get install build-essential  
sudo apt-get install autoconf  
sudo apt-get install pkg-config  
sudo apt-get install libgtk-3-dev
sudo apt-get install dbus-x11

CLI (you can also only compile cli version if you want)

cd cli  
make  

USAGE

GUI version

./packETH (or packETH if you did the make install)

The usage of the program should be pretty straightforward. As you will see, there are 4 main windows (first four buttons from the left side). I call them:

  • Builder - the page where you build the packet and send it once
  • Gen-b - generator for sending packet currently build inside Builder with many options how to send it
  • Gen-s - generator that allows you to select up to 10 previosly built packets and send them in different manner
  • Pcap window - open a tcpdump/wireshark capture file and load the selected packet into builder

To send the packets you need the SuperUser rights.

CLI version

Type ./packETHcli -h for available options.

RECEIVER mode

packETHcli also has a reveiver mode (-m 9). In this mode packEThcli counts packets and displays statistics. If you add a pattern into packets sent by packETH or packETHcli then only packets with valid pattern will be counted. See manual for more help.

DONATIONS

If you would like to increase my motivation for further development, you can make a donation. The amount is not important at all, it is just a sign for me, that time I spent for this project helps someone.

https://www.paypal.com/donate/?business=FZ8CFZHYDW2RJ&no_recurring=0&currency_code=EUR

AUTHORS & SUPPORT

If you get into problems, please feel free to contact me.

Miha Jemec
[email protected]
packETH (C) 2003-2023 by Miha Jemec, [email protected]
Covered under the GPL.

packeth's People

Contributors

jaapkeuter avatar jemcek avatar kayb94 avatar qarkai 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

packeth's Issues

running "make" errors out on CentOS 7.8

Could you please help bypass this issue? I'm able to locate pango lib but seeing these imcompatible errors.
How can I fix them? Thank you!

gcc  -g -O2   -o packETH src/main.o src/support.o src/interface.o src/callbacks.o src/function.o src/function_send.o src/loadpacket.o src/savepacket.o  -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lfreetype -lgthread-2.0 -lglib-2.0   -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libpangoft2-1.0.so when searching for -lpangoft2-1.0
/usr/bin/ld: skipping incompatible //lib/libpangoft2-1.0.so when searching for -lpangoft2-1.0
/usr/bin/ld: skipping incompatible //usr/lib/libpangoft2-1.0.so when searching for -lpangoft2-1.0
/usr/bin/ld: cannot find -lpangoft2-1.0
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libpangocairo-1.0.so when searching for -lpangocairo-1.0
/usr/bin/ld: skipping incompatible //lib/libpangocairo-1.0.so when searching for -lpangocairo-1.0
/usr/bin/ld: skipping incompatible //usr/lib/libpangocairo-1.0.so when searching for -lpangocairo-1.0
/usr/bin/ld: cannot find -lpangocairo-1.0
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libpango-1.0.so when searching for -lpango-1.0
/usr/bin/ld: skipping incompatible //lib/libpango-1.0.so when searching for -lpango-1.0
/usr/bin/ld: skipping incompatible //usr/lib/libpango-1.0.so when searching for -lpango-1.0
/usr/bin/ld: cannot find -lpango-1.0
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libfontconfig.so when searching for -lfontconfig
/usr/bin/ld: skipping incompatible //lib/libfontconfig.so when searching for -lfontconfig
/usr/bin/ld: skipping incompatible //usr/lib/libfontconfig.so when searching for -lfontconfig
/usr/bin/ld: cannot find -lfontconfig
collect2: error: ld returned 1 exit status
make[1]: *** [packETH] Error 1
make[1]: Leaving directory `/home/nanz/packETH'
make: *** [all] Error 2

Typo in help for packETHcli

./packETHcli -i eth0 -m 2 -d 100 -n 0 -s "8500 8500" -f packet2.pcap - send packet2.pcap infinite times with 300us between them

I believe that should be "with 100us between them"

GCC-10 stringop-truncation warnings cause CLI build to fail

When running make in the cli directory on an Ubuntu 21.04 system with gcc 10.3.0-1ubuntu1 I get the numerous of the following type of warning about strncpy. Since -Werror is active, these warnings cause the build to fail.

In file included from /usr/include/string.h:519,
                 from cli_send.c:27:
In function ‘strncpy’,
    inlined from ‘interface_setup’ at cli_send.c:1576:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ output may be truncated copying 15 bytes from a string of length 19 [-Werror=stringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~

The full build log is included in the attached build log.

build.log

Missing pthreadvc.dll on windows 10 x64

Sorry for the ignorance, but there was a missing pthreadvc.dll error. I tried to fix it with these instructions, but was unable to register it.
Any help for the process of dependencies installation would be greatly appreciated.

non zero exit code on successful exit of packETHcli

I noted that there is non consistency in the exit codes of packETHcli. On successful execution it returns non-zero (1), when incorrect parameters are provided it returns 0 or 7.
I would recommend to return 0 on successful execution (now it returns 1), then other (non-zero) values on error (or wrong parameter)

compiling CLI version on ARM

compiling CLI version on ARM platforms fails:

/tmp/ccR7C9OY.s: Assembler messages:
/tmp/ccR7C9OY.s:1126: Error: unknown mnemonic movl' -- movl (x0),x2'
/tmp/ccR7C9OY.s:1127: Error: unknown mnemonic subl' -- subl $4,x1'
...

this is because the the function ip_fast_csum() has some assembler code.

This function is only used in IDS testing mode, so temporarily, just delete everything inside this function and it will probably compile.

In GUI icmpv6 generated packet size is limited to 570bytes

In GUI for generating icmpv6 packets seems to be limitation on max number of chars in "Message body 0x" field. Fix is need in:

gtk_entry_set_max_length (GTK_ENTRY (entry214), 1024); <—— this number 1024 should be increased to somethng larger, like 3000

[crash] stack-overflow occurs when using packETHcli with snort rules

In the function readSnortRules(), the buffer new_content is allocated a space of 2048 bytes, but the write to it is without boundary checking, resulting in a stack-overflow.

Additionally, if there are rules in the Snort rule file in the format of "content: haha," the program will attempt to write to a null pointer. Refer to the crash1 example in the PoC.

// <- bug: `result` may be nullptr in this context, which could lead to a strdup(NULL)
if ((temp = strdup(result)) == NULL) {
	fprintf(stderr, "[%s:%d] Reading content failed\n",
		__FUNCTION__, __LINE__);
	exit(EXIT_FAILURE);
}
len_temp = strlen(temp);
memset(new_content, 0, MAX_CONTENT);
// new_content: char[2048]

// It is possible that len_temp > 2048
for (j = 0; j < len_temp; j++) {
	if (temp[j] == '|') {
		if (flag == false) {
			flag = true;
			continue;
		} else if (flag == true) {
			flag = false;
			continue;
		}
	}
	if (flag == true) {
		if (temp[j] == ' ')
			continue;

		memset(hex, 0, 5);
		strcpy(hex, "0x");

		ox[0] = temp[j];
		ox[1] = temp[j + 1];

		strncat(hex, ox, 2);
		sscanf(hex, "0x%2X", &hex_num);
		new_content[loc] = hex_num;          // <- bug: out-of-bound write here

		loc++;
		j++;
	} else if (flag == false) {
		new_content[loc] = temp[j];          // <- bug: out-of-bound write here
		loc++;
	}
}

Reproduce

PoC: snort_poc.zip

./packETHcli -i lo -m 5 -f crash1 -B 10 -t 60 -S1000 -a 2

AddressSanitizer:DEADLYSIGNAL
=================================================================
==3980135==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5555556299f0 bp 0x7ffffffedb30 sp 0x7ffffffed2e8 T0)
==3980135==The signal is caused by a READ memory access.
==3980135==Hint: address points to the zero page.
    #0 0x5555556299f0 in __sanitizer::internal_strlen(char const*) (/work/programs/packeth/src/cli/packETHcli+0xd59f0) (BuildId: 5e72ba3293693b9505053f30d2f7dfe0320c517c)
    #1 0x5555555fbd22 in strdup (/work/programs/packeth/src/cli/packETHcli+0xa7d22) (BuildId: 5e72ba3293693b9505053f30d2f7dfe0320c517c)
    #2 0x555555657265 in readSnortRules /work/programs/packeth/src/cli/parse_snort_rules.c:98:16
    #3 0x555555651a1f in send_ids_mode /work/programs/packeth/src/cli/cli_send.c:2046:25
    #4 0x55555564e62b in main /work/programs/packeth/src/cli/cli_send.c:436:13
    #5 0x7ffff7cea6c9  (/lib/x86_64-linux-gnu/libc.so.6+0x276c9) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #6 0x7ffff7cea784 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27784) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #7 0x5555555773c0 in _start (/work/programs/packeth/src/cli/packETHcli+0x233c0) (BuildId: 5e72ba3293693b9505053f30d2f7dfe0320c517c)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/work/programs/packeth/src/cli/packETHcli+0xd59f0) (BuildId: 5e72ba3293693b9505053f30d2f7dfe0320c517c) in __sanitizer::internal_strlen(char const*)
==3980135==ABORTING
./packETHcli -i lo -m 5 -f crash3 -B 10 -t 60 -S1000 -a 2

=================================================================
==3980177==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffff66018c0 at pc 0x555555657687 bp 0x7ffffffedb30 sp 0x7ffffffedb28
WRITE of size 1 at 0x7ffff66018c0 thread T0
    #0 0x555555657686 in readSnortRules /work/programs/packeth/src/cli/parse_snort_rules.c:127:23
    #1 0x555555651a1f in send_ids_mode /work/programs/packeth/src/cli/cli_send.c:2046:25
    #2 0x55555564e62b in main /work/programs/packeth/src/cli/cli_send.c:436:13
    #3 0x7ffff7cea6c9  (/lib/x86_64-linux-gnu/libc.so.6+0x276c9) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #4 0x7ffff7cea784 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27784) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #5 0x5555555773c0 in _start (/work/programs/packeth/src/cli/packETHcli+0x233c0) (BuildId: 5e72ba3293693b9505053f30d2f7dfe0320c517c)

Address 0x7ffff66018c0 is located in stack of thread T0 at offset 6336 in frame
    #0 0x555555656b8f in readSnortRules /work/programs/packeth/src/cli/parse_snort_rules.c:26

  This frame has 6 object(s):
    [32, 40) 'saveptr' (line 28)
    [64, 4160) 'line' (line 29)
    [4288, 6336) 'new_content' (line 29) <== Memory access at offset 6336 overflows this variable
    [6464, 6466) 'ox' (line 29)
    [6480, 6484) 'hex_num' (line 30)
    [6496, 6502) 'hex' (line 31)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /work/programs/packeth/src/cli/parse_snort_rules.c:127:23 in readSnortRules
Shadow bytes around the buggy address:
  0x7ffff6601600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x7ffff6601880: 00 00 00 00 00 00 00 00[f2]f2 f2 f2 f2 f2 f2 f2
  0x7ffff6601900: f2 f2 f2 f2 f2 f2 f2 f2 02 f2 04 f2 06 f3 f3 f3
  0x7ffff6601980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ffff6601b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3980177==ABORTING

Possible fix

Add some checks.

check for nanosecond support

When building packETH there should be a check inside the configure script is nanosecond support in not available in the kernel. In the case it is not, the user currently does not get any indication why packets are not sent on the wire

MTU check

If built packet is larger than MTU on the interface the packet can not be sent. The problem is, you don't get any warning. Maybe a message in the status bar would be an option?

Incorrect UDP checksum when using -x option

When sending UDP packets with the -x option, the checksum of the UDP is not adjusted. This causes packet receivers that verify the checksum to fail (e.g. socat). Either the checksum should be recalculated and adjusted or the checksum should be set to zero to indicate there is no checksum. Note that this likely applies to TCP packets as well, but I haven't tested that explicitly.

I have attached a pcap (bad_csum.pcap) file that contains two packets. The first was sent with the command
sudo packETHcli -m 2 -n 1 -i eno1 -f src-fwd.pcap -d 0
and the second was sent with the command
sudo packETHcli -m 2 -n 1 -i eno1 -f src-fwd.pcap -d 0 -x
The pcap shows that with -x the marker and sequence number are properly set, but the checksum is identical to that of the packet sent without the -x option. I have also attached the packet being sent as src-fwd.pcap.

bad_csum.zip

Error in compilation

I don't know whether it is mine or common...
While compiling I receive the following error:
gcc -g -O2 -o packETH src/main.o src/support.o src/interface.o src/callbacks.o src/function.o src/function_send.o src/loadpacket.o src/savepacket.o -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lharfbuzz -lfontconfig -lfreetype -lgthread-2.0 -pthread -lglib-2.0 -lm
/usr/bin/ld: src/function_send.o:/home/leonp/packETH-master/src/function_send.c:58: multiple definition of `iftext'; src/callbacks.o:/home/leonp/packETH-master/src/callbacks.c:68: first defined here
IMHO, both are defined without "static" or "extern", which causes the error.
Can I declare both statics or one external?

Build fails with LTO

I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Note the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.

I got this error:

x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o packETH src/pixmaps.o src/ui.o src/main.o src/support.o src/interface.o src/callbacks.o src/function.o src/function_send.o src/loadpacket.o src/savepacket.o  -lpthread -lm  -lgtk-3 -lgdk-3 -lharfbuzz -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo -lcairo-gobject -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lm
src/callbacks.c:63:22: error: type of ‘packet’ does not match original declaration [-Werror=lto-type-mismatch]
   63 | extern unsigned char packet[9300];
      |                      ^
src/function.c:55:15: note: array types have different bounds
   55 | unsigned char packet[100001];
      |               ^
src/function_send.c:50:22: error: type of ‘packet’ does not match original declaration [-Werror=lto-type-mismatch]
   50 | extern unsigned char packet[10000];
      |                      ^
src/function.c:55:15: note: array types have different bounds
   55 | unsigned char packet[100001];
      |               ^
src/function.c:55:15: note: ‘packet’ was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:482: packETH] Error 1

Downstream report: https://bugs.gentoo.org/861695
Full build log: build.log

missing git tags for packaging

Hi, can you please push git tags like 1.9 and 2.0? That would aid packaging this for distro repos and would be very much appreciated.

'make' and 'make install' fails on OS X 10.13.4

make
make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-am
depbase=echo src/callbacks.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
gcc -DPKGDATADIR="/usr/local/share/packeth/" -I. -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -Wunused -D_REENTRANT -I/usr/local/Cellar/gtk+/2.24.32_2/include/gtk-2.0 -I/usr/local/Cellar/gtk+/2.24.32_2/lib/gtk-2.0/include -I/usr/local/Cellar/pango/1.42.4/include/pango-1.0 -I/usr/local/Cellar/harfbuzz/1.8.8/include/harfbuzz -I/usr/local/Cellar/graphite2/1.3.12/include -I/usr/local/Cellar/pango/1.42.4/include/pango-1.0 -I/usr/local/Cellar/fribidi/1.0.5/include/fribidi -I/usr/local/Cellar/atk/2.28.1_2/include/atk-1.0 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.35/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/libpng/1.6.35/include/libpng16 -I/usr/local/Cellar/glib/2.56.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/opt/icu4c/include -g -O2 -MT src/callbacks.o -MD -MP -MF $depbase.Tpo -c -o src/callbacks.o src/callbacks.c &&
mv -f $depbase.Tpo $depbase.Po
src/callbacks.c:47:10: fatal error: 'linux/sockios.h' file not found
#include <linux/sockios.h>
^~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [src/callbacks.o] Error 1
make: *** [all] Error 2

make install
depbase=echo src/callbacks.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
gcc -DPKGDATADIR="/usr/local/share/packeth/" -I. -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -Wunused -D_REENTRANT -I/usr/local/Cellar/gtk+/2.24.32_2/include/gtk-2.0 -I/usr/local/Cellar/gtk+/2.24.32_2/lib/gtk-2.0/include -I/usr/local/Cellar/pango/1.42.4/include/pango-1.0 -I/usr/local/Cellar/harfbuzz/1.8.8/include/harfbuzz -I/usr/local/Cellar/graphite2/1.3.12/include -I/usr/local/Cellar/pango/1.42.4/include/pango-1.0 -I/usr/local/Cellar/fribidi/1.0.5/include/fribidi -I/usr/local/Cellar/atk/2.28.1_2/include/atk-1.0 -I/usr/local/Cellar/cairo/1.14.12/include/cairo -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.0/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.35/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.36.12/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/libpng/1.6.35/include/libpng16 -I/usr/local/Cellar/glib/2.56.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.42/include -I/usr/local/opt/icu4c/include -g -O2 -MT src/callbacks.o -MD -MP -MF $depbase.Tpo -c -o src/callbacks.o src/callbacks.c &&
mv -f $depbase.Tpo $depbase.Po
src/callbacks.c:47:10: fatal error: 'linux/sockios.h' file not found
#include <linux/sockios.h>
^~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/callbacks.o] Error 1

Build fails

Hi! I'm interested in using this software for a project. Attempted to build on an Ubuntu 20.04 system, and the build fails with the error seen here.

gcc  -g -O2   -o packETH src/main.o src/support.o src/interface.o src/callbacks.o src/function.o src/function_send.o src/loadpacket.o src/savepacket.o  -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lharfbuzz -lfontconfig -lfreetype -lgthread-2.0 -pthread -lglib-2.0 -lm
/usr/bin/ld: src/function_send.o:/home/johnathan/Documents/packeth/src/function_send.c:58: multiple definition of `iftext'; src/callbacks.o:/home/johnathan/Documents/packeth/src/callbacks.c:68: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:477: packETH] Error 1

packETHcli receiver mode counts packets twice

In same cases the receiver mode counts packets twice. If you start the generator and the receiver both on the same interface (lo for example) the receiver will also count the transmitted packets. Thus all the statistics including sequence error will be wrong.

Need to add flag to ioctl calls that only received packets will be passed to receiver.

icmpv6 load info field

When loading pcap file which contains ICMPv6 packets, try to disect which type of packet is it (RA, NA, ND etc)

[crash] packETHcli has a buffer overflow issue when the packet is too long

In function read_packet_from_file(), variable params1.ph.incl_len is used without an overflow check. This can lead to some variables being overwritten or the program crashing.

/* copy the 16 bytes into ph structure */
memcpy(&params1.ph, params1.pkt_temp, 16);    
params1.ptr = params1.pkt_temp + sizeof(params1.ph);

/* and the packet itself, but only up to the capture length */
freads = fread(params1.ptr, params1.ph.incl_len, 1, file_p);       // uint32_t incl_len is read from pcap file

The length of the pkt_temp buffer is 10000. If the packet exceeds this length, variables in .bss section will be overwritten.

image

Reproduce

Poc: mypoc.zip

CC=clang CFLAGS="-O0 -g -fsanitize=address" make
./packETHcli -i lo -f ./mypoc.pcap

Asan report:

=================================================================
==366700==ERROR: AddressSanitizer: global-buffer-overflow on address 0x555555fefe68 at pc 0x555555594dd5 bp 0x7fffffffde60 sp 0x7fffffffd630
WRITE of size 11000 at 0x555555fefe68 thread T0
    #0 0x555555594dd4 in fread (/work/programs/packeth/origin/cli/packETHcli+0x40dd4) (BuildId: 87a631790a9eaae61db995e5c5764db95f25d64e)
    #1 0x55555564f543 in read_packet_from_file /work/programs/packeth/origin/cli/cli_send.c:1680:22
    #2 0x55555564e5ce in main /work/programs/packeth/origin/cli/cli_send.c:415:13
    #3 0x7ffff7cea6c9  (/lib/x86_64-linux-gnu/libc.so.6+0x276c9) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #4 0x7ffff7cea784 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27784) (BuildId: 8a1bf172e710f8ca0c1576912c057b45f90d90d8)
    #5 0x5555555773c0 in _start (/work/programs/packeth/origin/cli/packETHcli+0x233c0) (BuildId: 87a631790a9eaae61db995e5c5764db95f25d64e)

0x555555fefe68 is located 0 bytes after global variable 'params1' defined in '/work/programs/packeth/origin/cli/cli_send.c:124' (0x555555fed480) of size 10728
SUMMARY: AddressSanitizer: global-buffer-overflow (/work/programs/packeth/origin/cli/packETHcli+0x40dd4) (BuildId: 87a631790a9eaae61db995e5c5764db95f25d64e) in fread
Shadow bytes around the buggy address:
  0x555555fefb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x555555fefc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x555555fefc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x555555fefd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x555555fefd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x555555fefe00: 00 00 00 00 00 00 00 00 00 00 00 00 00[f9]f9 f9
  0x555555fefe80: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x555555feff00: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x555555feff80: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x555555ff0000: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x555555ff0080: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==366700==ABORTING

Possible fix

If a packet exceeds the maximum length of ETH, it indicates that the pcap file is corrupt. The program can abort processing and report an 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.