From 9ba0916937108d09764b4ec8c16f184c3c0cff7f Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Sat, 14 Aug 2010 20:21:14 +0000 Subject: [PATCH] fix port bug, add diff from sj, see #2329 git-svn-id: file:///home/svn/framework3/trunk@10015 4d416f70-5f16-0410-b530-b9f4589650da --- lib/rex/proto/dhcp/server.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/rex/proto/dhcp/server.rb b/lib/rex/proto/dhcp/server.rb index 4b387d3d9b..ca2911fdae 100644 --- a/lib/rex/proto/dhcp/server.rb +++ b/lib/rex/proto/dhcp/server.rb @@ -20,7 +20,7 @@ class Server def initialize(hash, context = {}) self.listen_host = '0.0.0.0' # clients don't already have addresses. Needs to be 0.0.0.0 - self.listen_port = 67 # mandatory + self.listen_port = 67 # mandatory (bootps) self.context = context self.sock = nil @@ -32,12 +32,10 @@ class Server source = hash['SRVHOST'] || Rex::Socket.source_address self.ipstring = Rex::Socket.addr_aton(source) - first_ip = hash['DHCPIPSTART'] || "#{self.ipstring[0..2]}\x20" #?? - self.start_ip = Rex::Socket.addr_atoi(first_ip) + self.start_ip = Rex::Socket.addr_atoi(hash['DHCPIPSTART']) || "#{self.ipstring[0..2]}\x20" #default range x.x.x.32-254 self.current_ip = start_ip - last_ip = hash['DHCPIPEND'] || "#{self.ipstring[0..2]}\xfe" - self.end_ip = Rex::Socket.addr_atoi(last_ip) + self.end_ip = Rex::Socket.addr_atoi(hash['DHCPIPEND']) || "#{self.ipstring[0..2]}\xfe" # netmask netmask = hash['NETMASK'] || "255.255.255.0" @@ -114,10 +112,11 @@ class Server # Send a single packet to the specified host def send_packet(ip, pkt) + port = 68 # bootpc if ip - self.sock.sendto( pkt, ip, 67 ) + self.sock.sendto( pkt, ip, port ) else - self.sock.sendto( pkt, '255.255.255.255', 67 ) + self.sock.sendto( pkt, '255.255.255.255', port ) end end