Nmap snmp-brute NSE Script


This page contains detailed information about how to use the snmp-brute NSE script. For list of all NSE scripts, visit the Nmap NSE Library.

Select:
Overview
Error Messages

Script Overview


Script source code: https://github.com/nmap/nmap/tree/master/scripts/snmp-brute.nse
Script categories: intrusive, brute
Target service / protocol: snmp, udp
Target network port(s): 161
List of CVEs: -

Script Description


The snmp-brute.nse script attempts to find an SNMP community string by brute force guessing.

This script opens a sending socket and a sniffing pcap socket in parallel threads. The sending socket sends the SNMP probes with the community strings, while the pcap socket sniffs the network for an answer to the probes. If valid community strings are found, they are added to the creds database and reported in the output.

The script takes the snmp-brute.communitiesdb argument that allows the user to define the file that contains the community strings to be used. If not defined, the default wordlist used to bruteforce the SNMP community strings is nselib/data/snmpcommunities.lst. In case this wordlist does not exist, the script falls back to nselib/data/passwords.lst

No output is reported if no valid account is found.

Snmp-brute NSE Script Arguments


This is a full list of arguments supported by the snmp-brute.nse script:

snmp-brute.communitiesdb

The filename of a list of community strings to try.

creds.global

Credentials to be returned by Credentials.getCredentials regardless of the service.

creds.[service]

Credentials to be returned by Credentials.getCredentials for [service]. E.g. creds.http=admin:password

creds.[service]

Credentials to be returned by Credentials.getCredentials for [service]. E.g. creds.http=admin:password

snmp.version

The SNMP protocol version. Use "v1" or 0 for SNMPv1 (default) and "v2c" or 1 for SNMPv2c.

passdb

The filename of an alternate password database. Default: nselib/data/passwords.lst

unpwdb.passlimit

The maximum number of passwords passwords will return (default unlimited).

unpwdb.timelimit

The maximum amount of time that any iterator will run before stopping. The value is in seconds by default and you can follow it with ms, s, m, or h for milliseconds, seconds, minutes, or hours. For example, unpwdb.timelimit=30m or unpwdb.timelimit=.5h for 30 minutes. The default depends on the timing template level (see the module description). Use the value 0 to disable the time limit.

unpwdb.userlimit

The maximum number of usernames usernames will return (default unlimited).

userdb

The filename of an alternate username database. Default: nselib/data/usernames.lst

- - -
To use these script arguments, add them to the Nmap command line using the --script-args arg1=value,[arg2=value,..] syntax. For example:

nmap --script=snmp-brute --script-args snmp-brute.communitiesdb=value,creds.global=value <target>

Snmp-brute NSE Script Example Usage


Here's an example of how to use the snmp-brute.nse script:

nmap -sU --script snmp-brute <target> [--script-args snmp-brute.communitiesdb=<wordlist> ]

Snmp-brute NSE Script Example Output


Here's a sample output from the snmp-brute.nse script:

PORT    STATE SERVICE
161/udp open  snmp
| snmp-brute:
|   dragon - Valid credentials
|_  jordan - Valid credentials

Snmp-brute NSE Script Example XML Output


There is no sample XML output for this module. However, by providing the -oX <file> option, Nmap will produce a XML output and save it in the file.xml file.

Authors


  • Philip Pickering
  • Gorjan Petrovski
  • Patrik Karlsson
  • Gioacchino Mazzurco

References


See Also


Related NSE scripts to the snmp-brute.nse script:

Visit Nmap NSE Library for more scripts.

The snmp-brute.nse script may fail with the following error messages. Check for the possible causes by using the code snippets highlighted below found in the script source code. This can often times help in identifying the root cause of the problem.

Cannot find communities list


Here is a relevant code snippet related to the "Cannot find communities list" error message:

97:	  end
98:	end
99:	
100:	local communities_raw = function(path)
101:	  if not path then
102:	    return false, "Cannot find communities list"
103:	  end
104:	
105:	  if not filltable(path, communitiestable) then
106:	    return false, "Error parsing communities list"
107:	  end

Error parsing communities list


Here is a relevant code snippet related to the "Error parsing communities list" error message:

101:	  if not path then
102:	    return false, "Cannot find communities list"
103:	  end
104:	
105:	  if not filltable(path, communitiestable) then
106:	    return false, "Error parsing communities list"
107:	  end
108:	
109:	  return true, closure(communitiestable)
110:	end
111:	

Cannot read the communities file, using the nmap username/password database instead


Here is a relevant code snippet related to the "Cannot read the communities file, using the nmap username/password database instead" error message:

129:	      count_limit = tonumber(stdnse.get_script_args("unpwdb.passlimit"))
130:	    end
131:	
132:	    return true, unpwdb.limited_iterator(iterator, time_limit, count_limit, "communities")
133:	  else
134:	    stdnse.debug1("Cannot read the communities file, using the nmap username/password database instead")
135:	
136:	    return unpwdb.passwords()
137:	  end
138:	end
139:	

Could not send SNMP probe


Here is a relevant code snippet related to the "Could not send SNMP probe" error message:

153:	    end
154:	    payload = snmp.encode(snmp.buildPacket(request, nil, community))
155:	    status, err = socket:send(payload)
156:	    if not status then
157:	      result.status = false
158:	      result.msg = "Could not send SNMP probe"
159:	      condvar "signal"
160:	      return
161:	    end
162:	
163:	    community = nextcommunity()

Failed to read the communities database


Here is a relevant code snippet related to the "Failed to read the communities database" error message:

229:	
230:	action = function(host, port)
231:	  local status, nextcommunity = communities()
232:	
233:	  if not status then
234:	    return fail("Failed to read the communities database")
235:	  end
236:	
237:	  local result = {}
238:	  local threads = {}
239:	

Failed to connect to server


Here is a relevant code snippet related to the "Failed to connect to server" error message:

246:	
247:	  local socket = nmap.new_socket("udp")
248:	  status = socket:connect(host, port)
249:	
250:	  if ( not(status) ) then
251:	    return fail("Failed to connect to server")
252:	  end
253:	
254:	  local status, _, lport = socket:get_info()
255:	  if( not(status) ) then
256:	    return fail("Failed to retrieve local port")

Failed to retrieve local port


Here is a relevant code snippet related to the "Failed to retrieve local port" error message:

251:	    return fail("Failed to connect to server")
252:	  end
253:	
254:	  local status, _, lport = socket:get_info()
255:	  if( not(status) ) then
256:	    return fail("Failed to retrieve local port")
257:	  end
258:	
259:	  local recv_co = stdnse.new_thread(sniff_snmp_responses, host, port, lport, result)
260:	  local send_co = stdnse.new_thread(send_snmp_queries, socket, result, nextcommunity)
261:	

An error occurred:


Here is a relevant code snippet related to the "An error occurred: " error message:

268:	    if recv_dead then break end
269:	  end
270:	
271:	  socket:close()
272:	
273:	  if result.status then
274:	    return creds.Credentials:new(SCRIPT_NAME, host, port):getTable()
275:	  else
276:	    stdnse.debug1("An error occurred: "..result.msg)
277:	  end
278:	end

Version


This page has been created based on Nmap version 7.92.

Go back to menu.