bettercap 1.5.5 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebf307012a9f7a95c84810c21db31d0ca657575f
4
- data.tar.gz: 7aa29333600b9ad15821f2f4ad760dbee5dfcd76
3
+ metadata.gz: 1ee074bcf0415b99ad835ac61a8a72e94237ac34
4
+ data.tar.gz: c600e478177e4019e6745e7951c24ec0dc9b4778
5
5
  SHA512:
6
- metadata.gz: 65328453bb055e8ddcea4073eac6b0c5c51b3d1a26c8fcab29f5d0a6be517516af1f5d9f7b21aad2877051dd37d3556e8bb457c781c82ab84e34060508995238
7
- data.tar.gz: cff87a74985588e872ac886f5bf9e042bf507cbe911208f56f096eb786cf4783c673d352b8d8d9ddbe3777194dbefe263615171de86c9ab55cba0c8be844bdf5
6
+ metadata.gz: bc7511b21557af365f5a3df0d9c6711387035fbc9964804791bd18b22f65ea33455c88d197c9fd8ad20592a30aada450f3f61dfa680458bfa85f6a852dada595
7
+ data.tar.gz: a314b465b7c55533559679e43eb4ce6ab5a20387001434e3e7c1a7909df55a2fd76cde2242c150902fe4b35488eb2108979fb8e3506b091c548ee3bde509cb29
data/README.md CHANGED
@@ -86,6 +86,14 @@ This should solve issues such as [this one](https://github.com/evilsocket/better
86
86
  gem build bettercap.gemspec
87
87
  sudo gem install bettercap*.gem
88
88
 
89
+ **Installation on Kali Linux**
90
+
91
+ Kali Linux has bettercap packaged and added to the **kali-rolling** repositories. To install bettercap and all dependencies in one fell swoop on the latest version of Kali Linux:
92
+
93
+ apt-get update
94
+ apt-get dist-upgrade
95
+ apt-get install bettercap
96
+
89
97
  Documentation and Examples
90
98
  ============
91
99
 
@@ -38,9 +38,8 @@ class BSD < Base
38
38
  # If +enabled+ is true, the PF firewall will be enabled, otherwise it will
39
39
  # be disabled.
40
40
  def enable(enabled)
41
- begin
42
- Shell.execute("pfctl -#{enabled ? 'e' : 'd'} >/dev/null 2>&1")
43
- rescue; end
41
+ Shell.execute("pfctl -#{enabled ? 'e' : 'd'} >/dev/null 2>&1")
42
+ rescue
44
43
  end
45
44
 
46
45
  # Apply the +r+ BetterCap::Firewalls::Redirection port redirection object.
@@ -66,12 +65,9 @@ class BSD < Base
66
65
  # disable pf
67
66
  enable false
68
67
 
69
- begin
70
- # remove the pf config file
71
- File.delete( "/tmp/bettercap_pf_#{Process.pid}.conf" )
72
- rescue
73
- end
74
-
68
+ # remove the pf config file
69
+ File.delete( "/tmp/bettercap_pf_#{Process.pid}.conf" )
70
+ rescue
75
71
  end
76
72
  end
77
73
  end
@@ -91,7 +91,12 @@ module Logger
91
91
  loop do
92
92
  message = @@queue.pop
93
93
  if @@ctx.nil? or @@ctx.running
94
- emit message
94
+ begin
95
+ emit message
96
+ rescue Exception => e
97
+ Logger.warn "Logger error: #{e.message}"
98
+ Logger.exception e
99
+ end
95
100
  end
96
101
  end
97
102
  end
@@ -16,8 +16,8 @@ module Celluloid
16
16
  class Actor
17
17
  # Handle any exceptions that occur within a running actor
18
18
  def handle_crash(exception)
19
- shutdown ExitEvent.new(behavior_proxy, exception)
20
- rescue => ex
19
+ shutdown ExitEvent.new(behavior_proxy, exception)
20
+ rescue
21
21
  end
22
22
  end
23
23
  end
@@ -16,12 +16,10 @@ module Celluloid
16
16
  module IO
17
17
  class UDPSocket
18
18
  def initialize(address_family = ::Socket::AF_INET)
19
- begin
20
- @socket = ::UDPSocket.new(address_family)
21
- rescue Errno::EMFILE
22
- sleep 0.5
23
- retry
24
- end
19
+ @socket = ::UDPSocket.new(address_family)
20
+ rescue Errno::EMFILE
21
+ sleep 0.5
22
+ retry
25
23
  end
26
24
  end
27
25
  end
@@ -49,13 +49,12 @@ class PacketQueue
49
49
 
50
50
  # Wait for the packet queue to be empty.
51
51
  def wait_empty( timeout )
52
- begin
53
- Timeout::timeout(timeout) {
54
- while !@queue.empty?
55
- sleep 0.5
56
- end
57
- }
58
- rescue; end
52
+ Timeout::timeout(timeout) {
53
+ while !@queue.empty?
54
+ sleep 0.5
55
+ end
56
+ }
57
+ rescue
59
58
  end
60
59
 
61
60
  # Notify the queue to stop and wait for every worker to finish.
@@ -19,6 +19,7 @@ class Base
19
19
  TYPES = [
20
20
  :uint8,
21
21
  :uint16,
22
+ :uint16rev,
22
23
  :uint24,
23
24
  :uint32,
24
25
  :uint32rev,
@@ -64,6 +65,10 @@ class Base
64
65
  value = data[offset..offset + 1].unpack('S')[0]
65
66
  offset += 2
66
67
 
68
+ when :uint16rev
69
+ value = data[offset..offset + 1].reverse.unpack('S')[0]
70
+ offset += 2
71
+
67
72
  when :uint24
68
73
  value = data[offset..offset + 2].unpack('S')[0]
69
74
  offset += 3
@@ -132,28 +137,15 @@ class Base
132
137
  end
133
138
 
134
139
  def self.size( info, pkt, default )
135
- if info[:opts].has_key?(:size)
136
- if info[:opts][:size].is_a?(Integer)
137
- return info[:opts][:size]
138
- else
139
- n = pkt.send( info[:opts][:size] )
140
- return n
141
- end
142
- else
143
- return default
144
- end
140
+ return default unless info[:opts].has_key?(:size)
141
+ return info[:opts][:size] if info[:opts][:size].is_a?(Integer)
142
+ return pkt.send( info[:opts][:size] )
145
143
  end
146
144
 
147
145
  def self.offset( info, pkt, default )
148
- if info[:opts].has_key?(:offset)
149
- if info[:opts][:offset].is_a?(Integer)
150
- return info[:opts][:offset]
151
- else
152
- return default + pkt.send( info[:opts][:offset] )
153
- end
154
- else
155
- return default
156
- end
146
+ return default unless info[:opts].has_key?(:offset)
147
+ return info[:opts][:offset] if info[:opts][:offset].is_a?(Integer)
148
+ return default + pkt.send( info[:opts][:offset] )
157
149
  end
158
150
  end
159
151
 
@@ -0,0 +1,119 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+
4
+ BETTERCAP
5
+
6
+ Author : Simone 'evilsocket' Margaritelli
7
+ Email : evilsocket@gmail.com
8
+ Blog : http://www.evilsocket.net/
9
+
10
+ This project is released under the GPL 3 license.
11
+
12
+ =end
13
+
14
+ module BetterCap
15
+ module Network
16
+ module Protos
17
+ module TeamViewer
18
+
19
+ COMMANDS = {
20
+ 10 => "CMD_IDENTIFY",
21
+ 11 => "CMD_REQUESTCONNECT",
22
+ 13 => "CMD_DISCONNECT",
23
+ 14 => "CMD_VNCDISCONNECT",
24
+ 15 => "CMD_TVCONNECTIONFAILED",
25
+ 16 => "CMD_PING",
26
+ 17 => "CMD_PINGOK",
27
+ 18 => "CMD_MASTERCOMMAND",
28
+ 19 => "CMD_MASTERRESPONSE",
29
+ 20 => "CMD_CHANGECONNECTION",
30
+ 21 => "CMD_NOPARTNERCONNECT",
31
+ 22 => "CMD_CONNECTTOWAITINGTHREAD",
32
+ 23 => "CMD_SESSIONMODE",
33
+ 24 => "CMD_REQUESTROUTINGSESSION",
34
+ 25 => "CMD_TIMEOUT",
35
+ 26 => "CMD_JAVACONNECT",
36
+ 27 => "CMD_KEEPALIVEBEEP",
37
+ 28 => "CMD_REQUESTKEEPALIVE",
38
+ 29 => "CMD_MASTERCOMMAND_ENCRYPTED",
39
+ 30 => "CMD_MASTERRESPONSE_ENCRYPTED",
40
+ 31 => "CMD_REQUESTRECONNECT",
41
+ 32 => "CMD_RECONNECTTOWAITINGTHREAD",
42
+ 33 => "CMD_STARTLOGGING",
43
+ 34 => "CMD_SERVERAVAILABLE",
44
+ 35 => "CMD_KEEPALIVEREQUEST",
45
+ 36 => "CMD_OK",
46
+ 37 => "CMD_FAILED",
47
+ 38 => "CMD_PING_PERFORMANCE",
48
+ 39 => "CMD_PING_PERFORMANCE_RESPONSE",
49
+ 40 => "CMD_REQUESTKEEPALIVE2",
50
+ 41 => "CMD_DISCONNECT_SWITCHEDTOUDP",
51
+ 42 => "CMD_SENDMODE_UDP",
52
+ 43 => "CMD_KEEPALIVEREQUEST_ANSWER",
53
+ 44 => "CMD_ROUTE_CMD_TO_CLIENT",
54
+ 45 => "CMD_NEW_MASTERLOGIN",
55
+ 46 => "CMD_BUDDY",
56
+ 47 => "CMD_ACCEPTROUTINGSESSION",
57
+ 48 => "CMD_NEW_MASTERLOGIN_ANSWER",
58
+ 49 => "CMD_BUDDY_ENCRYPTED",
59
+ 50 => "CMD_REQUEST_ROUTE_BUDDY",
60
+ 51 => "CMD_CONTACT_OTHER_MASTER",
61
+ 52 => "CMD_REQUEST_ROUTE_ENCRYPTED",
62
+ 53 => "CMD_ENDSESSION",
63
+ 54 => "CMD_SESSIONID",
64
+ 55 => "CMD_RECONNECT_TO_SESSION",
65
+ 56 => "CMD_RECONNECT_TO_SESSION_ANSWER",
66
+ 57 => "CMD_MEETING_CONTROL",
67
+ 58 => "CMD_CARRIER_SWITCH",
68
+ 59 => "CMD_MEETING_AUTHENTICATION",
69
+ 60 => "CMD_ROUTERCMD",
70
+ 61 => "CMD_PARTNERRECONNECT",
71
+ 62 => "CMD_CONGRESTION_CONTROL",
72
+ 63 => "CMD_ACK",
73
+ 70 => "CMD_UDPREQUESTCONNECT",
74
+ 71 => "CMD_UDPPING",
75
+ 72 => "CMD_UDPREQUESTCONNECT_VPN",
76
+ 90 => "CMD_DATA",
77
+ 91 => "CMD_DATA2",
78
+ 92 => "CMD_DATA_ENCRYPTED",
79
+ 93 => "CMD_REQUESTENCRYPTION",
80
+ 94 => "CMD_CONFIRMENCRYPTION",
81
+ 95 => "CMD_ENCRYPTIONREQUESTFAILED",
82
+ 96 => "CMD_REQUESTNOENCRYPTION",
83
+ 97 => "CMD_UDPFLOWCONTROL",
84
+ 98 => "CMD_DATA3",
85
+ 99 => "CMD_DATA3_ENCRYPTED",
86
+ 100 => "CMD_DATA3_RESENDPACKETS",
87
+ 101 => "CMD_DATA3_ACKPACKETS",
88
+ 102 => "CMD_AUTH_CHALLENGE",
89
+ 103 => "CMD_AUTH_RESPONSE",
90
+ 104 => "CMD_AUTH_RESULT",
91
+ 105 => "CMD_RIP_MESSAGES",
92
+ 106 => "CMD_DATA4",
93
+ 107 => "CMD_DATASTREAM",
94
+ 108 => "CMD_UDPHEARTBEAT",
95
+ 109 => "CMD_DATA_DIRECTED",
96
+ 110 => "CMD_UDP_RESENDPACKETS",
97
+ 111 => "CMD_UDP_ACKPACKETS",
98
+ 112 => "CMD_UDP_PROTECTEDCOMMAND",
99
+ 113 => "CMD_FLUSHSENDBUFFER"
100
+ }
101
+
102
+ class Packet < Network::Protos::Base
103
+ uint16rev :magic
104
+ uint8 :command_code
105
+
106
+ def version
107
+ return '1' if self.magic == 0x1130
108
+ return '2'
109
+ end
110
+
111
+ def command
112
+ return COMMANDS[ self.command_code ]
113
+ end
114
+ end
115
+
116
+ end
117
+ end
118
+ end
119
+ end
@@ -22,16 +22,15 @@ class HTTPD
22
22
  def initialize( port = 8081, path = './' )
23
23
  @port = port
24
24
  @path = path
25
- begin
26
- @server = WEBrick::HTTPServer.new(
27
- Port: @port,
28
- DocumentRoot: @path,
29
- Logger: WEBrick::Log.new("/dev/null"),
30
- AccessLog: []
31
- )
32
- rescue Errno::EADDRINUSE
33
- raise BetterCap::Error, "[HTTPD] It looks like there's another process listening on port #{@port}, please chose a different port."
34
- end
25
+ @server = WEBrick::HTTPServer.new(
26
+ Port: @port,
27
+ DocumentRoot: @path,
28
+ Logger: WEBrick::Log.new("/dev/null"),
29
+ AccessLog: []
30
+ )
31
+ rescue Errno::EADDRINUSE
32
+ raise BetterCap::Error, "[HTTPD] It looks like there's another process listening on port #{@port}, "\
33
+ "please chose a different port."
35
34
  end
36
35
 
37
36
  # Start the server.
@@ -97,26 +97,21 @@ class Target
97
97
 
98
98
  # Return a compact string representation of this object.
99
99
  def to_s_compact
100
- if @name
101
- "#{@name}/#{@ip}"
102
- else
103
- @ip
104
- end
100
+ return "#{@name}/#{@ip}" if @name
101
+ @ip
105
102
  end
106
103
 
107
104
  # Return true if this +Target+ is equal to the specified +ip+ and +mac+,
108
105
  # otherwise return false.
109
- def equals?(ip, mac)
110
- # compare by ip
111
- if mac.nil?
112
- return ( @ip == ip )
113
- # compare by mac
114
- elsif !@mac.nil? and ( @mac == mac )
115
- Logger.info "Found IP #{ip} for target #{@mac}!" if @ip.nil?
116
- @ip = ip
117
- return true
118
- end
119
- false
106
+ def equals?(ip, mac = nil)
107
+ # compare by ip if no mac
108
+ return ( @ip == ip ) if mac.nil?
109
+ # false if no mac or if it's different
110
+ return false if @mac.nil? || ( @mac != mac )
111
+
112
+ Logger.info "Found IP #{ip} for target #{@mac}!" if @ip.nil?
113
+ @ip = ip
114
+ return true
120
115
  end
121
116
 
122
117
  def self.normalized_mac(v)
@@ -67,10 +67,12 @@ class InjectCSS < BetterCap::Proxy::HTTP::Module
67
67
  BetterCap::Logger.info "[#{'INJECTCSS'.green}] Injecting CSS #{@@cssdata.nil?? "URL" : "file"} into #{request.to_url}"
68
68
  # inject URL
69
69
  if @@cssdata.nil?
70
- response.body.sub!( '</head>', " <link rel=\"stylesheet\" href=\"#{@cssurl}\"></script></head>" )
70
+ replacement = " <link rel=\"stylesheet\" href=\"#{@cssurl}\"></script></head> "
71
+ response.body.sub!( '</head>' ) {replacement}
71
72
  # inject data
72
73
  else
73
- response.body.sub!( '</head>', "#{@@cssdata}</head>" )
74
+ replacement = "#{@@cssdata}</head> "
75
+ response.body.sub!( '</head>' ) {replacement}
74
76
  end
75
77
  end
76
78
  end
@@ -55,9 +55,11 @@ class InjectHTML < BetterCap::Proxy::HTTP::Module
55
55
  BetterCap::Logger.info "[#{'INJECTHTML'.green}] Injecting HTML code into #{request.to_url}"
56
56
 
57
57
  if @@data.nil?
58
- response.body.sub!( '</body>', "<iframe src=\"#{@@iframe}\" frameborder=\"0\" height=\"0\" width=\"0\"></iframe></body>" )
58
+ replacement = "<iframe src=\"#{@@iframe}\" frameborder=\"0\" height=\"0\" width=\"0\"></iframe></body>"
59
+ response.body.sub!( '</body>' ) {replacement}
59
60
  else
60
- response.body.sub!( '</body>', "#{@@data}</body>" )
61
+ replacement = "#{@@data}</body>"
62
+ response.body.sub!( '</body>' ) {replacement}
61
63
  end
62
64
  end
63
65
  end
@@ -67,10 +67,12 @@ class InjectJS < BetterCap::Proxy::HTTP::Module
67
67
  BetterCap::Logger.info "[#{'INJECTJS'.green}] Injecting javascript #{@@jsdata.nil?? "URL" : "file"} into #{request.to_url}"
68
68
  # inject URL
69
69
  if @@jsdata.nil?
70
- response.body.sub!( '</head>', "<script src=\"#{@@jsurl}\" type=\"text/javascript\"></script></head>" )
70
+ replacement = "<script src=\"#{@@jsurl}\" type=\"text/javascript\"></script></head>"
71
+ response.body.sub!( '</head>' ) {replacement}
71
72
  # inject data
72
73
  else
73
- response.body.sub!( '</head>', "#{@@jsdata}</head>" )
74
+ replacement = "#{@@jsdata}<p></p></head>"
75
+ response.body.sub!( '</head>') {replacement}
74
76
  end
75
77
  end
76
78
  end
@@ -29,6 +29,10 @@ class Fetcher < Net::HTTP
29
29
  def self.fetch( hostname, port )
30
30
  http = self.new( hostname, port )
31
31
  http.use_ssl = true
32
+ http.ssl_timeout =
33
+ http.open_timeout =
34
+ http.read_timeout = 10
35
+
32
36
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
33
37
 
34
38
  http.head("/")
@@ -166,10 +166,11 @@ class Streamer
166
166
  # Use a Net::HTTP object in order to perform the +req+ BetterCap::Proxy::HTTP::Request
167
167
  # object, will return a BetterCap::Proxy::HTTP::Response object instance.
168
168
  def perform_proxy_request(req, res)
169
- path = req.path
170
- response = nil
171
- http = Net::HTTP.new( req.host, req.port )
172
- http.use_ssl = ( req.port == 443 )
169
+ path = req.path
170
+ response = nil
171
+ http = Net::HTTP.new( req.host, req.port )
172
+ http.use_ssl = ( req.port == 443 )
173
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
173
174
 
174
175
  http.start do
175
176
  response = yield( http, path, req.headers )
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+
4
+ BETTERCAP
5
+
6
+ Author : Simone 'evilsocket' Margaritelli
7
+ Email : evilsocket@gmail.com
8
+ Blog : http://www.evilsocket.net/
9
+
10
+ This project is released under the GPL 3 license.
11
+
12
+ =end
13
+
14
+ module BetterCap
15
+ module Parsers
16
+ # MySQL authentication parser.
17
+ class TeamViewer < Base
18
+ def on_packet( pkt )
19
+ begin
20
+ if pkt.tcp_dst == 5938 or pkt.tcp_src == 5938
21
+ packet = Network::Protos::TeamViewer::Packet.parse( pkt.payload )
22
+ unless packet.nil?
23
+ StreamLogger.log_raw( pkt, 'TEAMVIEWER', "#{'version'.blue}=#{packet.version.yellow} #{'command'.blue}=#{packet.command.yellow}" )
24
+ end
25
+ end
26
+ rescue; end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -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.5'
15
+ VERSION = '1.5.6'
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.5
4
+ version: 1.5.6
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-05-25 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.7'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.7.5
19
+ version: 0.8.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.7'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.7.5
26
+ version: 0.8.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: packetfu
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +188,7 @@ files:
194
188
  - lib/bettercap/network/protos/mysql.rb
195
189
  - lib/bettercap/network/protos/ntlm.rb
196
190
  - lib/bettercap/network/protos/snmp.rb
191
+ - lib/bettercap/network/protos/teamviewer.rb
197
192
  - lib/bettercap/network/servers/dnsd.rb
198
193
  - lib/bettercap/network/servers/httpd.rb
199
194
  - lib/bettercap/network/services
@@ -246,6 +241,7 @@ files:
246
241
  - lib/bettercap/sniffer/parsers/rlogin.rb
247
242
  - lib/bettercap/sniffer/parsers/snmp.rb
248
243
  - lib/bettercap/sniffer/parsers/snpp.rb
244
+ - lib/bettercap/sniffer/parsers/teamviewer.rb
249
245
  - lib/bettercap/sniffer/parsers/url.rb
250
246
  - lib/bettercap/sniffer/parsers/whatsapp.rb
251
247
  - lib/bettercap/sniffer/sniffer.rb