From owner-freebsd-hackers Wed Jan 19 5:56:21 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id B4B6314F82; Wed, 19 Jan 2000 05:56:12 -0800 (PST) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id OAA21279; Wed, 19 Jan 2000 14:56:11 +0100 (CET) (envelope-from des@flood.ping.uio.no) To: hackers@freebsd.org, security@freebsd.org Subject: New option to ping(8): dump packet contents From: Dag-Erling Smorgrav Date: 19 Jan 2000 14:56:10 +0100 Message-ID: Lines: 12 User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --=-=-= The attached patch adds a -D option to ping(8) which makes it dump the payload of the reply packet instead of comparing it to the payload of the original request packet. This is useful in cases where the target host purposeldy modifies the payload before replying, e.g. if you hack your stack to report the load average in echo reply packets. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no --=-=-= Content-Disposition: attachment; filename=ping-dump.diff Content-Description: patch Index: ping.c =================================================================== RCS file: /home/ncvs/src/sbin/ping/ping.c,v retrieving revision 1.49 diff -u -r1.49 ping.c --- ping.c 2000/01/14 23:40:38 1.49 +++ ping.c 2000/01/19 13:48:53 @@ -133,6 +133,7 @@ #define F_POLICY 0x4000 #endif /*IPSEC_POLICY_IPSEC*/ #endif /*IPSEC*/ +#define F_DUMP 0x8000 /* * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum @@ -234,10 +235,10 @@ datap = &outpack[8 + PHDR_LEN]; #ifndef IPSEC - while ((ch = getopt(argc, argv, "I:LQRT:c:adfi:l:np:qrs:t:v")) != -1) + while ((ch = getopt(argc, argv, "I:LQRT:c:adDfi:l:np:qrs:t:v")) != -1) #else #ifdef IPSEC_POLICY_IPSEC - while ((ch = getopt(argc, argv, "I:LQRT:c:adfi:l:np:qrs:t:vP:")) != -1) + while ((ch = getopt(argc, argv, "I:LQRT:c:adDfi:l:np:qrs:t:vP:")) != -1) #endif /*IPSEC_POLICY_IPSEC*/ #endif { @@ -256,6 +257,9 @@ case 'd': options |= F_SO_DEBUG; break; + case 'D': + options |= F_DUMP; + break; case 'f': if (uid) { errno = EPERM; @@ -837,7 +841,13 @@ cp = (u_char*)&icp->icmp_data[PHDR_LEN]; dp = &outpack[8 + PHDR_LEN]; for (i = PHDR_LEN; i < datalen; ++i, ++cp, ++dp) { - if (*cp != *dp) { + if (options & F_DUMP) { + if ((i - PHDR_LEN) % 16 == 8) + putchar(' '); + if ((i - PHDR_LEN) % 16 == 0) + putchar('\n'); + printf(" %02x", *dp); + } else if (*cp != *dp) { (void)printf("\nwrong data byte #%d should be 0x%x but was 0x%x", i, *dp, *cp); printf("\ncp:"); --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message