🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
3 messages
3 total messages Started by 程浩 Sun, 21 Apr 2013 12:50
update netcat 1.11 to netcat 1.12
#254371
Author: 程浩
Date: Sun, 21 Apr 2013 12:50
121 lines
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);
}
Re: update netcat 1.11 to netcat 1.12
#254373
Author: Ivan Shmakov
Date: Sun, 21 Apr 2013 13:58
55 lines
3331 bytes
>>>>> 程浩  <chenghao0511@gmail.com> writes:

	[Cross-posting to news:comp.protocols.tcp-ip and
	news:comp.sources.d, and setting Followup-To: there, for
	news:news.software.readers doesn't seem to be an appropriate
	newsgroup for Netcat-related discussions in general.]

 > update netcat 1.11 to netcat 1.12

	Which of the Netcat implementations do you suggest to change?
	Please note that there're at least /four/ different Netcats
	currently in use, including the "traditional" Netcat,
	OpenBSD Netcat, GNU Netcat, and Netcat6.  (Cf., e. g., [1].)

[1] http://en.wikipedia.org/wiki/Netcat#Variants

 > //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.

	Usually, one doesn't release new versions of the software
	without either acquiring the consent of the current maintainer,
	or changing the name.  Although it's a guideline rather than a
	"strict" rule, failure to follow it may result -- and, in this
	case, have resulted -- in many distinct versions of the code
	being sharing the same name and version.  Consider, e. g.:

--cut: http://eternallybored.org/misc/netcat/ --
    Here's netcat 1.11 compiled for both 32 and 64-bit Windows (but note
    that 64-bit version hasn't been tested much - use at your own risk).
    [...]

    Small update: netcat 1.12 - adds -c command-line option to send CRLF
    line endings instead of just CR (eg. to talk to Exchange SMTP)
--cut: http://eternallybored.org/misc/netcat/ --

 > //only modify doexec.c by chenghao0511@gmail.com

[...]

	Please also consider presenting the change in the "Unified diff"
	format (cf., e. g., [1]), so that the differences will be easy
	to read for anyone concerned.

	(I believe that MinGW provides the "diff.exe" version of the
	GNU diff program, suitable for the W32 and W64 platforms.)

	TIA.

[2] http://en.wikipedia.org/wiki/Unified_diff#Unified_format

-- 
FSF associate member #7257	np. Returning — Jami Sieber
Re: update netcat 1.11 to netcat 1.12
#254417
Author: Mike Dee
Date: Fri, 03 May 2013 12:50
10 lines
1735 bytes
In article <31cee52f-4d64-4731-b235-f52249951005@googlegroups.com>,
 í–ç_ <chenghao0511@gmail.com> wrote:

> User-Agent: G2/1.0

^^^^^^^^
ROLMAO

-- 
dee
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads