bettercap 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -34
  3. data/bin/bettercap +1 -1
  4. data/lib/bettercap/context.rb +1 -1
  5. data/lib/bettercap/discovery/agents/mdns.rb +61 -0
  6. data/lib/bettercap/discovery/agents/upnp.rb +60 -0
  7. data/lib/bettercap/discovery/agents/wsd.rb +75 -0
  8. data/lib/bettercap/firewalls/linux.rb +0 -4
  9. data/lib/bettercap/logger.rb +63 -34
  10. data/lib/bettercap/network/network.rb +1 -1
  11. data/lib/bettercap/options/core_options.rb +1 -1
  12. data/lib/bettercap/proxy/http/modules/redirect.rb +1 -1
  13. data/lib/bettercap/proxy/http/proxy.rb +1 -9
  14. data/lib/bettercap/proxy/http/sslstrip/strip.rb +5 -5
  15. data/lib/bettercap/sniffer/parsers/asterisk.rb +37 -0
  16. data/lib/bettercap/sniffer/parsers/bfd.rb +159 -0
  17. data/lib/bettercap/sniffer/parsers/dhcp.rb +23 -23
  18. data/lib/bettercap/sniffer/parsers/dict.rb +13 -11
  19. data/lib/bettercap/sniffer/parsers/hsrp.rb +262 -0
  20. data/lib/bettercap/sniffer/parsers/https.rb +17 -19
  21. data/lib/bettercap/sniffer/parsers/mpd.rb +12 -10
  22. data/lib/bettercap/sniffer/parsers/nntp.rb +5 -1
  23. data/lib/bettercap/sniffer/parsers/post.rb +8 -9
  24. data/lib/bettercap/sniffer/parsers/radius.rb +410 -0
  25. data/lib/bettercap/sniffer/parsers/redis.rb +15 -13
  26. data/lib/bettercap/sniffer/parsers/rlogin.rb +20 -19
  27. data/lib/bettercap/sniffer/parsers/snmp.rb +16 -17
  28. data/lib/bettercap/sniffer/parsers/snpp.rb +13 -11
  29. data/lib/bettercap/sniffer/parsers/teamtalk.rb +41 -0
  30. data/lib/bettercap/sniffer/parsers/teamviewer.rb +8 -8
  31. data/lib/bettercap/sniffer/parsers/url.rb +6 -6
  32. data/lib/bettercap/sniffer/parsers/whatsapp.rb +6 -7
  33. data/lib/bettercap/sniffer/parsers/wol.rb +68 -0
  34. data/lib/bettercap/spoofers/arp.rb +3 -3
  35. data/lib/bettercap/spoofers/hsrp.rb +351 -0
  36. data/lib/bettercap/spoofers/mac.rb +126 -0
  37. data/lib/bettercap/version.rb +1 -1
  38. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 490c8b7f32ca7a9764aba54e0b7a5e8fb6d42f0f
4
- data.tar.gz: d004aed04c55b7244ca61fd9a1c0dbbdd86d9042
3
+ metadata.gz: b7b14d5a93e46311f7abcb2a9bb1ae008ead71ea
4
+ data.tar.gz: c9a0bc4f745b7b37d8d5313048a554a6d24c0895
5
5
  SHA512:
6
- metadata.gz: 341644a5eb60a927046fd9c8300bbff5be5df6bacc8f4a381fa4d48624a52f712be07532869e73f63b4ecdbad207dbee8a30229236fbffd2c9edc733ceaeb809
7
- data.tar.gz: 736d8de6d05140d0252c8abad7eb5e59fc69c84f8a2a4ff59b12e9d7e72f37eaeab0bf2e55dd77d74873c8d18c5d06a75a1bffa420c24dc75b6e9fbecfbc201f
6
+ metadata.gz: 3b64319b9bc5243c6976e341a3d8f62867224c8c3dd0a85511c76133e3798660d19c10e8285ebb0c966fe4f3468328e766ba4a9f42310550b939ca2056f524d8
7
+ data.tar.gz: 925bb24ab784ee2e4ce4644eab36d658a48b313b825a3aa7f7262503f5e20d6ca9c0e3beac1c7a3ec69bbbea317be7849b73fcf3928e2918c969f8de4f98c9ae
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  **bettercap** is a complete, modular, portable and easily extensible **MITM** tool and framework with every kind of diagnostic
2
2
  and offensive feature you could need in order to perform a man in the middle attack.
3
3
 
4
- Before submitting issues, please read the relevant [section](https://www.bettercap.org/docs/contribute/) in the documentation.
5
-
6
4
  <table>
7
5
  <tr>
8
6
  <th>Version</th>
@@ -17,16 +15,9 @@ Before submitting issues, please read the relevant [section](https://www.betterc
17
15
  <td><a href="https://www.bettercap.org/">https://www.bettercap.org/</a></td>
18
16
  </tr>
19
17
  <tr>
20
- <th>Blog</th>
21
- <td><a href="https://www.bettercap.org/blog/">https://www.bettercap.org/blog/</a></td>
22
- <tr>
23
- <th>Github</th>
18
+ <th>GitHub</th>
24
19
  <td><a href="https://github.com/evilsocket/bettercap">https://github.com/evilsocket/bettercap</a></td>
25
20
  <tr/>
26
- <tr>
27
- <th>Documentation</th>
28
- <td><a href="https://www.bettercap.org/docs/">https://www.bettercap.org/docs/</a></td>
29
- </tr>
30
21
  <tr>
31
22
  <th>Code Documentation</th>
32
23
  <td>
@@ -46,16 +37,8 @@ Before submitting issues, please read the relevant [section](https://www.betterc
46
37
  <td><a href="https://twitter.com/bettercap">@bettercap</a></td>
47
38
  </tr>
48
39
  <tr>
49
- <th>Chat</th>
50
- <td>
51
- <a href="https://gitter.im/evilsocket/bettercap" target="_blank">
52
- <img src="https://badges.gitter.im/evilsocket/bettercap.svg"/>
53
- </a>
54
- </td>
55
- </tr>
56
- <tr>
57
- <th>Copyright</th>
58
- <td>2015-2016 Simone Margaritelli</td>
40
+ <th>Copyleft</th>
41
+ <td>Simone Margaritelli</td>
59
42
  </tr>
60
43
  <tr>
61
44
  <th>License</th>
@@ -68,33 +51,49 @@ Installation
68
51
 
69
52
  **Dependencies**
70
53
 
71
- All dependencies will be automatically installed through the GEM system but in some case you might need to install some system
72
- dependency in order to make everything work:
54
+ All dependencies will be automatically installed through the RubyGems system but in some cases you might need to install some system
55
+ dependency in order to make everything work.
56
+
57
+ **On OSX** (install brew and xcode tools first):
58
+
59
+ ```shell
60
+ brew install libpcap
61
+ ```
62
+
63
+ **On Linux**:
73
64
 
74
- sudo apt-get install build-essential ruby-dev libpcap-dev
65
+ ```shell
66
+ sudo apt-get install build-essential ruby-dev libpcap-dev net-tools
67
+ ```
75
68
 
76
69
  This should solve issues such as [this one](https://github.com/evilsocket/bettercap/issues/22) or [this one](https://github.com/evilsocket/bettercap/issues/100).
77
70
 
78
- **Stable Release ( GEM )**
71
+ **Stable Release (RubyGems)**
79
72
 
80
- gem install bettercap
73
+ ```shell
74
+ gem install bettercap
75
+ ```
81
76
 
82
77
  **From Source**
83
78
 
84
- git clone https://github.com/evilsocket/bettercap
85
- cd bettercap
86
- gem build bettercap.gemspec
87
- sudo gem install bettercap*.gem
79
+ ```shell
80
+ git clone https://github.com/evilsocket/bettercap
81
+ cd bettercap
82
+ gem build bettercap.gemspec
83
+ sudo gem install bettercap*.gem
84
+ ```
88
85
 
89
86
  **Installation on Kali Linux**
90
87
 
91
88
  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
89
+
90
+ ```shell
91
+ apt-get update
92
+ apt-get dist-upgrade
93
+ apt-get install bettercap
94
+ ```
96
95
 
97
96
  Documentation and Examples
98
97
  ============
99
98
 
100
- Please refer to the [official website](https://www.bettercap.org/docs/).
99
+ Please refer to the [official website](https://www.bettercap.org/).
@@ -7,7 +7,7 @@
7
7
 
8
8
  Author : Simone 'evilsocket' Margaritelli
9
9
  Email : evilsocket@gmail.com
10
- Blog : http://www.evilsocket.net/
10
+ Blog : https://www.evilsocket.net/
11
11
 
12
12
  This project is released under the GPL 3 license.
13
13
 
@@ -147,7 +147,7 @@ class Context
147
147
  ip = ip.succ
148
148
  end
149
149
  tend = Time.now
150
- Logger.info "[#{'DISCOVERY'.green}] Done in #{(tend - tstart) * 1000.0} ms"
150
+ Logger.info "[#{'DISCOVERY'.green}] Done in #{'%.01f' % ((tend - tstart) * 1000.0)} ms"
151
151
  end
152
152
  end
153
153
 
@@ -0,0 +1,61 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+
4
+ BETTERCAP
5
+
6
+ Author : Simone 'evilsocket' Margaritelli
7
+ Email : evilsocket@gmail.com
8
+ Blog : https://www.evilsocket.net/
9
+
10
+ mDNS DNS-SD broadcast discovery agent:
11
+ Author : Brendan Coles
12
+ Email : bcoles[at]gmail.com
13
+
14
+ This project is released under the GPL 3 license.
15
+
16
+ =end
17
+
18
+ # Send a broadcast mDNS query trying to fill the ARP table.
19
+ module BetterCap
20
+ module Discovery
21
+ module Agents
22
+ # Class responsible for sending mDNS broadcast queries to the network.
23
+ class Mdns
24
+ # Create a thread which will send an mDNS broadcast query
25
+ # in order to populate the ARP cache with active targets.
26
+ # http://www.multicastdns.org/
27
+ # http://www.ietf.org/rfc/rfc6762.txt
28
+ # https://en.wikipedia.org/wiki/Multicast_DNS
29
+ # https://en.wikipedia.org/wiki/Zero-configuration_networking#DNS-SD_with_multicast
30
+ def initialize( ctx, address = nil )
31
+ pkt = PacketFu::UDPPacket.new
32
+
33
+ pkt.eth_saddr = ctx.iface.mac
34
+ pkt.eth_daddr = '01:00:5e:00:00:fb'
35
+ pkt.ip_saddr = ctx.iface.ip
36
+ pkt.ip_daddr = '224.0.0.251'
37
+ pkt.udp_src = (rand((2 ** 16) - 1024) + 1024).to_i
38
+ pkt.udp_dst = 5353
39
+
40
+ query = "\x09_services\x07_dns-sd\x04_udp\x05local"
41
+
42
+ payload = "\x00\x01" # Transaction ID
43
+ payload << "\x00\x00" # Flags
44
+ payload << "\x00\x01" # Number of questions
45
+ payload << "\x00\x00" # Number of answers
46
+ payload << "\x00\x00" # Number of authority resource records
47
+ payload << "\x00\x00" # Number of additional resource records
48
+ payload << query # Query
49
+ payload << "\x00" # Terminator
50
+ payload << "\x00\x0c" # Type (PTR)
51
+ payload << "\x00\x01" # Class
52
+
53
+ pkt.payload = payload
54
+ pkt.recalc
55
+
56
+ ctx.packets.push(pkt)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,60 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+
4
+ BETTERCAP
5
+
6
+ Author : Simone 'evilsocket' Margaritelli
7
+ Email : evilsocket@gmail.com
8
+ Blog : https://www.evilsocket.net/
9
+
10
+ UPnP SSDP broadcast discovery agent:
11
+ Author : Brendan Coles
12
+ Email : bcoles[at]gmail.com
13
+
14
+ This project is released under the GPL 3 license.
15
+
16
+ =end
17
+
18
+ # Send a broadcast UPnP query trying to fill the ARP table.
19
+ module BetterCap
20
+ module Discovery
21
+ module Agents
22
+ # Class responsible for sending UPnP SSDP broadcast queries to the network.
23
+ class Upnp
24
+ # Create a thread which will send a UPnP SSDP M-SEARCH broadcast query
25
+ # in order to populate the ARP cache with active targets.
26
+ # https://tools.ietf.org/html/draft-cai-ssdp-v1-03#section-4
27
+ # https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol
28
+ # https://en.wikipedia.org/wiki/Zero-configuration_networking#SSDP
29
+ def initialize( ctx, address = nil )
30
+ host = '239.255.255.250'
31
+ port = 1900
32
+
33
+ pkt = PacketFu::UDPPacket.new
34
+
35
+ pkt.eth_saddr = ctx.iface.mac
36
+ pkt.eth_daddr = '01:00:5e:7f:ff:fa'
37
+ pkt.ip_saddr = ctx.iface.ip
38
+ pkt.ip_daddr = host
39
+ pkt.udp_src = (rand((2 ** 16) - 1024) + 1024).to_i
40
+ pkt.udp_dst = port
41
+
42
+ query = []
43
+ query << 'M-SEARCH * HTTP/1.1'
44
+ query << "Host: #{host}:#{port}"
45
+ query << 'Man: ssdp:discover'
46
+ query << 'ST: ssdp:all' # Search Target
47
+ query << 'MX: 2' # Delay response (2 seconds)
48
+
49
+ payload = query.join("\r\n").to_s
50
+ payload << "\r\n"
51
+
52
+ pkt.payload = payload
53
+ pkt.recalc
54
+
55
+ ctx.packets.push(pkt)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+
4
+ BETTERCAP
5
+
6
+ Author : Simone 'evilsocket' Margaritelli
7
+ Email : evilsocket@gmail.com
8
+ Blog : https://www.evilsocket.net/
9
+
10
+ WS-Discovery broadcast discovery agent:
11
+ Author : Brendan Coles
12
+ Email : bcoles[at]gmail.com
13
+
14
+ This project is released under the GPL 3 license.
15
+
16
+ =end
17
+
18
+ # Send a broadcast WS-Discovery query trying to fill the ARP table.
19
+ module BetterCap
20
+ module Discovery
21
+ module Agents
22
+ # Class responsible for sending WS-Discovery broadcast queries to the network.
23
+ class Wsd
24
+ # Create a thread which will send a WS-Discovery broadcast query
25
+ # in order to populate the ARP cache with active targets.
26
+
27
+ # References:
28
+ # - https://msdn.microsoft.com/en-us/library/windows/desktop/bb513684(v=vs.85).aspx
29
+ # - http://specs.xmlsoap.org/ws/2005/04/discovery/ws-discovery.pdf
30
+ # - https://en.wikipedia.org/wiki/Web_Services_for_Devices
31
+ # - https://en.wikipedia.org/wiki/WS-Discovery
32
+ # - https://en.wikipedia.org/wiki/Zero-configuration_networking#WS-Discovery
33
+
34
+ def initialize( ctx, address = nil )
35
+ pkt = PacketFu::UDPPacket.new
36
+
37
+ pkt.eth_saddr = ctx.iface.mac
38
+ pkt.eth_daddr = '01:00:5e:7f:ff:fa'
39
+ pkt.ip_saddr = ctx.iface.ip
40
+ pkt.ip_daddr = '239.255.255.250'
41
+ pkt.udp_src = (rand((2 ** 16) - 1024) + 1024).to_i
42
+ pkt.udp_dst = 3702
43
+
44
+ uuid = SecureRandom.uuid
45
+
46
+ payload = '<?xml version="1.0" encoding="utf-8" ?>'
47
+ payload << '<soap:Envelope'
48
+ payload << ' xmlns:soap="http://www.w3.org/2003/05/soap-envelope"'
49
+ payload << ' xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"'
50
+ payload << ' xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery"'
51
+ payload << ' xmlns:wsdp="http://schemas.xmlsoap.org/ws/2006/02/devprof">'
52
+
53
+ payload << '<soap:Header>'
54
+ # WS-Discovery
55
+ payload << '<wsa:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To>'
56
+ # Action (Probe)
57
+ payload << "<wsa:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action>"
58
+ # Message identifier (unique GUID)
59
+ payload << "<wsa:MessageID>urn:uuid:#{uuid}</wsa:MessageID>"
60
+ payload << '</soap:Header>'
61
+
62
+ payload << '<soap:Body>'
63
+ payload << '<wsd:Probe/>' # WS-Discovery type (blank)
64
+ payload << '</soap:Body>'
65
+ payload << '</env:Envelope>'
66
+
67
+ pkt.payload = payload
68
+ pkt.recalc
69
+
70
+ ctx.packets.push(pkt)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -75,8 +75,6 @@ class Linux < Base
75
75
  # Ipv6 uses a different ip + port representation
76
76
  cal_dst_address = "[#{r.dst_address}]"
77
77
  end
78
- # post route
79
- Shell.execute("#{table} -t nat -I POSTROUTING -s 0/0 -j MASQUERADE")
80
78
  # accept all
81
79
  Shell.execute("#{table} -P FORWARD ACCEPT")
82
80
  # add redirection
@@ -92,8 +90,6 @@ class Linux < Base
92
90
  # Ipv6 uses a different ip + port representation
93
91
  cal_dst_address = "[#{r.dst_address}]"
94
92
  end
95
- # remove post route
96
- Shell.execute("#{table} -t nat -D POSTROUTING -s 0/0 -j MASQUERADE")
97
93
  # remove redirection
98
94
  Shell.execute("#{table} -t nat -D PREROUTING -i #{r.interface} -p #{r.protocol} #{r.src_address.nil? ? '' : "-d #{r.src_address}"} --dport #{r.src_port} -j DNAT --to #{cal_dst_address}:#{r.dst_port}")
99
95
  end
@@ -13,6 +13,53 @@ This project is released under the GPL 3 license.
13
13
  module BetterCap
14
14
  # Class responsible for console and file logging.
15
15
  module Logger
16
+ L_RAW = 0
17
+ L_DBG = 1
18
+ L_INF = 2
19
+ L_WRN = 3
20
+ L_ERR = 4
21
+
22
+ class Entry
23
+ def initialize( ts, level, message )
24
+ @timestamp = ts
25
+ @level = level
26
+ @message = message
27
+ end
28
+
29
+ def create
30
+ case @level
31
+ when Logger::L_RAW
32
+ formatted_message( @message, nil )
33
+ when Logger::L_DBG
34
+ formatted_message( @message, 'D' ).light_black
35
+ when Logger::L_INF
36
+ formatted_message( @message, 'I' )
37
+ when Logger::L_WRN
38
+ formatted_message( @message, 'W' ).yellow
39
+ when Logger::L_ERR
40
+ formatted_message( @message, 'E' ).red
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ # Format +message+ for the given +message_type+.
47
+ def formatted_message(message, message_type)
48
+ # raw message?
49
+ if message_type.nil?
50
+ if @timestamp and !message.strip.empty?
51
+ "[#{Time.now}] #{message}"
52
+ else
53
+ message
54
+ end
55
+ elsif @timestamp
56
+ "[#{Time.now}] [#{message_type}] #{message}"
57
+ else
58
+ "[#{message_type}] #{message}"
59
+ end
60
+ end
61
+ end
62
+
16
63
  class << self
17
64
  @@ctx = nil
18
65
  @@queue = Queue.new
@@ -39,48 +86,45 @@ module Logger
39
86
  "Message : #{e.message}\n" +
40
87
  "Backtrace :\n\n #{e.backtrace.join("\n ")}\n"
41
88
 
42
- if BetterCap::VERSION.end_with?('b')
43
- self.warn(msg)
44
- else
45
- self.debug(msg)
46
- end
89
+ self.debug(msg)
47
90
  end
48
91
 
49
92
  # Log an error +message+.
50
93
  def error(message)
51
- @@queue.push formatted_message(message, 'E').red
94
+ @@queue.push Logger::Entry.new( @@timestamp, Logger::L_ERR, message )
52
95
  end
53
96
 
54
97
  # Log an information +message+.
55
98
  def info(message)
56
- @@queue.push( formatted_message(message, 'I') ) unless @@silent
99
+ @@queue.push( Logger::Entry.new( @@timestamp, Logger::L_INF, message ) ) unless @silent
57
100
  end
58
101
 
59
102
  # Log a warning +message+.
60
103
  def warn(message)
61
- @@queue.push formatted_message(message, 'W').yellow
104
+ @@queue.push Logger::Entry.new( @@timestamp, Logger::L_WRN, message )
62
105
  end
63
106
 
64
107
  # Log a debug +message+.
65
108
  def debug(message)
66
109
  if @@debug and not @@silent
67
- @@queue.push formatted_message(message, 'D').light_black
110
+ @@queue.push Logger::Entry.new( @@timestamp, Logger::L_DBG, message )
68
111
  end
69
112
  end
70
113
 
71
114
  # Log a +message+ as it is.
72
115
  def raw(message)
73
- @@queue.push( formatted_message( message, nil ) ) unless @@silent
116
+ @@queue.push( Logger::Entry.new( @@timestamp, Logger::L_RAW, message ) ) unless @silent
74
117
  end
75
118
 
76
119
  # Wait for the messages queue to be empty.
77
120
  def wait!
78
121
  while not @@queue.empty?
79
- if @@thread.nil?
80
- emit @@queue.pop
81
- else
82
- sleep 0.3
122
+ msg = @@queue.pop(true) rescue nil
123
+ if msg
124
+ emit msg.create
83
125
  end
126
+
127
+ sleep(0.3) if msg.nil?
84
128
  end
85
129
  end
86
130
 
@@ -89,15 +133,16 @@ module Logger
89
133
  # Main logger logic.
90
134
  def worker
91
135
  loop do
92
- message = @@queue.pop
93
- if @@ctx.nil? or @@ctx.running
136
+ msg = @@queue.pop(true) rescue nil
137
+ if msg and ( @@ctx.nil? or @@ctx.running )
94
138
  begin
95
- emit message
139
+ emit msg.create
96
140
  rescue Exception => e
97
- Logger.warn "Logger error: #{e.message}"
98
141
  Logger.exception e
99
142
  end
100
143
  end
144
+
145
+ sleep(0.3) if msg.nil?
101
146
  end
102
147
  end
103
148
 
@@ -110,22 +155,6 @@ module Logger
110
155
  f.close
111
156
  end
112
157
  end
113
-
114
- # Format +message+ for the given +message_type+.
115
- def formatted_message(message, message_type)
116
- # raw message?
117
- if message_type.nil?
118
- if @@timestamp and !message.strip.empty?
119
- "[#{Time.now}] #{message}"
120
- else
121
- message
122
- end
123
- elsif @@timestamp
124
- "[#{Time.now}] [#{message_type}] #{message}"
125
- else
126
- "[#{message_type}] #{message}"
127
- end
128
- end
129
158
  end
130
159
  end
131
160
  end