Nmap Development mailing list archives

Re: [nmap-svn] r19501 - nmap-exp/luis/nping-echo


From: "Luis MartinGarcia." <luis.mgarc () gmail com>
Date: Fri, 06 Aug 2010 17:20:09 +0200

On 08/06/2010 02:56 AM, David Fifield wrote:
On Thu, Aug 05, 2010 at 05:51:18PM -0700, commit-mailer () insecure org wrote:
  
Author: luis
Date: Thu Aug  5 17:51:18 2010
New Revision: 19501

Log:
Fixed a problem that caused Nping to abort on Windows due to a stack
overflow. After hours looking for the problem, I found that it was
Visual Studio's fault because by default it only allocates 1MB stacks.
Incrementing this value to 5MB (quite reasonable for today's RAMs)
does the trick.

Modified:
   nmap-exp/luis/nping-echo/nping.vcproj

Modified: nmap-exp/luis/nping-echo/nping.vcproj
==============================================================================
--- nmap-exp/luis/nping-echo/nping.vcproj    (original)
+++ nmap-exp/luis/nping-echo/nping.vcproj    Thu Aug  5 17:51:18 2010
@@ -82,6 +82,7 @@
                             GenerateDebugInformation="true"
                             ProgramDatabaseFile=".\Debug/nmap.pdb"
                             SubSystem="1"
+                            StackReserveSize="5000000"
                             OptimizeForWindows98="0"
                             RandomizedBaseAddress="1"
                             DataExecutionPrevention="0"
    
Interesting. Do you have any idea how the stack gets that deep in the
first place?

David Fifield
  

Well, I honestly don't know. Nping doesn't have any significant memory
needs. Probably the biggest structure out there is the EchoHeader class,
which has a big internal buffer (I'll try to reduce that). However, I've
been doing some tests on linux and Nping consumes a lot less memory than
Nmap (obvious, since it does not have to keep as much state as nmap), so
I don't really know why I had to increase its stack size on Windows. 
These are the results of my tests:


"TOP" COMMAND STATISTICS

NPING (nping --echo-client mypass echo.nmap.org -d4 --delay 500s)
  PID  VIRT  RES  SHR S %MEM P SWAP CODE DATA nFLT nDRT
13351 39740 8324 6332 S  0.2 0  30m  372 2888    0    0


NMAP (nmap scanme.insecure.org -p80)
  PID  VIRT  RES  SHR S %MEM P SWAP CODE DATA nFLT nDRT
13360 50104  14m 2936 S  0.4 0  34m  996  12m   12    0


PID        = Process Id
VIRT       = Virtual Image (kb)
RES        = Resident size (kb)
SHR        = Shared Mem size (kb)
%MEM       = Memory usage (RES)
P          = Last used cpu (SMP)
SWAP       = Swapped size (kb)
CODE       = Code size (kb)
DATA       = Data+Stack size (kb)
nFLT       = Page Fault count
nDRT       = Dirty Pages count



VALGRIND STATISTICS

NPING (nping --echo-client mypass echo.nmap.org -d4 --delay 500s)
==8935== HEAP SUMMARY:
==8935==     in use at exit: 27,826 bytes in 50 blocks
==8935==   total heap usage: 5,207 allocs, 5,157 frees, 820,636 bytes
allocated


NMAP (nmap scanme.insecure.org -p80)
==13372== HEAP SUMMARY:
==13372==     in use at exit: 1,178,248 bytes in 37 blocks
==13372==   total heap usage: 60,339 allocs, 60,302 frees, 5,215,047
bytes allocated


Regards,

Luis MartinGarcia.


_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: