1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00
Files
nmap/scripts/nfs-statfs.nse
patrik 71ca5cceba o [NSE] Improved error handling and reporting and re-designed communication
class in RPC library with patch from Djalal Harouni. [Patrik]
2010-04-22 20:25:38 +00:00

66 lines
1.7 KiB
Lua

description = [[
Retrieves disk space statistics from the remote NFS share
]]
---
-- @output
-- PORT STATE SERVICE
-- | nfs-statfs:
-- | /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
--
-- Version 0.3
-- Created 01/25/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- Revised 02/22/2010 - v0.2 - adapted to support new RPC library
-- Revised 03/13/2010 - v0.3 - converted host to port rule
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 result, entry = {}, {}
local status, mounts = rpc.Helper.ShowMounts( host, port )
if ( not(status) ) then
return stdnse.format_output(false, mounts)
end
for _, v in ipairs( mounts ) do
local entry = {}
local status, stats = rpc.Helper.ExportStats(host, port, v.name)
entry.name = v.name
if (not(status)) then
table.insert(entry, string.format("ERROR: %s", stats))
else
table.insert( entry, string.format("Block size: %d", stats.block_size) )
table.insert( entry, string.format("Total blocks: %d", stats.total_blocks) )
table.insert( entry, string.format("Free blocks: %d", stats.free_blocks) )
table.insert( entry, string.format("Available blocks: %d", stats.available_blocks) )
end
table.insert( result, entry )
end
return stdnse.format_output( true, result )
end