0 0
N [ˆl–Ðz¾”ŠeJeAà™¸ËêbÑ¿�þ\”,Ü¢qÖã#Åx€þì
„Î4×ëa–Ým_JJi?u8 ApMÜeõ1hßê ?÷ [local datafiles = require "datafiles"
local nmap = require "nmap"
local shortport = require "shortport"
local snmp = require "snmp"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local target = require "target"
description = [[
Attempts to enumerate network interfaces through SNMP.
This script can also be run during Nmap's pre-scanning phase and can
attempt to add the SNMP server's interface addresses to the target
list. The script argument snmp-interfaces.host is
required to know what host to probe. To specify a port for the SNMP
server other than 161, use snmp-interfaces.port. When
run in this way, the script's output tells how many new targets were
successfully added.
]]
---
-- @usage
-- nmap -sU -p 161 --script=snmp-interfaces
-- @args snmp-interfaces.host Specifies the SNMP server to probe when
-- running in the "pre-scanning phase".
-- @args snmp-interfaces.port The optional port number corresponding
-- to the host script argument. Defaults to 161.
--
-- @output
-- | snmp-interfaces:
-- | eth0
-- | IP address: 192.168.221.128
-- | MAC address: 00:0c:29:01:e2:74 (VMware)
-- | Type: ethernetCsmacd Speed: 1 Gbps
-- |_ Traffic stats: 6.45 Mb sent, 15.01 Mb received
--
author = {"Thomas Buchanan", "Kris Katterjohn"}
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "discovery", "safe"}
dependencies = {"snmp-brute"}
-- code borrowed heavily from Patrik Karlsson's excellent snmp scripts
-- Created 03/03/2010 - v0.1 - created by Thomas Buchanan
-- Revised 03/05/2010 - v0.2 - Reworked output slightly, moved iana_types to script scope. Suggested by David Fifield
-- Revised 04/11/2010 - v0.2 - moved snmp_walk to snmp library
-- Revised 08/10/2010 - v0.3 - prerule; add interface addresses to Nmap's target list (Kris Katterjohn)
-- Revised 05/27/2011 - v0.4 - action; add MAC addresses to nmap.registry[host.ip]["mac-geolocation"] (Gorjan Petrovski)
-- Revised 07/31/2012 - v0.5 - action; remove mac-geolocation changes (script removed from trunk)
prerule = function()
if not stdnse.get_script_args({"snmp-interfaces.host", "host"}) then
stdnse.debug3("Skipping '%s' %s, 'snmp-interfaces.host' argument is missing.", SCRIPT_NAME, SCRIPT_TYPE)
return false
end
return true
end
portrule = shortport.port_or_service(161, "snmp", "udp", {"open", "open|filtered"})
-- List of IANA-assigned network interface types
-- Taken from IANAifType-MIB
-- Available at http://www.iana.org/assignments/ianaiftype-mib
-- REVISION "201703300000Z" -- March 30, 2017
local iana_types = {
[1] = "other", -- none of the following
[2] = "regular1822",
[3] = "hdh1822",
[4] = "ddnX25",
[5] = "rfc877x25",
[6] = "ethernetCsmacd", -- for all ethernet-like interfaces,
-- regardless of speed, as per RFC3635
[7] = "iso88023Csmacd", -- Deprecated via RFC3635
-- ethernetCsmacd (6) should be used instead
[8] = "iso88024TokenBus",
[9] = "iso88025TokenRing",
[10] = "iso88026Man",
[11] = "starLan", -- Deprecated via RFC3635
-- ethernetCsmacd (6) should be used instead
[12] = "proteon10Mbit",
[13] = "proteon80Mbit",
[14] = "hyperchannel",
[15] = "fddi",
[16] = "lapb",
[17] = "sdlc",
[18] = "ds1", -- DS1-MIB
[19] = "e1", -- Obsolete see DS1-MIB
[20] = "basicISDN", -- no longer used
-- see also RFC2127
[21] = "primaryISDN", -- no longer used
-- see also RFC2127
[22] = "propPointToPointSerial", -- proprietary serial
[23] = "ppp",
[24] = "softwareLoopback",
[25] = "eon", -- CLNP over IP
[26] = "ethernet3Mbit",
[27] = "ns