Nmap Development mailing list archives

Re: NFS re-write, RPC library and some more scripts


From: David Fifield <david () bamsoftware com>
Date: Fri, 19 Feb 2010 16:57:52 -0700

On Mon, Jan 25, 2010 at 09:42:38PM +0100, Patrik Karlsson wrote:
I received a bug report from Matt regarding nfs-showmount not properly
listing the exports from a server. Having a look at one of my first
scripts kind of made me sick. So I re-wrote it from scratch and
factored out all the RPC/NFS code into a library called rpc.lua.

The bug was most likely related to the output from the server being a
lot larger than the two entries I had in my test environment. The
mountd program can be queried over either udp or tcp and the script
was doing both. When the answer gets large enough it will only work
over tcp, which brings me to the next bug, the fact that I was only
reading from the socket ones. Obviously a larger export list wouldn't
be read into the buffer with a single read. 

Both of theses issues are addressed in the new code and Matt has been
able to confirm that the script works now. Hopefully my last minute
changes didn't change that.

In the works of creating the library I implemented a couple of more
rpc calls and added two more scripts: nfs-get-stats and
nfs-get-dirlist. The first script gets disk usage statistics of from
each share and the second script lists the first 10 items in the
shared directory.

For these two I would suggest removing the "get" from the script names.
Even with that, nfs-statfs might be better because that's the name of
the NFS procedure--with the name "stats" I was at first expecting to
information like number of accesses and time of last access. Just for
the benefit of other readers, here is what the output looks like:

-- Host script results:
-- | nfs-get-stats:
-- |   /home/storage/backup
-- |     Block size: 512
-- |     Total blocks: 1901338728
-- |     Free blocks: 729769328
-- |     Available blocks: 633186880
-- |   /home
-- |     Block size: 512
-- |     Total blocks: 1901338728
-- |     Free blocks: 729769328
-- |_    Available blocks: 633186880

I tried the scripts. nfs-showmount is still working for me, but
nse-get-dirlist and nfs-get-stats don't work (produce no output) against
Mac OS X nfsd. I traced the problem to the call

        local mountd_ports = getPortsForProgram(host, "mountd", 2)

which is returning an empty table. It works with version 1 in
getNfsExports, but not version 2. Is this just a limitation of the nfsd,
that it can't provide this information?

A packet trace of the scripts running seems to indicate that results are
returned for mountd version 1 and 3, but not 2.

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


Current thread: