diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
commit | 0d47952611198ef6b1163f366dc03922d20b1475 (patch) | |
tree | 3d840a3b8c0daef0754707bfb9f5e873b6b1ac13 /scripts/snmp-win32-users.nse | |
parent | Initial commit. (diff) | |
download | nmap-0d47952611198ef6b1163f366dc03922d20b1475.tar.xz nmap-0d47952611198ef6b1163f366dc03922d20b1475.zip |
Adding upstream version 7.94+git20230807.3be01efb1+dfsg.upstream/7.94+git20230807.3be01efb1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | scripts/snmp-win32-users.nse | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/scripts/snmp-win32-users.nse b/scripts/snmp-win32-users.nse new file mode 100644 index 0000000..6576c35 --- /dev/null +++ b/scripts/snmp-win32-users.nse @@ -0,0 +1,92 @@ +local nmap = require "nmap" +local shortport = require "shortport" +local snmp = require "snmp" +local table = require "table" + +description = [[ +Attempts to enumerate Windows user accounts through SNMP +]] + +--- +-- @usage +-- nmap -sU -p 161 --script=snmp-win32-users <target> +-- @output +-- | snmp-win32-users: +-- | Administrator +-- | Guest +-- | IUSR_EDUSRV011 +-- | IWAM_EDUSRV011 +-- | SUPPORT_388945a0 +-- | Tomcat +-- | db2admin +-- | ldaptest +-- |_ patrik +-- @xmloutput +-- <elem>Administrator</elem> +-- <elem>Guest</elem> +-- <elem>IUSR_EDUSRV011</elem> +-- <elem>IWAM_EDUSRV011</elem> +-- <elem>SUPPORT_388945a0</elem> +-- <elem>Tomcat</elem> +-- <elem>db2admin</elem> +-- <elem>ldaptest</elem> +-- <elem>patrik</elem> + + +author = "Patrik Karlsson" +license = "Same as Nmap--See https://nmap.org/book/man-legal.html" +categories = {"default", "auth", "safe"} +dependencies = {"snmp-brute"} + +-- Version 0.3 +-- Created 01/15/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net> +-- Revised 01/19/2010 - v0.2 - fixed loop that would occur if a mib did not exist +-- Revised 04/11/2010 - v0.3 - moved snmp_walk to snmp library <patrik@cqure.net> + + +portrule = shortport.port_or_service(161, "snmp", "udp", {"open", "open|filtered"}) + +--- Processes the table and creates the script output +-- +-- @param tbl table containing <code>oid</code> and <code>value</code> +-- @return table with just the values +local function process_answer( tbl ) + + local new_tab = {} + + for _, v in ipairs( tbl ) do + table.insert( new_tab, v.value ) + end + + table.sort( new_tab ) + + return new_tab + +end + +action = function(host, port) + + local snmpoid = "1.3.6.1.4.1.77.1.2.25" + local users = {} + local status + + local snmpHelper = snmp.Helper:new(host, port) + snmpHelper:connect() + + status, users = snmpHelper:walk( snmpoid ) + + if( not(status) ) then + return + end + + users = process_answer( users ) + + if ( users == nil ) or ( #users == 0 ) then + return + end + + nmap.set_port_state(host, port, "open") + + return users +end + |