convert db_autopwn -I and -X to use RangeWalker; this has bugged me for a long time
git-svn-id: file:///home/svn/framework3/trunk@9309 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
bfe47b85d8
commit
f754b9178a
|
@ -456,9 +456,21 @@ class Db
|
||||||
when '-b'
|
when '-b'
|
||||||
code = :bind
|
code = :bind
|
||||||
when '-I'
|
when '-I'
|
||||||
targ_inc << OptAddressRange.new('TEMPRANGE', [ true, '' ]).normalize(args.shift)
|
tmpopt = OptAddressRange.new('TEMPRANGE', [ true, '' ])
|
||||||
|
range = args.shift
|
||||||
|
if not tmpopt.valid?(range)
|
||||||
|
print_error("Invalid range for -I")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
targ_inc << Rex::Socket::RangeWalker.new(tmpopt.normalize(range))
|
||||||
when '-X'
|
when '-X'
|
||||||
targ_exc << OptAddressRange.new('TEMPRANGE', [ true, '' ]).normalize(args.shift)
|
tmpopt = OptAddressRange.new('TEMPRANGE', [ true, '' ])
|
||||||
|
range = args.shift
|
||||||
|
if not tmpopt.valid?(range)
|
||||||
|
print_error("Invalid range for -X")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
targ_exc << Rex::Socket::RangeWalker.new(tmpopt.normalize(range))
|
||||||
when '-PI'
|
when '-PI'
|
||||||
port_inc = Rex::Socket.portspec_to_portlist(args.shift)
|
port_inc = Rex::Socket.portspec_to_portlist(args.shift)
|
||||||
when '-PX'
|
when '-PX'
|
||||||
|
@ -1045,19 +1057,9 @@ class Db
|
||||||
# Determine if an IP address is inside a given range
|
# Determine if an IP address is inside a given range
|
||||||
#
|
#
|
||||||
def range_include?(ranges, addr)
|
def range_include?(ranges, addr)
|
||||||
|
ranges.each do |range|
|
||||||
ranges.each do |sets|
|
return true if range.include? addr
|
||||||
sets.split(',').each do |set|
|
|
||||||
rng = set.split('-').map{ |c| Rex::Socket::addr_atoi(c) }
|
|
||||||
tst = Rex::Socket::addr_atoi(addr)
|
|
||||||
if (not rng[1])
|
|
||||||
return tst == rng[0]
|
|
||||||
elsif (tst >= rng[0] and tst <= rng[1])
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue