aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--network/hping3/hping3.SlackBuild13
-rw-r--r--network/hping3/hping3.info4
-rw-r--r--network/hping3/patches/data_size_udp.diff20
-rw-r--r--network/hping3/patches/dontfrag_offbyone.diff14
-rw-r--r--network/hping3/patches/ip_optlen_conflicting_types.diff18
-rw-r--r--network/hping3/patches/rtt_icmp_unreachable.diff32
-rw-r--r--network/hping3/patches/spelling_error_in_binary.diff153
-rw-r--r--network/hping3/patches/tcp_mss.diff180
8 files changed, 430 insertions, 4 deletions
diff --git a/network/hping3/hping3.SlackBuild b/network/hping3/hping3.SlackBuild
index 1dbd7e8093aa1..0dc5671a3fca5 100644
--- a/network/hping3/hping3.SlackBuild
+++ b/network/hping3/hping3.SlackBuild
@@ -1,7 +1,10 @@
#!/bin/sh
# Slackware build script for hping3 TCP/IP packet assembler/analyzer
-
+#
+# Copyright 2015 Brenton Earl <brent@exitstatusone.com>
+# All rights reserved.
+#
# Copyright 2009-2010 Marco Bonetti <sid77@slackware.it>
# All rights reserved.
#
@@ -24,7 +27,7 @@
PRGNAM=hping3
VERSION=${VERSION:-20051105}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -79,6 +82,12 @@ patch -p1 < $CWD/patches/spelling.diff
patch -p1 < $CWD/patches/personality.diff
patch -p1 < $CWD/patches/tcl.diff
patch -p1 < $CWD/patches/ip_id_field.diff
+patch -p1 < $CWD/patches/dontfrag_offbyone.diff
+patch -p1 < $CWD/patches/rtt_icmp_unreachable.diff
+patch -p1 < $CWD/patches/spelling_error_in_binary.diff
+patch -p1 < $CWD/patches/data_size_udp.diff
+patch -p1 < $CWD/patches/tcp_mss.diff
+patch -p1 < $CWD/patches/ip_optlen_conflicting_types.diff
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
diff --git a/network/hping3/hping3.info b/network/hping3/hping3.info
index abbc4ab53c4b6..327463b0e8a05 100644
--- a/network/hping3/hping3.info
+++ b/network/hping3/hping3.info
@@ -6,5 +6,5 @@ MD5SUM="ca4ea4e34bcc2162aedf25df8b2d1747"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
-MAINTAINER="Marco Bonetti"
-EMAIL="sid77@slackware.it"
+MAINTAINER="Brenton Earl"
+EMAIL="brent@exitstatusone.com"
diff --git a/network/hping3/patches/data_size_udp.diff b/network/hping3/patches/data_size_udp.diff
new file mode 100644
index 0000000000000..b10c243eb800d
--- /dev/null
+++ b/network/hping3/patches/data_size_udp.diff
@@ -0,0 +1,20 @@
+
+Fix incorrect data size check for UDP.
+
+--- a/parseoptions.c
++++ b/parseoptions.c
+@@ -569,9 +573,12 @@
+ if (opt_numeric == TRUE) opt_gethost = FALSE;
+
+ /* some error condition */
+- if (data_size+IPHDR_SIZE+TCPHDR_SIZE > 65535) {
++ if (data_size+IPHDR_SIZE+
++ (opt_udpmode?UDPHDR_SIZE:TCPHDR_SIZE) > 65535) {
+ printf("Option error: sorry, data size must be <= %lu\n",
+- (unsigned long)(65535-IPHDR_SIZE+TCPHDR_SIZE));
++ (unsigned long)(65535-(IPHDR_SIZE+
++ (opt_udpmode?UDPHDR_SIZE:TCPHDR_SIZE)))
++ );
+ exit(1);
+ }
+ else if (count <= 0 && count != -1) {
diff --git a/network/hping3/patches/dontfrag_offbyone.diff b/network/hping3/patches/dontfrag_offbyone.diff
new file mode 100644
index 0000000000000..d0be06e436f1a
--- /dev/null
+++ b/network/hping3/patches/dontfrag_offbyone.diff
@@ -0,0 +1,14 @@
+
+Fixes Off-by-one error with --dontfrag
+
+--- a/sendip_handler.c
++++ b/sendip_handler.c
+@@ -19,7 +19,7 @@
+ {
+ ip_optlen = ip_opt_build(ip_opt);
+
+- if (!opt_fragment && (size+ip_optlen+20 >= h_if_mtu))
++ if (!opt_fragment && (size+ip_optlen+20 > h_if_mtu))
+ {
+ /* auto-activate fragmentation */
+ virtual_mtu = h_if_mtu-20;
diff --git a/network/hping3/patches/ip_optlen_conflicting_types.diff b/network/hping3/patches/ip_optlen_conflicting_types.diff
new file mode 100644
index 0000000000000..b31b744730433
--- /dev/null
+++ b/network/hping3/patches/ip_optlen_conflicting_types.diff
@@ -0,0 +1,18 @@
+
+Fixes complicting declarations of variables ip_optlen in:
+
+globals.h: extern char ip_optlen
+and
+main.c: unsigned ip_optlen
+
+--- hping3.git.orig/main.c
++++ hping3.git/main.c
+@@ -152,7 +152,7 @@ unsigned char
+ lsr [255] = {0},
+ ssr [255] = {0};
+
+-unsigned
++char
+ ip_optlen = 0;
+
+ struct sockaddr_in
diff --git a/network/hping3/patches/rtt_icmp_unreachable.diff b/network/hping3/patches/rtt_icmp_unreachable.diff
new file mode 100644
index 0000000000000..81fa6c194ecbc
--- /dev/null
+++ b/network/hping3/patches/rtt_icmp_unreachable.diff
@@ -0,0 +1,32 @@
+
+Adds RTT handling for ICMP destination unreachable packets
+
+--- a/waitpacket.c
++++ b/waitpacket.c
+@@ -229,6 +229,7 @@
+ {
+ struct myicmphdr icmp;
+ struct myiphdr quoted_ip;
++ struct myudphdr quoted_udp;
+
+ /* Check if the packet can contain the ICMP header */
+ if (size < ICMPHDR_SIZE) {
+@@ -286,6 +287,18 @@
+ case 3:
+ if (!opt_quiet)
+ log_icmp_unreach(inet_ntoa(src), icmp.code);
++ if (quoted_ip.protocol == IPPROTO_UDP)
++ {
++ int sequence = 0, status;
++ float ms_delay = 0.0;
++ unsigned short port;
++
++ /* Get RTT for UDP packet */
++ memcpy(&quoted_udp, packet+ICMPHDR_SIZE+(quoted_ip.ihl<<2), sizeof(quoted_udp));
++ port = ntohs(quoted_udp.uh_sport);
++ status = rtt(&sequence, port, &ms_delay);
++ printf("status=%d port=%d seq=%d\n", status, port, sequence);
++ }
+ return 1;
+ case 11:
+ if (opt_traceroute)
diff --git a/network/hping3/patches/spelling_error_in_binary.diff b/network/hping3/patches/spelling_error_in_binary.diff
new file mode 100644
index 0000000000000..a7ac1f12d35f5
--- /dev/null
+++ b/network/hping3/patches/spelling_error_in_binary.diff
@@ -0,0 +1,153 @@
+
+Fixes spelling errors in binary
+
+--- a/parseoptions.c
++++ b/parseoptions.c
+@@ -174,7 +174,7 @@
+ str[j++] = '/';
+ break;
+ }
+- fprintf(stderr, "invalid IP adress in route\n");
++ fprintf(stderr, "invalid IP address in route\n");
+ fail_parse_route();
+ case ':':
+ if ((!i) && j && j < 4)
+--- a/getifname.c
++++ b/getifname.c
+@@ -206,7 +206,7 @@
+ printf("DEBUG: Output interface address: %s\n",
+ inet_ntoa(output_if_addr.sin_addr));
+ /* Put something in saved_ifname in order to tell
+- that the output adress is known */
++ that the output address is known */
+ saved_ifname[0] = 'X'; saved_ifname[1] = 0;
+ } else {
+ fprintf(stderr, "Warning: Unable to guess the output "
+--- a/usage.c
++++ b/usage.c
+@@ -50,7 +50,7 @@
+ " -r --rel relativize id field (to estimate host traffic)\n"
+ " -f --frag split packets in more frag. (may pass weak acl)\n"
+ " -x --morefrag set more fragments flag\n"
+-" -y --dontfrag set dont fragment flag\n"
++" -y --dontfrag set don't fragment flag\n"
+ " -g --fragoff set the fragment offset\n"
+ " -m --mtu set virtual mtu, implies --frag if packet size > mtu\n"
+ " -o --tos type of service (default 0x00), try --tos help\n"
+@@ -126,8 +126,8 @@
+ "ICMP help:\n"
+ " ICMP concerned packet options:\n"
+ " --icmp-ipver set ip version ( default 4 )\n"
+-" --icmp-iphlen set ip header lenght ( default IPHDR_SIZE >> 2)\n"
+-" --icmp-iplen set ip total lengtht ( default real lenght )\n"
++" --icmp-iphlen set ip header length ( default IPHDR_SIZE >> 2)\n"
++" --icmp-iplen set ip total length ( default real length )\n"
+ " --icmp-ipid set ip id ( default random )\n"
+ " --icmp-ipproto set ip protocol ( default IPPROTO_TCP )\n"
+ " --icmp-ipsrc set ip source ( default 0.0.0.0 )\n"
+--- a/sendtcp.c
++++ b/sendtcp.c
+@@ -50,7 +50,7 @@
+ memcpy(&pseudoheader->saddr, &local.sin_addr.s_addr, 4);
+ memcpy(&pseudoheader->daddr, &remote.sin_addr.s_addr, 4);
+ pseudoheader->protocol = 6; /* tcp */
+- pseudoheader->lenght = htons(TCPHDR_SIZE+tcp_opt_size+data_size);
++ pseudoheader->length = htons(TCPHDR_SIZE+tcp_opt_size+data_size);
+
+ /* tcp header */
+ tcp->th_dport = htons(dst_port);
+--- a/sendudp.c
++++ b/sendudp.c
+@@ -46,7 +46,7 @@
+ memcpy(&pseudoheader->saddr, &local.sin_addr.s_addr, 4);
+ memcpy(&pseudoheader->daddr, &remote.sin_addr.s_addr, 4);
+ pseudoheader->protocol = 17; /* udp */
+- pseudoheader->lenght = htons(packet_size);
++ pseudoheader->length = htons(packet_size);
+
+ /* udp header */
+ udp->uh_dport = htons(dst_port);
+--- a/sendicmp.c
++++ b/sendicmp.c
+@@ -243,7 +243,7 @@
+ memcpy(&pseudoheader->saddr, &icmp_ip_src.sin_addr.s_addr, 4);
+ memcpy(&pseudoheader->daddr, &icmp_ip_dst.sin_addr.s_addr, 4);
+ pseudoheader->protocol = icmp_ip.protocol;
+- pseudoheader->lenght = icmp_ip.tot_len;
++ pseudoheader->length = icmp_ip.tot_len;
+ icmp_udp->uh_sport = htons(icmp_ip_srcport);
+ icmp_udp->uh_dport = htons(icmp_ip_dstport);
+ icmp_udp->uh_ulen = htons(UDPHDR_SIZE + udp_data_len);
+--- a/hping2.h
++++ b/hping2.h
+@@ -134,7 +134,7 @@
+
+ /* fragmentation defines */
+ #define MF ((unsigned short)0x2000) /* more fragments */
+-#define DF ((unsigned short)0x4000) /* dont fragment */
++#define DF ((unsigned short)0x4000) /* don't fragment */
+ #define NF ((unsigned short)0x0000) /* no more fragments */
+
+ /* ip options defines */
+@@ -337,7 +337,7 @@
+ __u32 daddr;
+ __u8 zero;
+ __u8 protocol;
+- __u16 lenght;
++ __u16 length;
+ };
+
+ #define PSEUDOHDR_SIZE sizeof(struct pseudohdr)
+--- a/ars.c
++++ b/ars.c
+@@ -698,7 +698,7 @@
+ memcpy(&pseudo.daddr, &ip->daddr, 4);
+ pseudo.protocol = (pkt->p_layer[layer].l_type == ARS_TYPE_TCP)
+ ? ARS_IPPROTO_TCP : ARS_IPPROTO_UDP;
+- pseudo.lenght = htons(ars_relative_size(pkt, layer));
++ pseudo.length = htons(ars_relative_size(pkt, layer));
+
+ /* Finally do the checksum */
+ ars_multi_cksum(&mc, ARS_MC_INIT, NULL, 0);
+--- a/datahandler.c
++++ b/datahandler.c
+@@ -26,7 +26,7 @@
+ }
+
+ if (opt_sign) {
+- memcpy(data, sign, signlen); /* lenght pre-checked */
++ memcpy(data, sign, signlen); /* length pre-checked */
+ data+=signlen;
+ data_size-=signlen;
+ }
+--- a/ars.h
++++ b/ars.h
+@@ -67,7 +67,7 @@
+ #define ARS_MAX_IP_SIZE 65535
+
+ #define ARS_IP_MF ((unsigned short)0x2000) /* more fragments */
+-#define ARS_IP_DF ((unsigned short)0x4000) /* dont fragment */
++#define ARS_IP_DF ((unsigned short)0x4000) /* don't fragment */
+ #define ARS_IP_RF ((unsigned short)0x8000) /* reserved fragment flag */
+
+ #define ARS_IPOPT_COPY 0x80
+@@ -308,7 +308,7 @@
+ __u32 daddr;
+ __u8 zero;
+ __u8 protocol;
+- __u16 lenght;
++ __u16 length;
+ };
+
+ /* The IGRP header structure */
+--- a/sendip_handler.c
++++ b/sendip_handler.c
+@@ -35,7 +35,7 @@
+ unsigned short fragment_flag = 0;
+
+ if (opt_mf) fragment_flag |= MF; /* more fragments */
+- if (opt_df) fragment_flag |= DF; /* dont fragment */
++ if (opt_df) fragment_flag |= DF; /* don't fragment */
+ send_ip((char*)&local.sin_addr,
+ (char*)&remote.sin_addr,
+ packet, size, fragment_flag, ip_frag_offset,
diff --git a/network/hping3/patches/tcp_mss.diff b/network/hping3/patches/tcp_mss.diff
new file mode 100644
index 0000000000000..37113dc8daec4
--- /dev/null
+++ b/network/hping3/patches/tcp_mss.diff
@@ -0,0 +1,180 @@
+Add tcp-mss support.
+
+--- a/main.c
++++ b/main.c
+@@ -44,7 +44,8 @@
+ signlen,
+ lsr_length = 0,
+ ssr_length = 0,
+- tcp_ack;
++ tcp_ack,
++ tcp_mss;
+
+
+ unsigned short int
+@@ -95,6 +96,7 @@
+ opt_tcpexitcode = FALSE,
+ opt_badcksum = FALSE,
+ opt_tr_keep_ttl = FALSE,
++ opt_tcp_mss = FALSE,
+ opt_tcp_timestamp = FALSE,
+ opt_tr_stop = FALSE,
+ opt_tr_no_rtt = FALSE,
+--- a/globals.h
++++ b/globals.h
+@@ -32,7 +32,8 @@
+ tcp_seqnum,
+ set_ack,
+ ip_header_length,
+- tcp_ack;
++ tcp_ack,
++ tcp_mss;
+
+ extern unsigned short int
+ data_size;
+@@ -77,6 +78,7 @@
+ opt_tcpexitcode,
+ opt_badcksum,
+ opt_tr_keep_ttl,
++ opt_tcp_mss,
+ opt_tcp_timestamp,
+ opt_tr_stop,
+ opt_tr_no_rtt,
+--- a/parseoptions.c
++++ b/parseoptions.c
+@@ -31,7 +31,7 @@
+ OPT_RROUTE, OPT_IPPROTO, OPT_ICMP_IPVER, OPT_ICMP_IPHLEN,
+ OPT_ICMP_IPLEN, OPT_ICMP_IPID, OPT_ICMP_IPPROTO, OPT_ICMP_CKSUM,
+ OPT_ICMP_TS, OPT_ICMP_ADDR, OPT_TCPEXITCODE, OPT_FAST, OPT_TR_KEEP_TTL,
+- OPT_TCP_TIMESTAMP, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP,
++ OPT_TCP_TIMESTAMP, OPT_TCP_MSS, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP,
+ OPT_RAND_DEST, OPT_RAND_SOURCE, OPT_LSRR, OPT_SSRR, OPT_ROUTE_HELP,
+ OPT_ICMP_IPSRC, OPT_ICMP_IPDST, OPT_ICMP_SRCPORT, OPT_ICMP_DSTPORT,
+ OPT_ICMP_GW, OPT_FORCE_ICMP, OPT_APD_SEND, OPT_SCAN, OPT_FASTER,
+@@ -124,6 +124,7 @@
+ { '\0', "force-icmp", OPT_FORCE_ICMP, AGO_NOARG },
+ { '\0', "beep", OPT_BEEP, AGO_NOARG },
+ { '\0', "flood", OPT_FLOOD, AGO_NOARG },
++ { '\0', "tcp-mss", OPT_TCP_MSS, AGO_NEEDARG|AGO_EXCEPT0 },
+ AGO_LIST_TERM
+ };
+
+@@ -556,6 +557,10 @@
+ case OPT_FLOOD:
+ opt_flood = TRUE;
+ break;
++ case OPT_TCP_MSS:
++ opt_tcp_mss = TRUE;
++ tcp_mss = strtoul(ago_optarg, NULL, 0);
++ break;
+ }
+ }
+
+--- a/usage.c
++++ b/usage.c
+@@ -87,6 +87,7 @@
+ " -X --xmas set X unused flag (0x40)\n"
+ " -Y --ymas set Y unused flag (0x80)\n"
+ " --tcpexitcode use last tcp->th_flags as exit code\n"
++" --tcp-mss enable the TCP MSS option with the given value\n"
+ " --tcp-timestamp enable the TCP timestamp option to guess the HZ/uptime\n"
+ "Common\n"
+ " -d --data data size (default is 0)\n"
+--- a/sendtcp.c
++++ b/sendtcp.c
+@@ -28,10 +28,12 @@
+ char *packet, *data;
+ struct mytcphdr *tcp;
+ struct pseudohdr *pseudoheader;
+- unsigned char *tstamp;
++ unsigned char *opts;
+
++ if (opt_tcp_mss)
++ tcp_opt_size += 4;
+ if (opt_tcp_timestamp)
+- tcp_opt_size = 12;
++ tcp_opt_size += 12;
+
+ packet_size = TCPHDR_SIZE + tcp_opt_size + data_size;
+ packet = malloc(PSEUDOHDR_SIZE + packet_size);
+@@ -41,7 +43,7 @@
+ }
+ pseudoheader = (struct pseudohdr*) packet;
+ tcp = (struct mytcphdr*) (packet+PSEUDOHDR_SIZE);
+- tstamp = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE);
++ opts = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE);
+ data = (char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE+tcp_opt_size);
+
+ memset(packet, 0, PSEUDOHDR_SIZE+packet_size);
+@@ -64,14 +66,24 @@
+ tcp->th_win = htons(src_winsize);
+ tcp->th_flags = tcp_th_flags;
+
++ /* tcp MSS option */
++ if (opt_tcp_mss) {
++ opts[0] = 2;
++ opts[1] = 4; /* 4 bytes, kind+len+MSS */
++ opts[2] = tcp_mss >> 8;
++ opts[3] = tcp_mss & 0xff;
++ opts += 4;
++ }
++
+ /* tcp timestamp option */
+ if (opt_tcp_timestamp) {
+ __u32 randts = rand() ^ (rand() << 16);
+- tstamp[0] = tstamp[1] = 1; /* NOOP */
+- tstamp[2] = 8;
+- tstamp[3] = 10; /* 10 bytes, kind+len+T1+T2 */
+- memcpy(tstamp+4, &randts, 4); /* random */
+- memset(tstamp+8, 0, 4); /* zero */
++ opts[0] = opts[1] = 1; /* NOOP */
++ opts[2] = 8;
++ opts[3] = 10; /* 10 bytes, kind+len+T1+T2 */
++ memcpy(opts+4, &randts, 4); /* random */
++ memset(opts+8, 0, 4); /* zero */
++ opts += 12;
+ }
+
+ /* data */
+--- a/docs/hping3.8
++++ b/docs/hping3.8
+@@ -98,6 +98,8 @@
+ ] [
+ .B \-\-tcpexitcode
+ ] [
++.B \-\-tcp-mss
++] [
+ .B \-\-tcp-timestamp
+ ] [
+ .B \-\-tr-stop
+@@ -510,6 +512,9 @@
+ .I -b --badcksum
+ Send packets with a bad UDP/TCP checksum.
+ .TP
++.I --tcp-mss
++Enable the TCP MSS option and set it to the given value.
++.TP
+ .I --tcp-timestamp
+ Enable the TCP timestamp option, and try to guess the timestamp update
+ frequency and the remote system uptime.
+--- a/docs/french/hping2-fr.8
++++ b/docs/french/hping2-fr.8
+@@ -99,6 +99,8 @@
+ ] [
+ .B \-\-tcpexitcode
+ ] [
++.B \-\-tcp-mss
++] [
+ .B \-\-tcp-timestamp
+ ] [
+ .B \-\-tr-stop
+@@ -549,6 +551,9 @@
+ .I -b --badcksum
+ Envoie des paquets avec une mauvaise somme de contrôle UDP/TCP
+ .TP
++.I --tcp-mss
++Active l'option TCP MSS et la fixe avec la valeur donnée.
++.TP
+ .I --tcp-timestamp
+ Active l'option TCP timestamp, et essaye de deviner la fréquence de mise à
+ jour du timestamp et l'uptime du système distant.