Skip to content

Commit

Permalink
Enable ipv6 gateway options
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Jan 27, 2017
1 parent a786350 commit 1fe242c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/bettercap/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,20 @@ def initialize

# Update the Context state parsing network related informations.
def update!
gw = @options.core.gateway || Network.get_gateway
raise BetterCap::Error, "Could not detect the gateway address for interface #{@options.core.iface}, "\
'make sure you\'ve specified the correct network interface to use and to have the '\
'correct network configuration, this could also happen if bettercap '\
'is launched from a virtual environment.' unless Network::Validator.is_ip?(gw)
if @options.core.use_ipv6
gw = @options.core.gateway || Network.get_ipv6_gateway
raise BetterCap::Error, "Could not detect the gateway address for interface #{@options.core.iface}, "\
'make sure you\'ve specified the correct network interface to use and to have the '\
'correct network configuration, this could also happen if bettercap '\
'is launched from a virtual environment.' unless Network::Validator.is_ipv6?(gw)

else
gw = @options.core.gateway || Network.get_gateway
raise BetterCap::Error, "Could not detect the gateway address for interface #{@options.core.iface}, "\
'make sure you\'ve specified the correct network interface to use and to have the '\
'correct network configuration, this could also happen if bettercap '\
'is launched from a virtual environment.' unless Network::Validator.is_ip?(gw)
end

unless @options.core.use_mac.nil?
cfg = PacketFu::Utils.ifconfig @options.core.iface
Expand Down
5 changes: 5 additions & 0 deletions lib/bettercap/options/core_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def parse!( ctx, opts )
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)
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
Expand Down

0 comments on commit 1fe242c

Please sign in to comment.