1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 22:21:29 +00:00
Files
nmap/scripts/nfs-acls.nse
patrik dd9a237fe2 o [NSE] Added RPC library and three new NFS scripts. Modified the rpcinfo and
nfs-showmount scripts to use the new library. The new scripts are:
  - nfs-acls shows the owner and directory mode of NFS exports
  - nfs-dirlist lists the contents of NFS exports
  - nfs-statfs shows file system statistics for NFS exports
  [Patrik]
2010-03-21 17:56:17 +00:00

66 lines
1.7 KiB
Lua

description = [[
Shows NFS exports and access controls.
]]
---
-- @output
-- PORT STATE SERVICE
-- 111/tcp open rpcbind
-- | nfs-acls:
-- | /tmp
-- | uid: 0; gid: 0; mode: drwxrwxrwx (1777)
-- | /home/storage/backup
-- | uid: 0; gid: 0; mode: drwxr-xr-x (755)
-- | /home
-- |_ uid: 0; gid: 0; mode: drwxr-xr-x (755)
--
-- Version 0.6
-- Created 11/23/2009 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- Revised 11/24/2009 - v0.2 - added RPC query to find mountd ports
-- Revised 11/24/2009 - v0.3 - added a hostrule instead of portrule
-- Revised 11/26/2009 - v0.4 - reduced packet sizes and documented them
-- Revised 01/24/2009 - v0.5 - complete rewrite, moved all NFS related code into nselib/nfs.lua
-- Revised 02/22/2009 - v0.6 - adapted to support new RPC library
author = "Patrik Karlsson"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery", "safe"}
require("shortport")
require("rpc")
portrule = shortport.port_or_service(111, "rpcbind", {"tcp", "udp"} )
action = function(host, port)
local status, mounts, attribs
local result = {}
status, mounts = rpc.Helper.ShowMounts( host, port )
if ( not(status) or mounts == nil ) then
return " \n\n Failed to list mount points"
end
for _, mount in ipairs( mounts ) do
local item = {}
status, attribs = rpc.Helper.GetAttributes( host, port, mount.name )
item.name = mount.name
if ( status ) then
table.insert(item, ("uid: %d; gid: %d; mode: %s (%d)"):format(attribs.uid, attribs.gid, rpc.Util.ToAclText( attribs.mode ), rpc.Util.ToAclMode( attribs.mode )) )
else
table.insert(item, "ERROR: Mount failed")
end
table.insert(result, item)
end
return stdnse.format_output( true, result )
end