Nmap Development mailing list archives

Re: [NSE] rpcinfo script


From: Sven Klemm <sven () c3d2 de>
Date: Sun, 06 Jan 2008 23:59:09 +0100

Fyodor wrote:
On Sun, Jan 06, 2008 at 06:05:44PM +0100, Sven Klemm wrote:
I've modified the script to format the output more nicely.

This looks good, and I've applied it to SVN.

Thank you very much. I've got another patch which removes my own
implementation of ntohl and makes use of the one in the nse packet
library.

Cheers,
Sven

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

Index: rpcinfo.nse
===================================================================
--- rpcinfo.nse (revision 6671)
+++ rpcinfo.nse (working copy)
@@ -6,7 +6,7 @@
 categories = {"safe","discovery"}
 
 require "shortport"
-require "bit"
+require "packet"
 require "stdnse"
 
 local rpc_numbers = {}
@@ -56,14 +56,8 @@
 
   catch = function() socket:close() end
   try = nmap.new_try( catch )
-
   try( fillrpc() )
 
-  local ntohl = function( s )
-    return bit.lshift(s:byte(1),24) + bit.lshift(s:byte(2),16) +
-           bit.lshift(s:byte(3),8) + s:byte(4)
-  end
-
   local request = string.char(0x80,0,0,40) -- fragment header
   request = request .. transaction_id -- transaction id
   request = request .. "\0\0\0\0\0\0\0\2" -- message type: call (0) and rpc version 2
@@ -98,10 +92,10 @@
     local dir = { udp = {}, tcp = {}}
     local rpc_prog, rpc_vers, rpc_proto, rpc_port
     while answer:byte(4) == 1 and answer:len() >= 20 do
-      rpc_prog = ntohl( answer:sub(5,8))
-      rpc_vers = ntohl( answer:sub(9,12))
-      rpc_proto = ntohl( answer:sub(13,16))
-      rpc_port = ntohl( answer:sub(17,20))
+      rpc_prog = packet.u32( answer, 4 )
+      rpc_vers = packet.u32( answer, 8 )
+      rpc_proto = packet.u32( answer, 12 )
+      rpc_port = packet.u32( answer, 16 )
       answer = answer:sub(21)
       if rpc_proto == 6 then
         rpc_proto = "tcp"

Attachment: signature.asc
Description: OpenPGP digital signature


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

Current thread: