bettercap 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bettercap/context.rb +14 -0
- data/lib/bettercap/firewalls/base.rb +1 -1
- data/lib/bettercap/monkey/packetfu/utils.rb +1 -1
- data/lib/bettercap/network/network.rb +2 -0
- data/lib/bettercap/network/servers/dnsd.rb +6 -1
- data/lib/bettercap/options/core_options.rb +12 -0
- data/lib/bettercap/proxy/http/streamer.rb +12 -4
- data/lib/bettercap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebf307012a9f7a95c84810c21db31d0ca657575f
|
4
|
+
data.tar.gz: 7aa29333600b9ad15821f2f4ad760dbee5dfcd76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65328453bb055e8ddcea4073eac6b0c5c51b3d1a26c8fcab29f5d0a6be517516af1f5d9f7b21aad2877051dd37d3556e8bb457c781c82ab84e34060508995238
|
7
|
+
data.tar.gz: cff87a74985588e872ac886f5bf9e042bf507cbe911208f56f096eb786cf4783c673d352b8d8d9ddbe3777194dbefe263615171de86c9ab55cba0c8be844bdf5
|
data/lib/bettercap/context.rb
CHANGED
@@ -67,6 +67,7 @@ class Context
|
|
67
67
|
@firewall = Firewalls::Base.get
|
68
68
|
@memory = Memory.new
|
69
69
|
@iface = nil
|
70
|
+
@original_mac = nil
|
70
71
|
@gateway = nil
|
71
72
|
@targets = []
|
72
73
|
@spoofer = nil
|
@@ -85,6 +86,17 @@ class Context
|
|
85
86
|
'correct network configuration, this could also happen if bettercap '\
|
86
87
|
'is launched from a virtual environment.' unless Network::Validator.is_ip?(gw)
|
87
88
|
|
89
|
+
unless @options.core.use_mac.nil?
|
90
|
+
cfg = PacketFu::Utils.ifconfig @options.core.iface
|
91
|
+
raise BetterCap::Error, "Could not determine IPv4 address of '#{@options.core.iface}', make sure this interface "\
|
92
|
+
'is active and connected.' if cfg[:ip4_obj].nil?
|
93
|
+
|
94
|
+
@original_mac = Network::Target.normalized_mac(cfg[:eth_saddr])
|
95
|
+
|
96
|
+
Logger.info "Changing interface MAC address to #{@options.core.use_mac}"
|
97
|
+
|
98
|
+
Shell.ifconfig( "#{@options.core.iface} ether #{@options.core.use_mac}")
|
99
|
+
end
|
88
100
|
|
89
101
|
cfg = PacketFu::Utils.ifconfig @options.core.iface
|
90
102
|
raise BetterCap::Error, "Could not determine IPv4 address of '#{@options.core.iface}', make sure this interface "\
|
@@ -183,6 +195,8 @@ class Context
|
|
183
195
|
|
184
196
|
@dnsd.stop unless @dnsd.nil?
|
185
197
|
@httpd.stop unless @httpd.nil?
|
198
|
+
|
199
|
+
Shell.ifconfig( "#{@options.core.iface} ether #{@original_mac}") unless @original_mac.nil?
|
186
200
|
end
|
187
201
|
|
188
202
|
private
|
@@ -22,7 +22,7 @@ class Base
|
|
22
22
|
def get
|
23
23
|
return @@instance unless @@instance.nil?
|
24
24
|
|
25
|
-
if RUBY_PLATFORM =~ /
|
25
|
+
if RUBY_PLATFORM =~ /.+bsd/ or RUBY_PLATFORM =~ /darwin/
|
26
26
|
@@instance = Firewalls::BSD.new
|
27
27
|
elsif RUBY_PLATFORM =~ /linux/
|
28
28
|
@@instance = Firewalls::Linux.new
|
@@ -62,7 +62,12 @@ class DNSD
|
|
62
62
|
|
63
63
|
block = Proc.new do |transaction|
|
64
64
|
Logger.info "[#{transaction.options[:peer]} > #{'DNS'.green}] Received request for '#{transaction.question.to_s.yellow}', sending spoofed reply #{addr.yellow} ..."
|
65
|
-
|
65
|
+
begin
|
66
|
+
transaction.respond!(addr)
|
67
|
+
rescue Exception => e
|
68
|
+
Logger.warn "[#{'DNS'.green}] #{e.message}"
|
69
|
+
Logger.exception e
|
70
|
+
end
|
66
71
|
end
|
67
72
|
|
68
73
|
DnsWrapper.get.rules << RubyDNS::RuleBasedServer::Rule.new( [ Regexp.new(exp), Resolv::DNS::Resource::IN::A ], block )
|
@@ -39,6 +39,8 @@ class CoreOptions
|
|
39
39
|
attr_accessor :packet_throttle
|
40
40
|
# If true, bettercap will check for updates then exit.
|
41
41
|
attr_accessor :check_updates
|
42
|
+
# If not nil, the interface MAC address will be changed to this value.
|
43
|
+
attr_accessor :use_mac
|
42
44
|
|
43
45
|
def initialize( iface )
|
44
46
|
@iface = iface
|
@@ -53,6 +55,7 @@ class CoreOptions
|
|
53
55
|
@no_target_nbns = false
|
54
56
|
@packet_throttle = 0.0
|
55
57
|
@check_updates = false
|
58
|
+
@use_mac = nil
|
56
59
|
end
|
57
60
|
|
58
61
|
def parse!( ctx, opts )
|
@@ -64,6 +67,15 @@ class CoreOptions
|
|
64
67
|
@iface = v
|
65
68
|
end
|
66
69
|
|
70
|
+
opts.on( '--use-mac ADDRESS', 'Change the interface MAC address to this value before performing the attack.' ) do |v|
|
71
|
+
@use_mac = v
|
72
|
+
raise BetterCap::Error, "Invalid MAC address specified." unless Network::Validator.is_mac?(@use_mac)
|
73
|
+
end
|
74
|
+
|
75
|
+
opts.on( '--random-mac', 'Change the interface MAC address to a random one before performing the attack.' ) do |v|
|
76
|
+
@use_mac = [format('%0.2x', rand(256) & ~1), (1..5).map { format('%0.2x', rand(256)) }].join(':')
|
77
|
+
end
|
78
|
+
|
67
79
|
opts.on( '-G', '--gateway ADDRESS', 'Manually specify the gateway address, if not specified the current gateway will be retrieved and used. ' ) do |v|
|
68
80
|
@gateway = v
|
69
81
|
raise BetterCap::Error, "The specified gateway '#{v}' is not a valid IPv4 address." unless Network::Validator.is_ip?(v)
|
@@ -56,9 +56,13 @@ class Streamer
|
|
56
56
|
|
57
57
|
if r.nil?
|
58
58
|
# call modules on_pre_request
|
59
|
-
process( request )
|
60
|
-
|
61
|
-
|
59
|
+
r = process( request )
|
60
|
+
if r.nil?
|
61
|
+
self.send( "do_#{request.method}", request, response )
|
62
|
+
else
|
63
|
+
Logger.info "[#{'PROXY'.green}] Module returned crafted response."
|
64
|
+
response = r
|
65
|
+
end
|
62
66
|
else
|
63
67
|
response = r
|
64
68
|
end
|
@@ -107,7 +111,10 @@ class Streamer
|
|
107
111
|
|
108
112
|
begin
|
109
113
|
if response.nil?
|
110
|
-
mod.on_pre_request request
|
114
|
+
r = mod.on_pre_request request
|
115
|
+
# the handler returned a response, do not execute
|
116
|
+
# the request
|
117
|
+
response = r unless r.nil?
|
111
118
|
else
|
112
119
|
mod.on_request request, response
|
113
120
|
end
|
@@ -119,6 +126,7 @@ class Streamer
|
|
119
126
|
end
|
120
127
|
end
|
121
128
|
end
|
129
|
+
return response
|
122
130
|
end
|
123
131
|
|
124
132
|
# List of security headers to remove/patch from any response.
|
data/lib/bettercap/version.rb
CHANGED
@@ -12,7 +12,7 @@ This project is released under the GPL 3 license.
|
|
12
12
|
=end
|
13
13
|
module BetterCap
|
14
14
|
# Current version of bettercap.
|
15
|
-
VERSION = '1.5.
|
15
|
+
VERSION = '1.5.5'
|
16
16
|
# Program banner.
|
17
17
|
BANNER = File.read( File.dirname(__FILE__) + '/banner' ).gsub( '#VERSION#', "v#{VERSION}")
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bettercap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Margaritelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|