Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter dhcp options from various scripts instead of in dhcp.lua #302

Open
dmiller-nmap opened this issue Feb 12, 2016 · 1 comment
Open
Labels

Comments

@dmiller-nmap
Copy link

dhcp.dhcp_build attempts to enforce a "default" set of DHCP options, increasing to all option if verbosity is set (-v or script selected by name), but this kind of decision should be enforced by the script instead of in the library. This may require exposing the list of "actions" (DHCP options and parsing functions) to scripts.

@h4ck3rk3y
Copy link

@dmiller-nmap how about an argument only_defaults, which if set true won't enforce all options even if verbosity is set.

@@ -405,7 +405,7 @@
 --
 --@return status (true or false)
 --@return The parsed response, as a table.
-function dhcp_build(request_type, ip_address, mac_address, options, request_options, overrides, lease_time, transaction_id)
+function dhcp_build(request_type, ip_address, mac_address, options, request_options, overrides, lease_time, transaction_id, only_defaults)
   local packet = strbuf.new()

   -- Set up the default overrides
@@ -417,7 +417,7 @@
     -- Request the defaults, or there's no verbosity; otherwise, request everything!
     request_options = strbuf.new()
     for i,v in pairs(actions) do
-      if(v.default or nmap.verbosity() > 0) then
+      if(v.default or (not only_defaults and nmap.verbosity() > 0) ) then
         request_options = request_options .. string.char(i)
       end
     end
@@ -603,12 +603,12 @@
 --@param lease_time      [optional] The lease time used when requestint an IP. Default: 1 second.
 --@return status (true or false)
 --@return The parsed response, as a table.
-function make_request(target, request_type, ip_address, mac_address, options, request_options, overrides, lease_time)
+function make_request(target, request_type, ip_address, mac_address, options, request_options, overrides, lease_time, only_defaults)
   -- A unique id that identifies this particular session (and lets us filter out what we don't want to see)
   local transaction_id = overrides and overrides['xid'] or bin.pack("<I", math.random(0, 0x7FFFFFFF))

   -- Generate the packet
-  local status, packet = dhcp_build(request_type, bin.pack(">I", ipOps.todword(ip_address)), mac_address, options, request_options, overrides, lease_time, transaction_id)
+  local status, packet = dhcp_build(request_type, bin.pack(">I", ipOps.todword(ip_address)), mac_address, options, request_options, overrides, lease_time, transaction_id, only_defaults)
   if(not(status)) then
     stdnse.debug1("dhcp: Couldn't build packet: " .. packet)
     return false, "Couldn't build packet: "  .. packet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants