Article View: news.software.readers
Article #254371update netcat 1.11 to netcat 1.12
From: 程浩
Date: Sun, 21 Apr 2013 12:50
Date: Sun, 21 Apr 2013 12:50
121 lines
4248 bytes
4248 bytes
update netcat 1.11 to netcat 1.12
//nc -lp port (remote )
//nc ip port -e cmd.exe (local)
//after ctrl+c cmd.exe no exit,socket no shutdown,remote's nc no exit!
//it is a bug!so write netcat 1.12.
//only modify doexec.c by chenghao0511@gmail.com
BOOL ConsoleHandler(DWORD CEvent)
{
switch(CEvent)
{
case CTRL_C_EVENT:
TerminateProcess(Session->ProcessHandle,0);
return(TRUE);
break;
case CTRL_BREAK_EVENT:
TerminateProcess(Session->ProcessHandle,0);
return(TRUE);
break;
case CTRL_CLOSE_EVENT:
TerminateProcess(Session->ProcessHandle,0);
return(TRUE);
break;
case CTRL_LOGOFF_EVENT:
TerminateProcess(Session->ProcessHandle,0);
return(TRUE);
break;
case CTRL_SHUTDOWN_EVENT:
TerminateProcess(Session->ProcessHandle,0);
return(TRUE);
break;
}
return TRUE;
}
// **********************************************************************
//
// StartShell
//
// Execs the shell with the specified handle as stdin, stdout/err
//
// Returns process handle or NULL on failure
//
static HANDLE
StartShell(
HANDLE ShellStdinPipeHandle,
HANDLE ShellStdoutPipeHandle
)
{
PROCESS_INFORMATION ProcessInformation;
STARTUPINFO si;
HANDLE ProcessHandle = NULL;
//
// Initialize process startup info
//
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = NULL;
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.wShowWindow = SW_HIDE;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdInput = ShellStdinPipeHandle;
si.hStdOutput = ShellStdoutPipeHandle;
DuplicateHandle(GetCurrentProcess(), ShellStdoutPipeHandle,
GetCurrentProcess(), &si.hStdError,
DUPLICATE_SAME_ACCESS, TRUE, 0);
//no matter if (CreateProcess(NULL, pr00gie, NULL, NULL, TRUE, CREATE_NEW_PROCESS_GROUP, NULL, NULL,
if (CreateProcess(NULL, pr00gie, NULL, NULL, TRUE, 0, NULL, NULL,
&si, &ProcessInformation))
{
//nc -lp port (remote )
//nc ip port -e cmd.exe (local)
//after ctrl+c cmd.exe no exit,socket no shutdown,remote's nc no exit!
//it is a bug!so write netcat 1.12.
//only modify doexec.c by chenghao0511@gmail.com
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler,TRUE)==FALSE)
{
// unable to install handler
// display message to the user
printf("Unable to install handler!\n");
return NULL;
}
ProcessHandle = ProcessInformation.hProcess;
CloseHandle(ProcessInformation.hThread);
}
else
holler("Failed to execute shell, error = %s",
itoa(GetLastError(), smbuff, 10), NULL, NULL, NULL, NULL, NULL);
return(ProcessHandle);
}
Technical Details
Message-ID:
<31cee52f-4d64-4731-b235-f52249951005@googlegroups.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!eweka.nl!hq-usenetpeers.eweka.nl!news.glorb.com!gp5no4200141qab.0!news-out.google.com!ef9ni2qab.0!nntp.google.com!gp5no4200137qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <31cee52f-4d64-4731-b235-f52249951005@googlegroups.com> Subject: update netcat 1.11 to netcat 1.12 Date: Sun, 21 Apr 2013 12:50:04 +0000 From: 程浩 <chenghao0511@gmail.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!eweka.nl!hq-usenetpeers.eweka.nl!news.glorb.com!gp5no4200141qab.0!news-out.google.com!ef9ni2qab.0!nntp.google.com!gp5no4200137qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail X-Received: by 10.224.178.205 with SMTP id bn13mr16823595qab.3.1366548605449; X-Received: by 10.50.186.133 with SMTP id fk5mr4692734igc.0.1366548605223; Newsgroups: news.software.readers Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=65.49.2.181; posting-account=7F1TCwoAAAC0DsEDCzRUT8JJds_y2PTb NNTP-Posting-Host: 65.49.2.181 User-Agent: G2/1.0 MIME-Version: 1.0 Injection-Date: Sun, 21 Apr 2013 12:50:05 +0000 Content-Type: text/plain; charset=ISO-8859-1 Lines: 120 X-Original-Bytes: 4069