tomac / yersinia

A framework for layer 2 attacks
GNU General Public License v2.0
690 stars 117 forks source link

Build for mips64 #78

Open soxrok2212 opened 11 months ago

soxrok2212 commented 11 months ago

Hi!

I'm trying make a statically linked mips64 binary. I've built libpcap and libnet with mips64-linux-gnuabi64- cross compiler just fine and specified the paths, as well as added the -static flag. 2 problems arise.

  1. If I don't specify the includes path, the pcap version check fails:

    $ CFLAGS="-static -I../libpcap/include" CC=mips64-linux-gnuabi64-gcc CXX=mips64-linux-gnuabi64-g++ ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=../libpcap --with-libnet-includes=../libnet
    checking build system type... aarch64-unknown-linux-gnu
    checking host system type... mips64-unknown-linux-gnuabi64
    checking target system type... mips64-unknown-linux-gnuabi64
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for mips64-linux-gnuabi64-strip... mips64-linux-gnuabi64-strip
    checking for a race-free mkdir -p... /usr/bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking for mips64-linux-gnuabi64-gcc... mips64-linux-gnuabi64-gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... yes
    checking for suffix of object files... o
    checking whether the compiler supports GNU C... yes
    checking whether mips64-linux-gnuabi64-gcc accepts -g... yes
    checking for mips64-linux-gnuabi64-gcc option to enable C11 features... none needed
    checking whether mips64-linux-gnuabi64-gcc understands -c and -o together... yes
    checking whether make supports the include directive... yes (GNU style)
    checking dependency style of mips64-linux-gnuabi64-gcc... none
    checking for stdio.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for strings.h... yes
    checking for sys/stat.h... yes
    checking for sys/types.h... yes
    checking for unistd.h... yes
    checking for sys/time.h... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for makedepend... no
    checking if unaligned accesses fail... yes
    checking for main in -lsocket... no
    checking for main in -lresolv... yes
    checking for main in -lnsl... no
    checking for main in -lrt... yes
    checking for a complete set of pcap headers... found ../libpcap
    checking for pcap_lib_version in -lpcap... no
    checking for pcap_dump_flush in -lpcap... no
    checking for BPF device sending support... configure: error: in `/home/soxrok2212/mips64/yersinia':
    configure: error: cannot run test program while cross compiling
    See `config.log' for more details
  2. If I specify it the includes, it seems to fail during testing? or something with Berkeley Packet Filters, understandable since its being building on an arm64 system.

    $ LDFLAGS=-L../libpcap  CFLAGS="-static -I../libpcap/include" CC=mips64-linux-gnuabi64-gcc CXX=mips64-linux-gnuabi64-g++ ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=../libpcap --with-libnet-includes=../libnet
    checking build system type... aarch64-unknown-linux-gnu
    checking host system type... mips64-unknown-linux-gnuabi64
    checking target system type... mips64-unknown-linux-gnuabi64
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for mips64-linux-gnuabi64-strip... mips64-linux-gnuabi64-strip
    checking for a race-free mkdir -p... /usr/bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking for mips64-linux-gnuabi64-gcc... mips64-linux-gnuabi64-gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... yes
    checking for suffix of object files... o
    checking whether the compiler supports GNU C... yes
    checking whether mips64-linux-gnuabi64-gcc accepts -g... yes
    checking for mips64-linux-gnuabi64-gcc option to enable C11 features... none needed
    checking whether mips64-linux-gnuabi64-gcc understands -c and -o together... yes
    checking whether make supports the include directive... yes (GNU style)
    checking dependency style of mips64-linux-gnuabi64-gcc... none
    checking for stdio.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for strings.h... yes
    checking for sys/stat.h... yes
    checking for sys/types.h... yes
    checking for unistd.h... yes
    checking for sys/time.h... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for makedepend... no
    checking if unaligned accesses fail... yes
    checking for main in -lsocket... no
    checking for main in -lresolv... yes
    checking for main in -lnsl... no
    checking for main in -lrt... yes
    checking for a complete set of pcap headers... found ../libpcap
    checking for pcap_lib_version in -lpcap... yes
    checking for pcap_dump_flush in -lpcap... yes
    checking for BPF device sending support... configure: error: in `/home/soxrok2212/mips64/yersinia':
    configure: error: cannot run test program while cross compiling
    See `config.log' for more details

Any ideas?

soxrok2212 commented 11 months ago

I did get this to work, though it was a bit convoluted. In the end, my build command was: CC=mips64-linux-gnuabi64-gcc ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=/path/to/compiled/libpcap --with-libnet-includes=/path/to/compiled/libnet/include --disable-gtk --disable-admin --with-ncurses=/path/to/compiled/ncurses

Some caveats:

And then, it successfully built a statically linked binary that worked. So if there are any authors still working on this lovely project, there's a little bit of work needed to make cross compiling work effectively. I'm not very familiar with autoconf, else I'd make a PR of my own. Perhaps I'll try when I get some more time.

aoshiken commented 11 months ago

Good work @soxrok2212