Skip to content

Commit 52ffddd

Browse files
author
HD Moore
committed
Adds domain and url options to DHCP/PXE server, lands rapid7#3889
There are serious style and code quality issues with this class and normally I would push for a full refactor, but given the urgency of delivering DHCP functionality to support the bash issues, we will have to refactor the DHCP Server code another day.
2 parents 6516abb + 5dde73b commit 52ffddd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/rex/proto/dhcp/constants.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module DHCP
2121
OpRouter = 3
2222
OpDns = 6
2323
OpHostname = 0x0c
24+
OpDomainname = 0x0f
25+
OpURL = 0x72
2426
OpEnd = 0xff
2527

2628
PXEMagic = "\xF1\x00\x74\x7E"

lib/rex/proto/dhcp/server.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def initialize(hash, context = {})
9494
self.pxealtconfigfile = "update0"
9595
self.pxepathprefix = ""
9696
self.pxereboottime = 2000
97+
98+
self.domainname = hash['DOMAINNAME'] if hash.include?('DOMAINNAME')
99+
self.url = hash['URL'] if hash.include?('URL')
97100
end
98101

99102
def report(&block)
@@ -126,7 +129,7 @@ def set_option(opts)
126129
allowed_options = [
127130
:serveOnce, :pxealtconfigfile, :servePXE, :relayip, :leasetime, :dnsserv,
128131
:pxeconfigfile, :pxepathprefix, :pxereboottime, :router,
129-
:give_hostname, :served_hostname, :served_over, :serveOnlyPXE
132+
:give_hostname, :served_hostname, :served_over, :serveOnlyPXE, :domainname, :url
130133
]
131134

132135
opts.each_pair { |k,v|
@@ -154,7 +157,7 @@ def send_packet(ip, pkt)
154157
attr_accessor :sock, :thread, :myfilename, :ipstring, :served, :serveOnce
155158
attr_accessor :current_ip, :start_ip, :end_ip, :broadcasta, :netmaskn
156159
attr_accessor :servePXE, :pxeconfigfile, :pxealtconfigfile, :pxepathprefix, :pxereboottime, :serveOnlyPXE
157-
attr_accessor :give_hostname, :served_hostname, :served_over, :reporter
160+
attr_accessor :give_hostname, :served_hostname, :served_over, :reporter, :domainname, :url
158161

159162
protected
160163

@@ -317,6 +320,8 @@ def dispatch_request(from, buf)
317320
pkt << dhcpoption(OpHostname, send_hostname)
318321
end
319322
end
323+
pkt << dhcpoption(OpDomainname, self.domainname) if self.domainname
324+
pkt << dhcpoption(OpURL, self.url) if self.url
320325
pkt << dhcpoption(OpEnd)
321326

322327
pkt << ("\x00" * 32) #padding

0 commit comments

Comments
 (0)