Darkkey / erlamsa

Erlang port of famous radamsa fuzzzer.
MIT License
66 stars 10 forks source link

Compiling errors #8

Closed enovella closed 5 years ago

enovella commented 5 years ago

Just cloned the repo and got this error:

[20:23 edu@de11 erlamsa] >  sudo apt-get install git gcc make erlang erlang-dev erlang-tools erlang-ssl erlang-eunit erlang-mnesia erlang-inets
[sudo] password for edu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
erlang-dev is already the newest version (1:20.2.2+dfsg-1ubuntu2).
erlang-eunit is already the newest version (1:20.2.2+dfsg-1ubuntu2).
erlang-inets is already the newest version (1:20.2.2+dfsg-1ubuntu2).
erlang-mnesia is already the newest version (1:20.2.2+dfsg-1ubuntu2).
erlang-ssl is already the newest version (1:20.2.2+dfsg-1ubuntu2).
erlang-tools is already the newest version (1:20.2.2+dfsg-1ubuntu2).
make is already the newest version (4.1-9.1ubuntu1).
erlang is already the newest version (1:20.2.2+dfsg-1ubuntu2).
gcc is already the newest version (4:7.3.0-3ubuntu2.1).
git is already the newest version (1:2.17.1-1ubuntu0.4).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
[20:24 edu@de11 erlamsa] >  make
./rebar get-deps
==> procket (get-deps)
==> erlserial (get-deps)
==> erlamsa (get-deps)
./rebar compile
==> procket (compile)
make[1]: Entering directory '/home/edu/tools/fuzz/erlamsa/deps/procket/c_src'
make -f /home/edu/tools/fuzz/erlamsa/deps/procket/c_src/Makefile.ancillary
make[2]: Entering directory '/home/edu/tools/fuzz/erlamsa/deps/procket/c_src'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/edu/tools/fuzz/erlamsa/deps/procket/c_src'
cc -m64 -DHAVE_SETNS -g -Wall -o /home/edu/tools/fuzz/erlamsa/deps/procket/priv/procket -L/home/edu/tools/fuzz/erlamsa/deps/procket/c_src procket_cmd.c -lancillary
cc /home/edu/tools/fuzz/erlamsa/deps/procket/c_src/procket.o -shared -L/home/edu/tools/fuzz/erlamsa/deps/procket/c_src -lancillary -L /usr/lib/erlang/lib/erl_interface-3.10.1/lib -lerl_interface -lei -o /home/edu/tools/fuzz/erlamsa/deps/procket/c_src/../priv/procket.so
make[1]: Leaving directory '/home/edu/tools/fuzz/erlamsa/deps/procket/c_src'
==> erlserial (compile)
make[1]: Entering directory '/home/edu/tools/fuzz/erlamsa/deps/erlserial'
erlc -o ebin src/slip.erl
make[1]: Leaving directory '/home/edu/tools/fuzz/erlamsa/deps/erlserial'
/usr/bin/ld: c_src/serial.o: relocation R_X86_64_PC32 against symbol `bitrate_table' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ERROR: sh(cc c_src/serial.o  -shared  -L"/usr/lib/erlang/lib/erl_interface-3.10.1/lib" -lerl_interface -lei -o priv/erlserial_drv.so)
failed with return code 1 and the following output:
/usr/bin/ld: c_src/serial.o: relocation R_X86_64_PC32 against symbol `bitrate_table' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

ERROR: compile failed while processing /home/edu/tools/fuzz/erlamsa/deps/erlserial: rebar_abort
Makefile:7: recipe for target 'compile' failed
make: *** [compile] Error 1
Darkkey commented 5 years ago

Hey, could you please give details on your Linux distrib and also erlang version installed (just run erl for it and copy output here)?

enovella commented 5 years ago
[21:05 edu@de11 erlamsa] >  lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic

[21:05 edu@de11 erlamsa] >  erl 
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [kernel-poll:false]

Eshell V9.2  (abort with ^G)
1> 

[21:18 edu@de11 erlamsa] >  ld -v
GNU ld (GNU Binutils for Ubuntu) 2.30
21:18 edu@de11 erlamsa] >  gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) 
Darkkey commented 5 years ago

I've reproduced the problem, will try to fix it soon. Thanks.

Darkkey commented 5 years ago

Should be fixed. The bug was in the dependancy, so please do a full rebuild from scratch as:

cd erlamsa
rm -rf deps
./rebar clean
./rebar get-deps
./rebar co

Thank you so much again. You've catched a bad timing (or a good timing), right after major update :)

enovella commented 5 years ago

Very sweet!

[22:17 edu@de11 erlamsa] >  echo "eduardo" | ./eerlamsa 
ed���󠁎�uarddo[22:17 edu@de11 erlamsa] >  echo "eduardo" | ./eerlamsa 
eurdo
rdo
rdo

However, I cannot see the help:

[22:17 edu@de11 erlamsa] >  ./eerlamsa --help
escript: exception error: bad argument
  in function  unicode:characters_to_list/2
     called as unicode:characters_to_list(["Usage: erlamsa",
                                           [" [-A [<ascent>]]"," [-a]",
                                            " [-b [<blockscale>]]",
                                            " [-B [<bypass>]]",10],
                                           ["              ",
                                            " [--certfile <certfile>]",
                                            " [-d]"," [-D]",
                                            " [-e <external>]",10],
                                           ["              ",
                                            [32,91,45,undefine,32,91,60,102,
                                             97,105,108,100,101,108,97,121,62,
                                             93,93],
                                            " [-g [<generators>]]",
                                            " [-G <genfuzz>]"," [-h]",10],
                                           ["              ",
                                            " [-H <httpsvc>]"," [-i <input>]",
                                            " [--keyfile <keyfile>]"," [-l]",
                                            10],
                                           ["              "," [-L <logger>]",
                                            " [--maxfails [<maxfails>]]",10],
                                           ["              ",
                                            " [--maxrunningtime [<maxrunningtime>]]",
                                            " [-M [<meta>]]",10],
                                           ["              ",
                                            " [-m [<mutations>]]",
                                            " [-n [<count>]]",
                                            " [--no-io-logging]",10],
                                           ["              ",
                                            " [-O <monitor>]",
                                            " [-o [<output>]]",
                                            " [-p [<patterns>]]",10],
                                           ["              ",
                                            " [--pidfile <pidfile>]",
                                            " [-P <proxyprob>]",
                                            " [-s <seed>]",10],
                                           ["              ",
                                            " [-S [<sleep>]]",
                                            " [-v [<verbose>]]"," [-V]",
                                            " [-w <workers>]"," [file",10],
                                           ["              "," ...]"]],
                                          unicode)
  in call from unicode:characters_to_list/1 (unicode.erl, line 108)
  in call from getopt:usage/4 (src/getopt.erl, line 554)
  in call from erlamsa_cmdparse:parse_opts/2 (src/erlamsa_cmdparse.erl, line 436)
  in call from erlamsa:main/2 (src/erlamsa.erl, line 13)
Darkkey commented 5 years ago

Stupid mistype :( Should be fixed in the latest commit. Thanks again!

Darkkey commented 5 years ago

Btw, @enovella, why are you trying to use eerlamsa instead of erlamsa? eerlamsa script is not very suitable for using and is left only for compatibility reasons / or if you need to launch a lot of erlamsa's at once. Try use erlamsa instead. (I hope it works :) )

enovella commented 5 years ago

Yeah I realized after posting it but the erlamsa binary produces the same buggy output....

[23:11 edu@de11 erlamsa] >  ./erlamsa --help
escript: exception error: bad argument
  in function  unicode:characters_to_list/2
     called as unicode:characters_to_list(["Usage: erlamsa",
                                           [" [-A [<ascent>]]"," [-a]",
                                            " [-b [<blockscale>]]",
                                            " [-B [<bypass>]]",10],
                                           ["              ",
                                            " [--certfile <certfile>]",
                                            " [-d]"," [-D]",
                                            " [-e <external>]",10],
                                           ["              ",
                                            [32,91,45,undefine,32,91,60,102,
                                             97,105,108,100,101,108,97,121,62,
                                             93,93],
                                            " [-g [<generators>]]",
                                            " [-G <genfuzz>]"," [-h]",10],
                                           ["              ",
                                            " [-H <httpsvc>]"," [-i <input>]",
                                            " [--keyfile <keyfile>]"," [-l]",
                                            10],
                                           ["              "," [-L <logger>]",
                                            " [--maxfails [<maxfails>]]",10],
                                           ["              ",
                                            " [--maxrunningtime [<maxrunningtime>]]",
                                            " [-M [<meta>]]",10],
                                           ["              ",
                                            " [-m [<mutations>]]",
                                            " [-n [<count>]]",
                                            " [--no-io-logging]",10],
                                           ["              ",
                                            " [-O <monitor>]",
                                            " [-o [<output>]]",
                                            " [-p [<patterns>]]",10],
                                           ["              ",
                                            " [--pidfile <pidfile>]",
                                            " [-P <proxyprob>]",
                                            " [-s <seed>]",10],
                                           ["              ",
                                            " [-S [<sleep>]]",
                                            " [-v [<verbose>]]"," [-V]",
                                            " [-w <workers>]"," [file",10],
                                           ["              "," ...]"]],
                                          unicode)
  in call from unicode:characters_to_list/1 (unicode.erl, line 108)
  in call from getopt:usage/4 (src/getopt.erl, line 554)
  in call from erlamsa_cmdparse:parse_opts/2 (src/erlamsa_cmdparse.erl, line 436)
  in call from erlamsa:main/2 (src/erlamsa.erl, line 13)
  in call from escript:run/2 (escript.erl, line 759)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1 
Darkkey commented 5 years ago

Should be already fixed in https://github.com/Darkkey/erlamsa/commit/f1d6fe9c512db52d4174a505834fd9ca44f9c386 (see upper), could you please update & check?

enovella commented 5 years ago

Absolutely!

enovella commented 5 years ago

BINGO!

We're in business now

[23:14 edu@de11 erlamsa] >  ./erlamsa --help
Usage: erlamsa [-A [<ascent>]] [-a] [-b [<blockscale>]] [-B [<bypass>]]
               [--certfile <certfile>] [-d] [-D] [-e <external>]
               [--faildelay [<faildelay>]] [-g [<generators>]]
               [-G <genfuzz>] [-h] [-H <httpsvc>] [-i <input>]
               [--keyfile <keyfile>] [-l] [-L <logger>]
               [--maxfails [<maxfails>]]
               [--maxrunningtime [<maxrunningtime>]] [-M [<meta>]]
               [-m [<mutations>]] [-n [<count>]] [--no-io-logging]
               [-O <monitor>] [-o [<output>]] [-p [<patterns>]]
               [--pidfile <pidfile>] [-P <proxyprob>] [-s <seed>]
               [-S [<sleep>]] [-v [<verbose>]] [-V] [-w <workers>] [file
               ...]

  -A, --ascent       <arg>, fuzzing proxy: use ascent/descent coefficient 
                     for fuzzing probability (TCP/HTTP only) [default: 1.0]
  -a, --about        what is this thing
  -b, --blockscale   <arg>, increase/decrease default min (256 bytes) 
                     fuzzed blocksize multiplier [default: 1.0]
  -B, --bypass       <arg>, fuzzing proxy: bypass first <arg> packets 
                     before start fuzzing (TCP/HTTP only) [default: 0]
  --certfile         <arg>, certificate file for fuzzing TLS-based 
                     communications
  -d, --debug        run in debug/profiler mode, activates verbose
  -D, --detach       detach from console after start (service mode)
  -e, --external     external pre/post/generation/mutation module
  --faildelay        <arg>, additional delay (in ms.) after failed attempt 
                     to output data to the network [default: 0]
  -g, --generators   <arg>, which data generators to use [default: 
                     stdin,file,direct,jump,random,]
  -G, --genfuzz      <arg>, activate generation-based fuzzer, arg is base 
                     probablity
  -h, --help         show this thing
  -H, --httpservice  <arg>, run as HTTP service on <host:port>, e.g.: 
                     127.0.0.1:17771
  -i, --input        <arg>, special input, e.g. 
                     proto://lport:[udpclientport:]rhost:rport (fuzzing 
                     proxy) or proto://:port, proto://host:port for data 
                     endpoint (generation mode)
  --keyfile          <arg>, key file for fuzzing TLS-based communications
  -l, --list         list i/o options, monitors, mutations, patterns and 
                     generators
  -L, --logger       <arg>, logger options, e.g. level=critical..debug, 
                     file=filename, csv=filename.csv, mnesia=dir or stdout 
                     (-) or stderr (-err)
  --maxfails         <arg>, maximum failed attempts to output data to the 
                     network before giving up [default: 10]
  --maxrunningtime   <arg>, maximum running time for fuzzing instance 
                     (service/proxy modes only) [default: 30]
  -M, --meta         <arg>, save metadata about fuzzing process to this 
                     file or stdout (-) or stderr (-err) [default: nil]
  -m, --mutations    <arg>, which mutations to use [default: 
                     nil=0,zip,uri,b64=2,len=2,fo=2,fn,ft=2,lrs,lis,lp,ls,l
                     r,lri,lr2,lds,ld,srnd,snand,sd,sr,sp,br,ber,bi,bf,bed,
                     bei,bd,ts2=2,tr=2,ts1=2,num=3,td,tr2,ad,ab,ui=2,uw,js=
                     2,sgm=10,]
  -n, --count        <arg>, how many outputs to generate (number or inf) 
                     [default: 1]
  --no-io-logging    disable logging of incoming and outgoing data
  -O, --monitor      +-<arg>, add/remove monitor (use additional -O for 
                     each monitor
  -o, --output       <arg>, output pattern, e.g. /tmp/fuzz-%n.foo, -, 
                     [proto]://192.168.0.1:80 or [proto]://:80 [-] 
                     [default: -]
  -p, --patterns     <arg>, which mutation patterns to use [default: 
                     nu,cp,ar,cs,sz,sk,bu,nd,od,]
  --pidfile          <arg>, PID file name
  -P, --proxy        <arg>, activate fuzzing proxy mode, param is fuzzing 
                     probability in form of s->c,c->s e.g.: 0.5,0.5
  -s, --seed         <arg>, random seed in erlang format: int,int,int or 
                     source:device for an external source of entropy (e.g. 
                     binary file)
  -S, --sleep        <arg>, sleep time (in ms.) between output iterations 
                     [default: 0]
  -v, --verbose      be more verbose, show some progress during generation 
                     [default: 0]
  -V, --version      show program version
  -w, --workers      <arg>, number of working threads (1 for standalone, 
                     10 for proxy/fass)

Should we close the issue now? Is there something to fix in the Makefile?

Darkkey commented 5 years ago

Makefile should be ok. I've fixed Makefile for erlserial (it's a dependancy package). Please let me know if you'll find other bugs (as I've said, it was a major update yesterday/today, haven't got a chance to test everything properly).

enovella commented 5 years ago

Will do. Planning to do some protocol fuzzing using radamsa/erlamsa. Will share my feedback about the tool. Thanks for the quick fix and keep up the good work!

Darkkey commented 5 years ago

Thanks :) just create an issue if you'll have any questions on how to use erlamsa. It still lacks of proper documentation, don't have enough time to write it.