Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [nmap-svn] r31481 - nmap-exp/d33tah/lua-exec-examples/ncat
From: Jacek Wielemborek <wielemborekj1 () gmail com>
Date: Mon, 22 Jul 2013 21:10:45 +0200

2013/7/22  <commit-mailer () nmap org>:
Author: d33tah
Date: Mon Jul 22 16:47:03 2013
New Revision: 31481

Log:
set binary mode for stdout for --lua-exec-internal under Windows. that
prevents Windows from messing with line breaks for httpd.lua.

Modified:
   nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c

Modified: nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c
==============================================================================
--- nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c  (original)
+++ nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c  Mon Jul 22 16:47:03 2013
@@ -500,6 +500,13 @@
                    forking in POSIX builds, Windows does not have the fork() system
                    call and thus requires this workaround. More info here:
                    http://seclists.org/nmap-dev/2013/q2/492 */
+#ifdef WIN32
+                if (o.debug)
+                    logdebug("Enabling binary stdout for the Lua output.\n");
+                int result = _setmode(_fileno(stdout), _O_BINARY);
+                if (result == -1)
+                    perror("Cannot set mode");
+#endif
                 ncat_assert(argc == 3);
                 o.cmdexec = argv[2];
                 lua_setup();

_______________________________________________
Sent through the svn mailing list
http://nmap.org/mailman/listinfo/svn

This needs some discussion.

I'm not sure it's okay to just change the stdout mode for Lua scripts
- it could create a discrepancy between "traditional" Lua behavior on
Windows and one altered by binary mode.

I just did some testing that proves that without the binary mode,
print("a") produces CR LF. With binary mode on, it's just \n.
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]