Nmap Development mailing list archives

[NSE][PATCH] fix for --script-trace hex dump


From: Sven Klemm <sven () c3d2 de>
Date: Wed, 03 Sep 2008 11:34:38 +0200

Hi,

Currently --script-trace does not properly hexencode when the high bit of a byte is set. The attached patch fixes this behaviour.

Without the patch I get the following:

SCRIPT ENGINE: TCP 127.0.0.1:51289 < 127.0.0.1:111 | 00000000: ffffff80 00 00 44 6b ffffff8b 45 68 00 00 00 01 00 00 00 00 Dk Eh

With the patch applied I get the following:
SCRIPT ENGINE: TCP 127.0.0.1:54240 < 127.0.0.1:111 | 00000000: 80 00 00 44 6b 8b 45 68 00 00 00 01 00 00 00 00 Dk Eh

Cheers,
Sven

--
Sven Klemm
http://cthulhu.c3d2.de/~sven/

Index: nse_nsock.cc
===================================================================
--- nse_nsock.cc        (revision 9891)
+++ nse_nsock.cc        (working copy)
@@ -87,7 +87,7 @@
       if (isprint(str[i]) || isspace(str[i]))
         ret << str[i];
       else
-        ret << std::setw(3) << "\\" << (unsigned int) str[i];
+        ret << std::setw(3) << "\\" << (unsigned int)(unsigned char) str[i];
     }
     return ret.str();
   }
@@ -98,7 +98,7 @@
     ret << std::setw(8) << i << ": ";
     for (size_t j = i; j < i + 16; j++)
       if (j < len)
-        ret << std::setw(2) << (unsigned int) str[j] << " ";
+        ret << std::setw(2) << (unsigned int)(unsigned char) str[j] << " ";
       else
         ret << "   ";
     for (size_t j = i; j < i + 16 && j < len; j++)

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

Current thread: