2010-12-25 06:31:38 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2010-12-25 06:31:38 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2010-12-27 18:10:41 +00:00
|
|
|
include Msf::Exploit::Remote::SNMPClient
|
2010-12-25 06:31:38 +00:00
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'SNMP Enumeration Module',
|
|
|
|
'Description' => 'This module allows enumeration of any devices with SNMP
|
2011-01-06 21:35:57 +00:00
|
|
|
protocol support. It supports hardware, software, and network information.
|
2010-12-25 06:31:38 +00:00
|
|
|
The default community used is "public".',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'URL', 'http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol' ],
|
|
|
|
[ 'URL', 'http://net-snmp.sourceforge.net/docs/man/snmpwalk.html' ],
|
|
|
|
[ 'URL', 'http://www.nothink.org/perl/snmpcheck/' ],
|
|
|
|
],
|
|
|
|
'Author' => 'Matteo Cantoni <goony[at]nothink.org>',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
begin
|
|
|
|
snmp = connect_snmp
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2012-05-04 20:11:54 +00:00
|
|
|
fields_order = [
|
|
|
|
"Host IP", "Hostname", "Description", "Contact",
|
|
|
|
"Location", "Uptime snmp", "Uptime system",
|
|
|
|
"System date", "domain", "User accounts",
|
|
|
|
"Network information", "Network interfaces",
|
|
|
|
"Network IP", "Routing information",
|
|
|
|
"TCP connections and listening ports", "Listening UDP ports",
|
|
|
|
"Network services", "Share", "IIS server information",
|
|
|
|
"Storage information", "File system information",
|
|
|
|
"Device information", "Software components",
|
|
|
|
"Processes"
|
|
|
|
]
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2012-05-04 20:11:54 +00:00
|
|
|
output_data = {}
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data = {"Host IP"=>ip}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
sysName = snmp.get_value('1.3.6.1.2.1.1.5.0').to_s
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Hostname"] = sysName.strip
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
# print connected status after the first query so if there are
|
|
|
|
# any timeout or connectivity errors; the code would already
|
|
|
|
# have jumped to error handling where the error status is
|
|
|
|
# already being displayed.
|
2012-05-04 20:11:54 +00:00
|
|
|
print_good("#{ip}, Connected.")
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
sysDesc = snmp.get_value('1.3.6.1.2.1.1.1.0').to_s
|
|
|
|
sysDesc.gsub!(/^\s+|\s+$|\n+|\r+/, ' ')
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Description"] = sysDesc.strip
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
sysContact = snmp.get_value('1.3.6.1.2.1.1.4.0').to_s
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Contact"] = sysContact.strip
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
sysLocation = snmp.get_value('1.3.6.1.2.1.1.6.0').to_s
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Location"] = sysLocation.strip
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
sysUpTimeInstance = snmp.get_value('1.3.6.1.2.1.1.3.0').to_s
|
|
|
|
output_data["Uptime system"] = sysUpTimeInstance.strip
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
hrSystemUptime = snmp.get_value('1.3.6.1.2.1.25.1.1.0').to_s
|
|
|
|
output_data["Uptime snmp"] = hrSystemUptime.strip
|
2010-12-25 06:31:38 +00:00
|
|
|
hrSystemUptime = '-' if hrSystemUptime.to_s =~ /Null/
|
2011-01-06 21:35:57 +00:00
|
|
|
|
|
|
|
year = month = day = hour = minutes = seconds = tenths = 0
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
systemDate = snmp.get_value('1.3.6.1.2.1.25.1.2.0')
|
2011-07-19 17:33:02 +00:00
|
|
|
str = systemDate.to_s
|
2013-06-07 18:55:59 +00:00
|
|
|
if (str.empty? or str =~ /Null/ or str =~ /^noSuch/)
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["System date"] = '-'
|
2010-12-25 06:31:38 +00:00
|
|
|
else
|
2011-01-06 21:35:57 +00:00
|
|
|
|
|
|
|
# RFC 2579 - Textual Conventions for SMIv2
|
|
|
|
# http://www.faqs.org/rfcs/rfc2579.html
|
|
|
|
|
2011-07-19 17:33:02 +00:00
|
|
|
systemDate = systemDate.unpack('C*')
|
|
|
|
|
2011-01-06 21:35:57 +00:00
|
|
|
year = systemDate[0] * 256 + systemDate[1]
|
|
|
|
month = systemDate[2]
|
|
|
|
day = systemDate[3]
|
|
|
|
hour = systemDate[4]
|
|
|
|
minutes = systemDate[5]
|
|
|
|
seconds = systemDate[6]
|
|
|
|
tenths = systemDate[7]
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["System date"] = sprintf("%d-%d-%d %02d:%02d:%02d.%d", year, month, day, hour, minutes, seconds, tenths)
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
if (sysDesc =~ /Windows/)
|
2011-02-04 01:26:23 +00:00
|
|
|
usersLine = ""
|
|
|
|
domPrimaryDomain = snmp.get_value('1.3.6.1.4.1.77.1.4.1.0').to_s
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Domain"] = domPrimaryDomain.strip
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
users = []
|
|
|
|
|
|
|
|
snmp.walk(["1.3.6.1.4.1.77.1.2.25.1.1","1.3.6.1.4.1.77.1.2.25.1"]) do |user,entry|
|
|
|
|
users.push([[user.value]])
|
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not users.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["User accounts"] = users
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information = {}
|
2010-12-25 06:31:38 +00:00
|
|
|
|
|
|
|
ipForwarding = snmp.get_value('1.3.6.1.2.1.4.1.0')
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if ipForwarding == 0 || ipForwarding == 2
|
2010-12-25 06:31:38 +00:00
|
|
|
ipForwarding = "no"
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["IP forwarding enabled"] = ipForwarding
|
2010-12-25 06:31:38 +00:00
|
|
|
elsif ipForwarding == 1
|
|
|
|
ipForwarding = "yes"
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["IP forwarding enabled"] = ipForwarding
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
ipDefaultTTL = snmp.get_value('1.3.6.1.2.1.4.2.0')
|
|
|
|
if ipDefaultTTL.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["Default TTL"] = ipDefaultTTL
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
tcpInSegs = snmp.get_value('1.3.6.1.2.1.6.10.0')
|
|
|
|
if tcpInSegs.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["TCP segments received"] = tcpInSegs
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
tcpOutSegs = snmp.get_value('1.3.6.1.2.1.6.11.0')
|
|
|
|
if tcpOutSegs.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["TCP segments sent"] = tcpOutSegs
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2011-01-06 21:35:57 +00:00
|
|
|
tcpRetransSegs = snmp.get_value('1.3.6.1.2.1.6.12.0')
|
2010-12-25 06:31:38 +00:00
|
|
|
if tcpRetransSegs.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["TCP segments retrans"] = tcpRetransSegs
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
ipInReceives = snmp.get_value('1.3.6.1.2.1.4.3.0')
|
|
|
|
if ipInReceives.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["Input datagrams"] = ipInReceives
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
ipInDelivers = snmp.get_value('1.3.6.1.2.1.4.9.0')
|
|
|
|
if ipInDelivers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["Delivered datagrams"]=ipInDelivers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
ipOutRequests = snmp.get_value('1.3.6.1.2.1.4.10.0')
|
|
|
|
if ipOutRequests.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
network_information["Output datagrams"]=ipOutRequests
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not network_information.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Network information"] = network_information
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
network_interfaces = []
|
|
|
|
|
2011-09-23 17:51:11 +00:00
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.2.2.1.1", "1.3.6.1.2.1.2.2.1.2", "1.3.6.1.2.1.2.2.1.6",
|
|
|
|
"1.3.6.1.2.1.2.2.1.3", "1.3.6.1.2.1.2.2.1.4", "1.3.6.1.2.1.2.2.1.5",
|
|
|
|
"1.3.6.1.2.1.2.2.1.10", "1.3.6.1.2.1.2.2.1.16", "1.3.6.1.2.1.2.2.1.7"
|
|
|
|
]) do |index,descr,mac,type,mtu,speed,inoc,outoc,status|
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
ifindex = index.value
|
|
|
|
ifdescr = descr.value
|
|
|
|
ifmac = mac.value.unpack("H2H2H2H2H2H2").join(":")
|
|
|
|
iftype = type.value
|
|
|
|
ifmtu = mtu.value
|
|
|
|
ifspeed = speed.value.to_i
|
|
|
|
ifinoc = inoc.value
|
|
|
|
ifoutoc = outoc.value
|
|
|
|
ifstatus = status.value
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
case iftype
|
|
|
|
when 1
|
|
|
|
iftype = "other"
|
2011-01-08 01:13:26 +00:00
|
|
|
when 2
|
2010-12-25 06:31:38 +00:00
|
|
|
iftype = "regular1822"
|
|
|
|
when 3
|
|
|
|
iftype = "hdh1822"
|
|
|
|
when 4
|
|
|
|
iftype = "ddn-x25"
|
|
|
|
when 5
|
|
|
|
iftype = "rfc877-x25"
|
|
|
|
when 6
|
|
|
|
iftype = "ethernet-csmacd"
|
|
|
|
when 7
|
|
|
|
iftype = "iso88023-csmacd"
|
|
|
|
when 8
|
|
|
|
iftype = "iso88024-tokenBus"
|
|
|
|
when 9
|
|
|
|
iftype = "iso88025-tokenRing"
|
|
|
|
when 10
|
|
|
|
iftype = "iso88026-man"
|
|
|
|
when 11
|
|
|
|
iftype = "starLan"
|
|
|
|
when 12
|
|
|
|
iftype = "proteon-10Mbit"
|
|
|
|
when 13
|
|
|
|
iftype = "proteon-80Mbit"
|
|
|
|
when 14
|
|
|
|
iftype = "hyperchannel"
|
|
|
|
when 15
|
|
|
|
iftype = "fddi"
|
|
|
|
when 16
|
|
|
|
iftype = "lapb"
|
|
|
|
when 17
|
|
|
|
iftype = "sdlc"
|
|
|
|
when 18
|
|
|
|
iftype = "ds1"
|
|
|
|
when 19
|
|
|
|
iftype = "e1"
|
|
|
|
when 20
|
|
|
|
iftype = "basicISDN"
|
|
|
|
when 21
|
|
|
|
iftype = "primaryISDN"
|
|
|
|
when 22
|
|
|
|
iftype = "propPointToPointSerial"
|
|
|
|
when 23
|
|
|
|
iftype = "ppp"
|
|
|
|
when 24
|
|
|
|
iftype = "softwareLoopback"
|
|
|
|
when 25
|
|
|
|
iftype = "eon"
|
|
|
|
when 26
|
|
|
|
iftype = "ethernet-3Mbit"
|
|
|
|
when 27
|
|
|
|
iftype = "nsip"
|
|
|
|
when 28
|
|
|
|
iftype = "slip"
|
|
|
|
when 29
|
|
|
|
iftype = "ultra"
|
|
|
|
when 30
|
|
|
|
iftype = "ds3"
|
|
|
|
when 31
|
|
|
|
iftype = "sip"
|
|
|
|
when 32
|
|
|
|
iftype = "frame-relay"
|
|
|
|
else
|
|
|
|
iftype = "unknown"
|
|
|
|
end
|
|
|
|
|
|
|
|
case ifstatus
|
|
|
|
when 1
|
|
|
|
ifstatus = "up"
|
|
|
|
when 2
|
|
|
|
ifstatus = "down"
|
|
|
|
when 3
|
|
|
|
ifstatus = "testing"
|
|
|
|
else
|
|
|
|
ifstatus = "unknown"
|
|
|
|
end
|
|
|
|
|
|
|
|
ifspeed = ifspeed / 1000000
|
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
network_interfaces.push({
|
2012-05-04 20:11:54 +00:00
|
|
|
"Interface" => "[ #{ifstatus} ] #{ifdescr}",
|
|
|
|
"Id" => ifindex,
|
|
|
|
"Mac Address" => ifmac,
|
|
|
|
"Type" => iftype,
|
|
|
|
"Speed" => "#{ifspeed} Mbps",
|
|
|
|
"MTU" => ifmtu,
|
|
|
|
"In octets" => ifinoc,
|
|
|
|
"Out octets" => ifoutoc
|
|
|
|
})
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not network_interfaces.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Network interfaces"] = network_interfaces
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
network_ip = []
|
|
|
|
|
2011-09-23 17:51:11 +00:00
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.4.20.1.2", "1.3.6.1.2.1.4.20.1.1",
|
|
|
|
"1.3.6.1.2.1.4.20.1.3", "1.3.6.1.2.1.4.20.1.4"
|
|
|
|
]) do |ifid,ipaddr,netmask,bcast|
|
2011-02-04 01:26:23 +00:00
|
|
|
network_ip.push([ifid.value, ipaddr.value, netmask.value, bcast.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not network_ip.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Network IP"] = [["Id","IP Address","Netmask","Broadcast"]] + network_ip
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
routing = []
|
|
|
|
|
2011-09-23 17:51:11 +00:00
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.4.21.1.1", "1.3.6.1.2.1.4.21.1.7",
|
|
|
|
"1.3.6.1.2.1.4.21.1.11","1.3.6.1.2.1.4.21.1.3"
|
|
|
|
]) do |dest,hop,mask,metric|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (metric.value.to_s.empty?)
|
|
|
|
metric.value = '-'
|
|
|
|
end
|
2011-02-04 01:26:23 +00:00
|
|
|
routing.push([dest.value, hop.value, mask.value, metric.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not routing.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Routing information"] = [["Destination","Next hop","Mask","Metric"]] + routing
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
tcp = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.6.13.1.2","1.3.6.1.2.1.6.13.1.3","1.3.6.1.2.1.6.13.1.4",
|
|
|
|
"1.3.6.1.2.1.6.13.1.5","1.3.6.1.2.1.6.13.1.1"
|
|
|
|
]) do |ladd,lport,radd,rport,state|
|
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (ladd.value.to_s.empty? or ladd.value.to_s =~ /noSuchInstance/)
|
|
|
|
ladd = "-"
|
|
|
|
else
|
|
|
|
ladd = ladd.value
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (lport.value.to_s.empty? or lport.value.to_s =~ /noSuchInstance/)
|
|
|
|
lport = "-"
|
|
|
|
else
|
|
|
|
lport = lport.value
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (radd.value.to_s.empty? or radd.value.to_s =~ /noSuchInstance/)
|
|
|
|
radd = "-"
|
|
|
|
else
|
|
|
|
radd = radd.value
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (rport.value.to_s.empty? or rport.value.to_s =~ /noSuchInstance/)
|
|
|
|
rport = "-"
|
|
|
|
else
|
|
|
|
rport = rport.value
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
case state.value
|
|
|
|
when 1
|
|
|
|
state = "closed"
|
|
|
|
when 2
|
|
|
|
state = "listen"
|
|
|
|
when 3
|
|
|
|
state = "synSent"
|
|
|
|
when 4
|
|
|
|
state = "synReceived"
|
|
|
|
when 5
|
|
|
|
state = "established"
|
|
|
|
when 6
|
|
|
|
state = "finWait1"
|
|
|
|
when 7
|
|
|
|
state = "finWait2"
|
|
|
|
when 8
|
|
|
|
state = "closeWait"
|
|
|
|
when 9
|
|
|
|
state = "lastAck"
|
|
|
|
when 10
|
|
|
|
state = "closing"
|
|
|
|
when 11
|
|
|
|
state = "timeWait"
|
|
|
|
when 12
|
|
|
|
state = "deleteTCB"
|
|
|
|
else
|
|
|
|
state = "unknown"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
tcp.push([ladd, lport, radd, rport, state])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not tcp.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["TCP connections and listening ports"] = [["Local address","Local port","Remote address","Remote port","State"]] + tcp
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
udp = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
snmp.walk(["1.3.6.1.2.1.7.5.1.1","1.3.6.1.2.1.7.5.1.2"]) do |ladd,lport|
|
2011-02-04 01:26:23 +00:00
|
|
|
udp.push([ladd.value, lport.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not udp.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Listening UDP ports"] = [["Local address","Local port"]] + udp
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if (sysDesc =~ /Windows/)
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
network_services = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
n = 0
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
snmp.walk(["1.3.6.1.4.1.77.1.2.3.1.1","1.3.6.1.4.1.77.1.2.3.1.2"]) do |name,installed|
|
2011-02-04 01:26:23 +00:00
|
|
|
network_services.push([n,name.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
n+=1
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not network_services.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Network services"] = [["Index","Name"]] + network_services
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
share = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.4.1.77.1.2.27.1.1","1.3.6.1.4.1.77.1.2.27.1.2","1.3.6.1.4.1.77.1.2.27.1.3"
|
|
|
|
]) do |name,path,comment|
|
2011-02-04 01:26:23 +00:00
|
|
|
share.push({" Name"=>name.value, " Path"=>path.value, " Comment"=>comment.value})
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not share.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Share"] = share
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
iis = {}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalBytesSentLowWord = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.2.0')
|
|
|
|
if http_totalBytesSentLowWord.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["TotalBytesSentLowWord"] = http_totalBytesSentLowWord
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalBytesReceivedLowWord = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.4.0')
|
|
|
|
if http_totalBytesReceivedLowWord.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["TotalBytesReceivedLowWord"] = http_totalBytesReceivedLowWord
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalFilesSent = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.5.0')
|
|
|
|
if http_totalFilesSent.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["TotalFilesSent"] = http_totalFilesSent
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_currentAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.6.0')
|
|
|
|
if http_currentAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["CurrentAnonymousUsers"] = http_currentAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_currentNonAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.7.0')
|
|
|
|
if http_currentNonAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["CurrentNonAnonymousUsers"] = http_currentNonAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.8.0')
|
|
|
|
if http_totalAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["TotalAnonymousUsers"] = http_totalAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalNonAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.9.0')
|
|
|
|
if http_totalNonAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["TotalNonAnonymousUsers"] = http_totalNonAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_maxAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.10.0')
|
|
|
|
if http_maxAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["MaxAnonymousUsers"] = http_maxAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_maxNonAnonymousUsers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.11.0')
|
|
|
|
if http_maxNonAnonymousUsers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["MaxNonAnonymousUsers"] = http_maxNonAnonymousUsers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_currentConnections = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.12.0')
|
|
|
|
if http_currentConnections.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["CurrentConnections"] = http_currentConnections
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_maxConnections = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.13.0')
|
|
|
|
if http_maxConnections.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["MaxConnections"] = http_maxConnections
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_connectionAttempts = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.14.0')
|
|
|
|
if http_connectionAttempts.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["ConnectionAttempts"] = http_connectionAttempts
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_logonAttempts = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.15.0')
|
|
|
|
if http_logonAttempts.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["LogonAttempts"] = http_logonAttempts
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalGets = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.16.0')
|
|
|
|
if http_totalGets.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["Gets"] = http_totalGets
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalPosts = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.17.0')
|
|
|
|
if http_totalPosts.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["Posts"] = http_totalPosts
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalHeads = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.18.0')
|
|
|
|
if http_totalHeads.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["Heads"] = http_totalHeads
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalOthers = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.19.0')
|
|
|
|
if http_totalOthers.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["Others"] = http_totalOthers
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalCGIRequests = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.20.0')
|
|
|
|
if http_totalCGIRequests.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["CGIRequests"] = http_totalCGIRequests
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalBGIRequests = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.21.0')
|
|
|
|
if http_totalBGIRequests.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["BGIRequests"] = http_totalBGIRequests
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
http_totalNotFoundErrors = snmp.get_value('1.3.6.1.4.1.311.1.7.3.1.22.0')
|
|
|
|
if http_totalNotFoundErrors.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
iis["NotFoundErrors"] = http_totalNotFoundErrors
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not iis.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["IIS server information"] = iis
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
storage_information = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.25.2.3.1.1", "1.3.6.1.2.1.25.2.3.1.2", "1.3.6.1.2.1.25.2.3.1.3",
|
|
|
|
"1.3.6.1.2.1.25.2.3.1.4", "1.3.6.1.2.1.25.2.3.1.5", "1.3.6.1.2.1.25.2.3.1.6"
|
|
|
|
]) do |index,type,descr,allocation,size,used|
|
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
case type.value.to_s
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.1$/
|
|
|
|
type.value = "Other"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.2$/
|
|
|
|
type.value = "Ram"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.3$/
|
|
|
|
type.value = "Virtual Memory"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.4$/
|
|
|
|
type.value = "Fixed Disk"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.5$/
|
|
|
|
type.value = "Removable Disk"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.6$/
|
|
|
|
type.value = "Floppy Disk"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.7$/
|
|
|
|
type.value = "Compact Disc"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.8$/
|
|
|
|
type.value = "RamDisk"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.9$/
|
|
|
|
type.value = "Flash Memory"
|
|
|
|
when /^1.3.6.1.2.1.25.2.1.10$/
|
|
|
|
type.value = "Network Disk"
|
|
|
|
else
|
|
|
|
type.value = "unknown"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
allocation.value = "unknown" if allocation.value.to_s =~ /noSuchInstance/
|
2011-01-06 21:35:57 +00:00
|
|
|
size.value = "unknown" if size.value.to_s =~ /noSuchInstance/
|
|
|
|
used.value = "unknown" if used.value.to_s =~ /noSuchInstance/
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
storage_information.push([[descr.value],[index.value],[type.value],[allocation.value],[size.value],[used.value]])
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not storage_information.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
storage = []
|
2010-12-25 06:31:38 +00:00
|
|
|
storage_information.each {|a,b,c,d,e,f|
|
2011-02-04 01:26:23 +00:00
|
|
|
s = {}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
e = number_to_human_size(e,d)
|
|
|
|
f = number_to_human_size(f,d)
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2012-05-04 20:11:54 +00:00
|
|
|
s["Description"]= a
|
|
|
|
s["Device id"] = b
|
|
|
|
s["Filesystem type"] = c
|
|
|
|
s["Device unit"] = d
|
|
|
|
s["Memory size"] = e
|
|
|
|
s["Memory used"] = f
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
storage.push(s)
|
2010-12-25 06:31:38 +00:00
|
|
|
}
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Storage information"] = storage
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system = {}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSIndex = snmp.get_value('1.3.6.1.2.1.25.3.8.1.1.1')
|
|
|
|
if hrFSIndex.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Index"] = hrFSIndex
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSMountPoint = snmp.get_value('1.3.6.1.2.1.25.3.8.1.2.1')
|
|
|
|
if hrFSMountPoint.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Mount point"] = hrFSMountPoint
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSRemoteMountPoint = snmp.get_value('1.3.6.1.2.1.25.3.8.1.3.1')
|
2013-06-07 18:55:59 +00:00
|
|
|
if hrFSRemoteMountPoint.to_s !~ /Null/ and hrFSRemoteMountPoint.to_s !~ /^noSuch/
|
2011-01-06 21:35:57 +00:00
|
|
|
if hrFSRemoteMountPoint.empty?
|
|
|
|
hrFSRemoteMountPoint = '-'
|
|
|
|
end
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Remote mount point"] = hrFSRemoteMountPoint
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSType = snmp.get_value('1.3.6.1.2.1.25.3.8.1.4.1')
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
case hrFSType.to_s
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.1$/
|
|
|
|
hrFSType = "Other"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.2$/
|
|
|
|
hrFSType = "Unknown"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.3$/
|
|
|
|
hrFSType = "BerkeleyFFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.4$/
|
|
|
|
hrFSType = "Sys5FS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.5$/
|
|
|
|
hrFSType = "Fat"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.6$/
|
|
|
|
hrFSType = "HPFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.7$/
|
|
|
|
hrFSType = "HFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.8$/
|
|
|
|
hrFSType = "MFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.9$/
|
|
|
|
hrFSType = "NTFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.10$/
|
|
|
|
hrFSType = "VNode"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.11$/
|
|
|
|
hrFSType = "Journaled"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.12$/
|
|
|
|
hrFSType = "iso9660"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.13$/
|
|
|
|
hrFSType = "RockRidge"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.14$/
|
|
|
|
hrFSType = "NFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.15$/
|
|
|
|
hrFSType = "Netware"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.16$/
|
|
|
|
hrFSType = "AFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.17$/
|
|
|
|
hrFSType = "DFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.18$/
|
|
|
|
hrFSType = "Appleshare"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.19$/
|
|
|
|
hrFSType = "RFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.20$/
|
|
|
|
hrFSType = "DGCFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.21$/
|
|
|
|
hrFSType = "BFS"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.22$/
|
|
|
|
hrFSType = "FAT32"
|
|
|
|
when /^1.3.6.1.2.1.25.3.9.23$/
|
|
|
|
hrFSType = "LinuxExt2"
|
|
|
|
else
|
|
|
|
hrFSType = "Null"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if hrFSType.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Type"] = hrFSType
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSAccess = snmp.get_value('1.3.6.1.2.1.25.3.8.1.5.1')
|
|
|
|
if hrFSAccess.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Access"] = hrFSAccess
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
hrFSBootable = snmp.get_value('1.3.6.1.2.1.25.3.8.1.6.1')
|
|
|
|
if hrFSBootable.to_s !~ /Null/
|
2011-02-04 01:26:23 +00:00
|
|
|
file_system["Bootable"] = hrFSBootable
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if not file_system.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["File system information"] = file_system
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
device_information = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.25.3.2.1.1", "1.3.6.1.2.1.25.3.2.1.2",
|
|
|
|
"1.3.6.1.2.1.25.3.2.1.5", "1.3.6.1.2.1.25.3.2.1.3"
|
|
|
|
]) do |index,type,status,descr|
|
|
|
|
|
2011-01-06 21:35:57 +00:00
|
|
|
case type.value.to_s
|
2010-12-25 06:31:38 +00:00
|
|
|
when /^1.3.6.1.2.1.25.3.1.1$/
|
|
|
|
type.value = "Other"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.2$/
|
|
|
|
type.value = "Unknown"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.3$/
|
|
|
|
type.value = "Processor"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.4$/
|
|
|
|
type.value = "Network"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.5$/
|
|
|
|
type.value = "Printer"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.6$/
|
|
|
|
type.value = "Disk Storage"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.10$/
|
|
|
|
type.value = "Video"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.11$/
|
|
|
|
type.value = "Audio"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.12$/
|
|
|
|
type.value = "Coprocessor"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.13$/
|
|
|
|
type.value = "Keyboard"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.14$/
|
|
|
|
type.value = "Modem"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.15$/
|
|
|
|
type.value = "Parallel Port"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.16$/
|
|
|
|
type.value = "Pointing"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.17$/
|
|
|
|
type.value = "Serial Port"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.18$/
|
|
|
|
type.value = "Tape"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.19$/
|
|
|
|
type.value = "Clock"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.20$/
|
|
|
|
type.value = "Volatile Memory"
|
|
|
|
when /^1.3.6.1.2.1.25.3.1.21$/
|
|
|
|
type.value = "Non Volatile Memory"
|
|
|
|
else
|
|
|
|
type.value = "unknown"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
case status.value
|
|
|
|
when 1
|
|
|
|
status.value = "unknown"
|
|
|
|
when 2
|
|
|
|
status.value = "running"
|
|
|
|
when 3
|
|
|
|
status.value = "warning"
|
|
|
|
when 4
|
|
|
|
status.value = "testing"
|
|
|
|
when 5
|
|
|
|
status.value = "down"
|
|
|
|
else
|
|
|
|
status.value = "unknown"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
descr.value = "unknown" if descr.value.to_s =~ /noSuchInstance/
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
device_information.push([index.value, type.value, status.value, descr.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not device_information.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Device information"] = [["Id","Type","Status","Descr"]] + device_information
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
software_list = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
snmp.walk(["1.3.6.1.2.1.25.6.3.1.1","1.3.6.1.2.1.25.6.3.1.2"]) do |index,name|
|
2011-02-04 01:26:23 +00:00
|
|
|
software_list.push([index.value,name.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not software_list.empty?
|
2011-02-04 01:26:23 +00:00
|
|
|
output_data["Software components"] = [["Index","Name"]] + software_list
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
process_interfaces = []
|
2011-09-23 17:51:11 +00:00
|
|
|
|
|
|
|
snmp.walk([
|
|
|
|
"1.3.6.1.2.1.25.4.2.1.1", "1.3.6.1.2.1.25.4.2.1.2", "1.3.6.1.2.1.25.4.2.1.4",
|
|
|
|
"1.3.6.1.2.1.25.4.2.1.5", "1.3.6.1.2.1.25.4.2.1.7"
|
|
|
|
]) do |id,name,path,param,status|
|
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
if status.value == 1
|
|
|
|
status.value = "running"
|
|
|
|
elsif status.value == 2
|
|
|
|
status.value = "runnable"
|
|
|
|
else
|
|
|
|
status.value = "unknown"
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
process_interfaces.push([id.value, status.value, name.value, path.value, param.value])
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-01-08 01:13:26 +00:00
|
|
|
if not process_interfaces.empty?
|
2012-05-04 20:11:54 +00:00
|
|
|
output_data["Processes"] = [["Id","Status","Name","Path","Parameters"]] + process_interfaces
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2012-05-04 20:11:54 +00:00
|
|
|
print_line("\n[*] System information:\n")
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
line = ""
|
|
|
|
width = 30 # name field width
|
2011-10-27 22:07:41 +00:00
|
|
|
twidth = 32 # table like display cell width
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
fields_order.each {|k|
|
|
|
|
if not output_data.has_key?(k)
|
|
|
|
next
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
v = output_data[k]
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
case v
|
|
|
|
when Array
|
|
|
|
content = ""
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
v.each{ |a|
|
|
|
|
case a
|
|
|
|
when Hash
|
|
|
|
a.each{ |sk, sv|
|
2011-10-27 22:07:41 +00:00
|
|
|
sk = truncate_to_twidth(sk, twidth)
|
2012-05-04 20:11:54 +00:00
|
|
|
content << sprintf("%s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
2011-02-04 01:26:23 +00:00
|
|
|
}
|
|
|
|
content << "\n"
|
|
|
|
when Array
|
|
|
|
a.each { |sv|
|
|
|
|
sv = sv.to_s.strip
|
2012-05-04 20:11:54 +00:00
|
|
|
# I don't like cutting info
|
|
|
|
#sv = truncate_to_twidth(sv, twidth)
|
|
|
|
content << sprintf("%-20s", sv)
|
2011-02-04 01:26:23 +00:00
|
|
|
}
|
|
|
|
content << "\n"
|
|
|
|
else
|
|
|
|
content << sprintf(" %s\n", a)
|
|
|
|
content << "\n"
|
|
|
|
end
|
|
|
|
}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:sname => 'snmp',
|
|
|
|
:port => datastore['RPORT'].to_i,
|
|
|
|
:type => "snmp.#{k}",
|
|
|
|
:data => content
|
|
|
|
)
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2012-05-04 20:11:54 +00:00
|
|
|
line << "\n[*] #{k}:\n\n#{content}"
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
when Hash
|
|
|
|
content = ""
|
|
|
|
v.each{ |sk, sv|
|
2011-10-27 22:07:41 +00:00
|
|
|
sk = truncate_to_twidth(sk,twidth)
|
2012-05-04 20:11:54 +00:00
|
|
|
content << sprintf("%s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
2011-02-04 01:26:23 +00:00
|
|
|
}
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:sname => 'snmp',
|
|
|
|
:port => datastore['RPORT'].to_i,
|
|
|
|
:type => "snmp.#{k}",
|
|
|
|
:data => content
|
|
|
|
)
|
|
|
|
|
2012-05-04 20:11:54 +00:00
|
|
|
line << "\n[*] #{k}:\n\n#{content}"
|
2011-02-04 01:26:23 +00:00
|
|
|
content << "\n"
|
|
|
|
else
|
|
|
|
if (v.nil? or v.empty? or v =~ /Null/)
|
|
|
|
v = '-'
|
|
|
|
end
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-02-04 01:26:23 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:sname => 'snmp',
|
|
|
|
:port => datastore['RPORT'].to_i,
|
|
|
|
:type => "snmp.#{k}",
|
|
|
|
:data => v
|
|
|
|
)
|
2011-09-23 17:51:11 +00:00
|
|
|
|
2011-10-27 22:07:41 +00:00
|
|
|
k = truncate_to_twidth(k,twidth)
|
2011-09-23 17:51:11 +00:00
|
|
|
line << sprintf("%s%s: %s\n", k, " "*([0,width-k.length].max), v)
|
2011-02-04 01:26:23 +00:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
print_line(line)
|
2011-01-08 01:13:26 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
print_line('')
|
|
|
|
|
2012-11-23 03:36:33 +00:00
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
|
|
|
|
rescue SNMP::RequestTimeout
|
2012-11-23 03:36:33 +00:00
|
|
|
vprint_status("#{ip} SNMP request timeout.")
|
|
|
|
rescue Rex::ConnectionError
|
|
|
|
print_status("#{ip} Connection refused.")
|
2010-12-25 06:31:38 +00:00
|
|
|
rescue SNMP::InvalidIpAddress
|
2012-11-23 03:36:33 +00:00
|
|
|
print_status("#{ip} Invalid IP Address. Check it with 'snmpwalk tool'.")
|
2012-05-04 20:11:54 +00:00
|
|
|
rescue SNMP::UnsupportedVersion
|
2012-11-23 03:36:33 +00:00
|
|
|
print_status("#{ip} Unsupported SNMP version specified. Select from '1' or '2c'.")
|
2010-12-25 06:31:38 +00:00
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_status("Unknown error: #{e.class} #{e}")
|
2012-11-23 03:36:33 +00:00
|
|
|
ensure
|
|
|
|
disconnect_snmp
|
2010-12-25 06:31:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-27 22:07:41 +00:00
|
|
|
def truncate_to_twidth(string,twidth)
|
|
|
|
string.slice(0..twidth-2)
|
|
|
|
end
|
|
|
|
|
2010-12-25 06:31:38 +00:00
|
|
|
def number_to_human_size(size,unit)
|
2011-01-08 01:13:26 +00:00
|
|
|
size = size.first.to_i * unit.first.to_i
|
2010-12-25 06:31:38 +00:00
|
|
|
|
|
|
|
if size < 1024
|
|
|
|
"#{size} bytes"
|
|
|
|
elsif size < 1024.0 * 1024.0
|
|
|
|
"%.02f KB" % (size / 1024.0)
|
|
|
|
elsif size < 1024.0 * 1024.0 * 1024.0
|
|
|
|
"%.02f MB" % (size / 1024.0 / 1024.0)
|
|
|
|
else
|
|
|
|
"%.02f GB" % (size / 1024.0 / 1024.0 / 1024.0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|