hping
hping copied to clipboard
adjust Makefile.in (add docs, man), fix build
I have added support for $(DESTDIR), docs, man pages too for French in Makefile.in
cat hping-3.0.0_alpha_1-Makefile.in.patch
--- Makefile.in.orig 2014-12-25 15:01:43.000000000 +0100
+++ Makefile.in 2014-12-26 08:06:25.681410513 +0100
@@ -9,14 +9,19 @@
CC= gcc
AR=/usr/bin/ar
RANLIB=/usr/bin/ranlib
-CCOPT= -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
+CCOPT= $(CFLAGS) -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
DEBUG= -g
#uncomment the following if you need libpcap based build under linux
#(not raccomanded)
COMPILE_TIME=
-INSTALL_MANPATH=@MANPATH@
@PCAP@
+DOCS = AUTHORS *BUGS CHANGES COPYING NEWS README TODO
+DOCS_EN = docs/*.txt docs/AS-BACKDOOR docs/HPING2-IS-OPEN docs/MORE-FUN-WITH-IPID
+DOCS_FR = docs/french/*.txt docs/french/AS-BACKDOOR docs/french/HPING2-IS-OPEN docs/french/MORE-FUN-WITH-IPID
+MANS = docs/hping2.8 docs/hping3.8
+MANS_FR = docs/french/hping2-fr.8
+
ARSOBJ = ars.o apd.o split.o rapd.o
OBJ= main.o getifname.o getlhs.o \
@@ -72,17 +77,18 @@
rm -rf hping3 *.o byteorder byteorder.h systype.h Makefile libars.a .depend
rm -rf hping3 *.o byteorder byteorder.h systype.h Makefile libars.a .depend
install: hping3
- cp -f hping3 /usr/sbin/
- chmod 755 /usr/sbin/hping3
- ln -s /usr/sbin/hping3 /usr/sbin/hping
- ln -s /usr/sbin/hping3 /usr/sbin/hping2
- @if [ -d ${INSTALL_MANPATH}/man8 ]; then \
- cp ./docs/hping3.8 ${INSTALL_MANPATH}/man8; \
- chmod 644 ${INSTALL_MANPATH}/man8/hping3.8; \
- else \
- echo "@@@@@@ WARNING @@@@@@"; \
- echo "Can't install the man page: ${INSTALL_MANPATH}/man8 does not exist"; \
- fi
+ install -m 0755 -d $(DESTDIR)/usr/sbin
+ install -m 0755 -d $(DESTDIR)/usr/share/man/man8
+ install -m 0755 -d $(DESTDIR)/usr/share/man/fr/man8
+ install -m 0755 -d $(DESTDIR)/usr/share/doc/packages/hping/docs/french
+ install -m 0755 hping3 $(DESTDIR)/usr/sbin/
+ ln -s /usr/sbin/hping3 hping
+ ln -s /usr/sbin/hping3 hping2
+ install -m 0644 $(MANS) $(DESTDIR)/usr/share/man/man8/
+ install -m 0644 $(MANS_FR) $(DESTDIR)/usr/share/man/fr/man8/
+ install -m 0644 $(DOCS) $(DESTDIR)/usr/share/doc/packages/hping/
+ install -m 0644 $(DOCS_EN) $(DESTDIR)/usr/share/doc/packages/hping/docs/
+ install -m 0644 $(DOCS_FR) $(DESTDIR)/usr/share/doc/packages/hping/docs/french/
strip: hping3
@ls -l ./hping3
This changes fix build
I use this sed to fix build with scan.c
sed -i 's|icmp, p, sizeof(subtcp|icmp, p, sizeof(icmp|' scan.c
Without this sed get
[ 19s] I: Statement is overflowing a buffer
[ 19s] E: hping bufferoverflow /usr/include/bits/string3.h:51
I use this patch to fix build with ars.c
cat hping-3.0.0_alpha_1-ars.c.patch
--- ars.c.orig 2014-12-25 15:01:43.000000000 +0100
+++ ars.c 2014-12-26 07:50:20.883410513 +0100
@@ -481,8 +481,8 @@
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
return (u_int16_t) ~sum;
- } else {
- assert("else reached in ars_multi_cksum()" == "");
+// } else {
+// assert("else reached in ars_multi_cksum()" == "");
}
return 0; /* unreached, here to prevent warnings */
}
Without this patch get
[ 16s] I: Expression compares a char* pointer with a string literal.
[ 16s] Usually a strcmp() was intended by the programmer
[ 16s] E: hping stringcompare ars.c:485
Please correct these build warnings and release new commit when is all fixed, too Issue #9
[ 9s] getifname.c:343:35: warning: pointer targets in passing argument 3 of 'getsockname' differ in signedness [-Wpointer-sign]
[ 9s] if (getsockname(sock_rt, (struct sockaddr *)&iface_out, &len) == -1 ) {
[ 9s] ^
[ 9s] In file included from getifname.c:14:0:
[ 9s] /usr/include/sys/socket.h:127:12: note: expected 'socklen_t * __restrict__' but argument is of type 'int *'
[ 9s] extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
[ 9s] ^
[ 9s] getifname.c: In function 'get_if_name':
[ 9s] getifname.c:61:11: warning: 'sa.sin_addr.s_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
[ 9s] printf("DEBUG: Output interface address: %s\n",
[ 9s] ^
...
[ 11s] waitpacket.c: In function 'wait_packet':
[ 11s] waitpacket.c:691:57: warning: 'tstamp' may be used uninitialized in this function [-Wmaybe-uninitialized]
[ 11s] if (hz > 0 && opt_clock_skew) clock_skew(hz,tstamp,rttms);
[ 11s] ^
[ 11s] waitpacket.c:611:8: note: 'tstamp' was declared here
[ 11s] __u32 tstamp, echo;
[ 11s] ^
...
[ 11s] listen.c: In function 'listenmain':
[ 11s] listen.c:77:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
[ 11s] write(stdoutFD, p, size-(p-ip_packet));
[ 11s] ^
...
[ 11s] libpcap_stuff.c:26:6: warning: variable 'on' set but not used [-Wunused-but-set-variable]
[ 11s] int on;
[ 11s] ^
[ 11s] libpcap_stuff.c: In function 'pcap_recv':
[ 11s] libpcap_stuff.c:61:19: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
[ 11s] p = (unsigned char*) pcap_next(pcapfp, &hdr);
[ 11s] ^
...
[ 12s] ip_opt_build.c: In function 'ip_opt_build':
[ 12s] ip_opt_build.c:28:29: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsize
of-pointer-memaccess]
[ 12s] memset(ip_opt, 1, sizeof(ip_opt));
[ 12s] ^
...
[ 12s] random.c:32:7: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
[ 12s] read(fd, rc4_sbox, 256);
[ 12s] ^
...
[ 12s] scan.c:458:6: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
[ 12s] p = packet+linkhdr_size+iphdrlen;
[ 12s] ^
...
[ 12s] adbuf.c: In function 'adbuf_addchar':
[ 12s] adbuf.c:130:22: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
[ 12s] unsigned char *p = b->buf + adbuf_used(b);
[ 12s] ^
...
[ 13s] ars.c:909:20: warning: variable 'ip' set but not used [-Wunused-but-set-variable]
[ 13s] struct ars_iphdr *ip;
[ 13s] ^
[ 13s] apd.c: In function 'ars_decode_hex':
[ 13s] apd.c:823:2: warning: pointer targets in return differ in signedness [-Wpointer-sign]
[ 13s] return saved;
[ 13s] ^
[ 13s] apd.c: In function 'ars_decode_string':
[ 13s] apd.c:852:2: warning: pointer targets in return differ in signedness [-Wpointer-sign]
[ 13s] return saved;
[ 13s] ^
[ 13s] apd.c: In function 'ars_d_set_data':
[ 13s] apd.c:889:7: warning: variable 'err' set but not used [-Wunused-but-set-variable]
[ 13s] int err, blen;
[ 13s] ^
Tip add in sources where you get
p =
^
#include <unistd.h>
Please fix too gethostbyname
[ 23s] hping.x86_64: I: binary-or-shlib-calls-gethostbyname /usr/sbin/hping3
[ 23s] The binary calls gethostbyname(). Please port the code to use getaddrinfo().