πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #254443

update netcat 1.14 to 1.15

#254443
From: 程桩
Date: Sat, 11 May 2013 09:28
77 lines
3327 bytes
update netcat 1.14 to 1.15

modify by chenghao0511#gmail.com 2013/05/11

why?

netcat 1.14 can not support : 
nc -u -lp port -e cmd.exe
nc -u ip port


how to update:(in doexec.c in SessionWriteShellThreadFn)


-    BYTE    RecvBuffer[1];

+    BYTE    RecvBuffer[8192];

-     BYTE    Buffer[BUFFER_SIZE];

-    while (recv(Session->ClientSocket, RecvBuffer, sizeof(RecvBuffer), 0) != 0) {

+    while ((BufferCnt = recv(Session->ClientSocket, RecvBuffer, sizeof(RecvBuffer), 0)) != 0) {

-        Buffer[BufferCnt++] = RecvBuffer[0];

-        if (RecvBuffer[0] == '\r')
-                Buffer[BufferCnt++] = '\n';

		// Trap exit as it causes problems
-		if (strnicmp(Buffer, "exit\n", 5) == 0)
-			ExitThread(0);



        //
        // If we got a CR, it's time to send what we've buffered up down to the
        // shell process.
        // SECURITY FIX: CW 12/27/04 Add BufferCnt size check.  If we hit end of buffer, flush it
        if (RecvBuffer[0] == '\n' || RecvBuffer[0] == '\r' || BufferCnt > BUFFER_SIZE-1) {
            if (! WriteFile(Session->WritePipeHandle, Buffer, BufferCnt, 
                            &BytesWritten, NULL))
            {
                break;
            }
            BufferCnt = 0;
        }


changed to:

        //if (RecvBuffer[0] == '\n' || RecvBuffer[0] == '\r' || BufferCnt > BUFFER_SIZE-1) {
            if (! WriteFile(Session->WritePipeHandle, RecvBuffer, BufferCnt, 
                            &BytesWritten, NULL))
            {
                break;
            }
            BufferCnt = 0;
        //}

source code:
https://github.com/chenghao11/netcat-1.13/wiki/update-netcat-1.12-to-1.13
http://code.google.com/p/netcat113/
https://sourceforge.net/p/netcat113/
download:
https://www.box.com/s/h8cay347q12i50ipavug
https://docs.google.com/file/d/0B0LORKrOvywudmNTWTBjRjZKaVk/edit?usp=sharing

http://youtu.be/t213MFUS3IU
Technical Details
Message-ID: <e8917973-7012-4164-9793-238d5f6555f0@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.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!m7no4692289qam.0!news-out.google.com!y6ni29564qax.0!nntp.google.com!m7no4692283qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <e8917973-7012-4164-9793-238d5f6555f0@googlegroups.com>
Subject: update netcat 1.14 to 1.15
Date: Sat, 11 May 2013 09:28:30 +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.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!m7no4692289qam.0!news-out.google.com!y6ni29564qax.0!nntp.google.com!m7no4692283qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
X-Received: by 10.224.10.6 with SMTP id n6mr13972029qan.4.1368264510884;
X-Received: by 10.50.56.51 with SMTP id x19mr766482igp.0.1368264510850; Sat,
Newsgroups: news.software.readers
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=65.49.14.163;
 posting-account=7F1TCwoAAAC0DsEDCzRUT8JJds_y2PTb
NNTP-Posting-Host: 65.49.14.163
User-Agent: G2/1.0
MIME-Version: 1.0
Injection-Date: Sat, 11 May 2013 09:28:30 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Lines: 76
X-Original-Bytes: 3089