Script dhcp-discover

Script types: portrule
Categories: discovery, safe
Download: https://svn.nmap.org/nmap/scripts/dhcp-discover.nse

Script Summary

Sends a DHCPINFORM request to a host on UDP port 67 to obtain all the local configuration parameters without allocating a new address.

DHCPINFORM is a DHCP request that returns useful information from a DHCP server, without allocating an IP address. The request sends a list of which fields it wants to know (a handful by default, every field if verbosity is turned on), and the server responds with the fields that were requested. It should be noted that the server doesn't have to return every field, nor does it have to return them in the same order, or honour the request at all. A Linksys WRT54g, for example, completely ignores the list of requested fields and returns a few standard ones. This script displays every field it receives.

With script arguments, the type of DHCP request can be changed, which can lead to interesting results. Additionally, the MAC address can be randomized, which in should override the cache on the DHCP server and assign a new IP address. Extra requests can also be sent to exhaust the IP address range more quickly.

Some of the more useful fields:

  • DHCP Server (the address of the server that responded)
  • Subnet Mask
  • Router
  • DNS Servers
  • Hostname

See also:

Script Arguments

dhcp-discover.dhcptype

The type of DHCP request to make. By default, DHCPINFORM is sent, but this argument can change it to DHCPOFFER, DHCPREQUEST, DHCPDECLINE, DHCPACK, DHCPNAK, DHCPRELEASE or DHCPINFORM. Not all types will evoke a response from all servers, and many require different fields to contain specific values.

dhcp-discover.clientid

Client identifier to use in DHCP option 61. The value is a string, while hardware type 0, appropriate for FQDNs, is assumed. Example: clientid=kurtz is equivalent to specifying clientid-hex=00:6b:75:72:74:7a (see below).

dhcp-discover.mac

Set to native (default) or random or a specific client MAC address in the DHCP request. Keep in mind that you may not see the response if a non-native address is used. Setting it to random will possibly cause the DHCP server to reserve a new IP address each time.

dhcp-discover.requests

Set to an integer to make up to that many requests (and display the results).

dhcp-discover.clientid-hex

Client identifier to use in DHCP option 61. The value is a hexadecimal string, where the first octet is the hardware type.

Example Usage

nmap -sU -p 67 --script=dhcp-discover <target>

Script Output

Interesting ports on 192.168.1.1:
PORT   STATE SERVICE
67/udp open  dhcps
| dhcp-discover:
|   DHCP Message Type: DHCPACK
|   Server Identifier: 192.168.1.1
|   IP Address Lease Time: 1 day, 0:00:00
|   Subnet Mask: 255.255.255.0
|   Router: 192.168.1.1
|_  Domain Name Server: 208.81.7.10, 208.81.7.14

Requires


Author:

  • Ron Bowes

License: Same as Nmap--See https://nmap.org/book/man-legal.html