A Little Intro to hping3

Last night I installed hping3 in my system. The installation process is quite a bit challenging (as always :D).

Here are the steps to install hping3 on your system :

– Make sure you have the following packages installed on your system :

– libpcap and libpcap-devel
– tcl and tcl-devel

– Extract the hping3 tarball

– If your system is openSUSE 10.x, you need to apply this simple patch. Just put the patch file in the parent directory of your hping3 directory and type the following command :

$ patch -p0< hping3.patch
patching file hping3-20051105/libpcap_stuff.c
patching file hping3-20051105/script.c

– Configure your hping3 :

$ ./configure

build byteorder.c…
create byteorder.h…
===> Found Tclsh in: /usr/bin/tclsh8.4
————————————–
system type: LINUX

LIBPCAP : PCAP=-lpcap
PCAP_INCLUDE :
MANPATH : /usr/local/man
USE_TCL : -DUSE_TCL
TCL_VER : 8.4
TCL_INC :
LIBTCL : -ltcl8.4 -lm -lpthread
TCLSH : /usr/bin/tclsh8.4

(to modify try configure –help)
————————————–
creating Makefile…
creating dependences…
now you can try `make’

– Make it :

$ make
gcc -c -O2 -Wall -DUSE_TCL -g main.c
gcc -c -O2 -Wall -DUSE_TCL -g getifname.c

./hping3 -v
hping version 3.0.0-alpha-1 ($Id: release.h,v 1.4 2004/04/09 23:38:56 antirez Exp $)
This binary is TCL scripting capable
use `make strip’ to strip hping3 binary
use `make install’ to install hping3

– After that your hping3 is ready to install. You can do the suggestions offered by the script.

Here are several features of hping3 :

  • Port Scanning
  • TCP SYN Scan
  • TCP ACK Scan
  • Other TCP Scans
  • UDP Scans
  • Host Discovery
  • ICMP Ping
  • TCP Ping
  • UDP Ping
  • OS Fingerprinting
  • Sniffer
  • Backdoor
  • File Transfer
  • Covert Channel
  • Flooding
  • Fuzzing
  • Firewall/IDS Testing
  • Traceroute

I leave the commands to use each feature to you my gentle reader as exercises. :D

4 thoughts on “A Little Intro to hping3

  1. Hi,
    I applied the patch, but still can’t get it work. Here is the msg:
    gcc -c -O2 -Wall -DUSE_TCL -g main.c
    gcc -c -O2 -Wall -DUSE_TCL -g getifname.c
    getifname.c: In function ‘get_output_if’:
    getifname.c:343: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness
    gcc -c -O2 -Wall -DUSE_TCL -g getlhs.c
    gcc -c -O2 -Wall -DUSE_TCL -g parseoptions.c
    gcc -c -O2 -Wall -DUSE_TCL -g datafiller.c
    gcc -c -O2 -Wall -DUSE_TCL -g datahandler.c
    gcc -c -O2 -Wall -DUSE_TCL -g gethostname.c
    gcc -c -O2 -Wall -DUSE_TCL -g binding.c
    gcc -c -O2 -Wall -DUSE_TCL -g getusec.c
    gcc -c -O2 -Wall -DUSE_TCL -g opensockraw.c
    gcc -c -O2 -Wall -DUSE_TCL -g logicmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g waitpacket.c
    gcc -c -O2 -Wall -DUSE_TCL -g resolve.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendip.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendicmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendudp.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendtcp.c
    gcc -c -O2 -Wall -DUSE_TCL -g cksum.c
    gcc -c -O2 -Wall -DUSE_TCL -g statistics.c
    gcc -c -O2 -Wall -DUSE_TCL -g usage.c
    gcc -c -O2 -Wall -DUSE_TCL -g version.c
    gcc -c -O2 -Wall -DUSE_TCL -g antigetopt.c
    gcc -c -O2 -Wall -DUSE_TCL -g sockopt.c
    gcc -c -O2 -Wall -DUSE_TCL -g listen.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendhcmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g memstr.c
    gcc -c -O2 -Wall -DUSE_TCL -g rtt.c
    gcc -c -O2 -Wall -DUSE_TCL -g relid.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendip_handler.c
    gcc -c -O2 -Wall -DUSE_TCL -g libpcap_stuff.c
    libpcap_stuff.c: In function ‘pcap_recv’:
    libpcap_stuff.c:61: warning: pointer targets in assignment differ in signedness
    gcc -c -O2 -Wall -DUSE_TCL -g memlockall.c
    gcc -c -O2 -Wall -DUSE_TCL -g memunlockall.c
    gcc -c -O2 -Wall -DUSE_TCL -g memlock.c
    gcc -c -O2 -Wall -DUSE_TCL -g memunlock.c
    gcc -c -O2 -Wall -DUSE_TCL -g ip_opt_build.c
    gcc -c -O2 -Wall -DUSE_TCL -g display_ipopt.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendrawip.c
    gcc -c -O2 -Wall -DUSE_TCL -g signal.c
    gcc -c -O2 -Wall -DUSE_TCL -g send.c
    gcc -c -O2 -Wall -DUSE_TCL -g strlcpy.c
    gcc -c -O2 -Wall -DUSE_TCL -g arsglue.c
    gcc -c -O2 -Wall -DUSE_TCL -g random.c
    gcc -c -O2 -Wall -DUSE_TCL -g scan.c
    scan.c: In function ‘receiver’:
    scan.c:458: warning: pointer targets in assignment differ in signedness
    gcc -c -O2 -Wall -DUSE_TCL -g hstring.c
    gcc -c -O2 -Wall -DUSE_TCL -g script.c
    script.c: In function ‘GetPacketDescription’:
    script.c:265: warning: pointer targets in initialization differ in signedness
    script.c: In function ‘HpingEventCmd’:
    script.c:766: warning: suggest explicit braces to avoid ambiguous ‘else’
    gcc -c -O2 -Wall -DUSE_TCL -g interface.c
    interface.c: In function ‘hping_get_interfaces’:
    interface.c:154: warning: dereferencing type-punned pointer will break strict-aliasing rules
    gcc -c -O2 -Wall -DUSE_TCL -g adbuf.c
    adbuf.c: In function ‘adbuf_addchar’:
    adbuf.c:130: warning: pointer targets in initialization differ in signedness
    gcc -c -O2 -Wall -DUSE_TCL -g hex.c
    gcc -c -O2 -Wall -DUSE_TCL -g apdutils.c
    gcc -c -O2 -Wall -DUSE_TCL -g sbignum.c
    gcc -c -O2 -Wall -DUSE_TCL -g sbignum-tables.c
    gcc -c -O2 -Wall -DUSE_TCL -g ars.c
    gcc -c -O2 -Wall -DUSE_TCL -g apd.c
    apd.c: In function ‘ars_decode_hex’:
    apd.c:823: warning: pointer targets in return differ in signedness
    apd.c: In function ‘ars_decode_string’:
    apd.c:852: warning: pointer targets in return differ in signedness
    gcc -c -O2 -Wall -DUSE_TCL -g split.c
    gcc -c -O2 -Wall -DUSE_TCL -g rapd.c
    gcc -o hping3 -O2 -Wall -DUSE_TCL -g main.o getifname.o getlhs.o parseoptions.o datafiller.o datahandler.o gethostname.o binding.o getusec.o opensockraw.o logicmp.o waitpacket.o resolve.o sendip.o sendicmp.o sendudp.o sendtcp.o cksum.o statistics.o usage.o version.o antigetopt.o sockopt.o listen.o sendhcmp.o memstr.o rtt.o relid.o sendip_handler.o libpcap_stuff.o memlockall.o memunlockall.o memlock.o memunlock.o ip_opt_build.o display_ipopt.o sendrawip.o signal.o send.o strlcpy.o arsglue.o random.o scan.o hstring.o script.o interface.o adbuf.o hex.o apdutils.o sbignum.o sbignum-tables.o ars.o apd.o split.o rapd.o -L/usr/local/lib -lpcap -ltcl8.4 -lm -lpthread
    /usr/local/lib/libpcap.a(gencode.o): In function `pcap_compile’:
    gencode.c:(.text+0x631): undefined reference to `pcap_parse’
    collect2: ld returned 1 exit status
    make: *** [hping3] Error 1

    You have any idea?

    Thanks

  2. Hey I have the same problem as stated above. However, I am using libpcap-0.9.4

    Here is my output

    make
    gcc -c -O2 -Wall -DUSE_TCL -g main.c
    gcc -c -O2 -Wall -DUSE_TCL -g getifname.c
    getifname.c: In function ‘get_output_if’:
    getifname.c:343: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness
    /usr/include/sys/socket.h:119: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’
    getifname.c: In function ‘get_if_name’:
    getifname.c:61: warning: ‘sa.sin_addr.s_addr’ may be used uninitialized in this function
    gcc -c -O2 -Wall -DUSE_TCL -g getlhs.c
    gcc -c -O2 -Wall -DUSE_TCL -g parseoptions.c
    gcc -c -O2 -Wall -DUSE_TCL -g datafiller.c
    gcc -c -O2 -Wall -DUSE_TCL -g datahandler.c
    gcc -c -O2 -Wall -DUSE_TCL -g binding.c
    gcc -c -O2 -Wall -DUSE_TCL -g logicmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g waitpacket.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendip.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendicmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendudp.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendtcp.c
    gcc -c -O2 -Wall -DUSE_TCL -g cksum.c
    gcc -c -O2 -Wall -DUSE_TCL -g statistics.c
    gcc -c -O2 -Wall -DUSE_TCL -g version.c
    gcc -c -O2 -Wall -DUSE_TCL -g listen.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendhcmp.c
    gcc -c -O2 -Wall -DUSE_TCL -g rtt.c
    gcc -c -O2 -Wall -DUSE_TCL -g relid.c
    gcc -c -O2 -Wall -DUSE_TCL -g sendip_handler.c
    gcc -c -O2 -Wall -DUSE_TCL -g libpcap_stuff.c
    libpcap_stuff.c:20:21: error: net/bpf.h: No such file or directory
    libpcap_stuff.c: In function ‘pcap_recv’:
    libpcap_stuff.c:61: warning: pointer targets in assignment differ in signedness
    make: *** [libpcap_stuff.o] Error 1

    • Do you use the RPM version of libpcap or you compile your own ?

      If you use RPM version, please check the libpcap-devel package content by giving the following command :

      rpm -qil libpcap-devel

      The error message mention that you don’t have the required file bpf.h in net directory. In my case, the file is stored in other directory beside the one listed in the hping file, so I created the above patch to change the file location.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s