Skip to content

Commit

Permalink
Removed IPv6 specific options, use of IPv6 is automatically detected …
Browse files Browse the repository at this point in the history
…now.
  • Loading branch information
evilsocket committed Feb 27, 2017
1 parent b93225c commit 777b7f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
36 changes: 23 additions & 13 deletions lib/bettercap/options/core_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,13 @@ def parse!( ctx, opts )

opts.on( '-G', '--gateway ADDRESS', 'Manually specify the gateway address, if not specified the current gateway will be retrieved and used. ' ) do |v|
@gateway = v
raise BetterCap::Error, "The specified gateway '#{v}' is not a valid IPv4 address." unless Network::Validator.is_ip?(v)
end

opts.on( '--gateway6 ADDRESS', 'Manually specify the IPv6 gateway address, if not specified the current gateway will be retrieved and used. ' ) do |v|
@gateway = v
raise BetterCap::Error, "The specified gateway '#{v}' is not a valid IPv6 address." unless Network::Validator.is_ipv6?(v)
check_ip!( v, "The specified gateway '#{v}' is not a valid IPv4 or IPv6 address." )
end

opts.on( '-T', '--target ADDRESS1,ADDRESS2', 'Target IP addresses, if not specified the whole subnet will be targeted.' ) do |v|
self.targets = v
end

opts.on( '-t', '--target6 ADDRESS1,ADDRESS2', 'Target IPv6 addresses.' ) do |v|
@use_ipv6 = true
self.targets = v
end

opts.on( '--ignore ADDRESS1,ADDRESS2', 'Ignore these addresses if found while searching for targets.' ) do |v|
self.ignore = v
end
Expand Down Expand Up @@ -160,6 +150,16 @@ def validate!
raise BetterCap::Error, 'No default interface found, please specify one with the -I argument.' if @iface.nil?
end

def check_ip!(v,error)
if Network::Validator.is_ip?(v)
@use_ipv6 = false
elsif Network::Validator.is_ipv6?(v)
@use_ipv6 = true
else
raise BetterCap::Error, error
end
end

# Return true if active host discovery is enabled, otherwise false.
def discovery?
( @discovery and @targets.nil? )
Expand All @@ -171,8 +171,12 @@ def targets=(value)
@targets = []

value.split(",").each do |t|
if Network::Validator.is_ip?(t) or Network::Validator.is_mac?(t) or Network::Validator.is_ipv6?(t)
if Network::Validator.is_ip?(t) or Network::Validator.is_mac?(t)
@targets << Network::Target.new(t)

elsif Network::Validator.is_ipv6?(t)
@targets << Network::Target.new(t)
@use_ipv6 = true

elsif Network::Validator.is_range?(t)
Network::Validator.each_in_range( t ) do |address|
Expand All @@ -195,7 +199,7 @@ def targets=(value)
# or more invalid IP addresses are specified.
def ignore=(value)
@ignore = value.split(",")
valid = @ignore.select { |target| Network::Validator.is_ip?(target) }
valid = @ignore.select { |target| ( Network::Validator.is_ip?(target) or Network::Validator.is_ipv6?(target) ) }

raise BetterCap::Error, "Invalid ignore addresses specified." if valid.empty?

Expand All @@ -204,6 +208,12 @@ def ignore=(value)
Logger.warn "Not a valid address: #{target}"
end

valid.each do |target|
if Network::Validator.is_ipv6?(target)
@use_ipv6 = true
end
end

@ignore = valid

Logger.warn "Ignoring #{valid.join(", ")} ."
Expand Down
2 changes: 1 addition & 1 deletion lib/bettercap/options/spoof_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse!( ctx, opts )
opts.separator "SPOOFING:".bold
opts.separator ""

opts.on( '-S', '--spoofer NAME', "Spoofer module to use, available: #{Spoofers::Base.available.map{|x| x.yellow }.join(', ')} - default: #{@spoofer.yellow}." ) do |v|
opts.on( '-S', '--spoofer NAME', "Spoofer module to use, available: #{Spoofers::Base.available.map{|x| x.yellow }.join(', ')} - default: #{@spoofer.yellow} for IPv4 and #{'NDP'.yellow} for IPv6." ) do |v|
@spoofer = v
end

Expand Down

0 comments on commit 777b7f2

Please sign in to comment.