bettercap.rb 1.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env ruby
# encoding: UTF-8

=begin

  BETTERCAP

  Author : Simone 'evilsocket' Margaritelli
  Email  : evilsocket@gmail.com
  Blog   : http://www.evilsocket.net/

  This project is released under the GPL 3 license.

=end

# they hate us 'cause they ain't us
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

Sophie Brun's avatar
Sophie Brun committed
20 21 22 23
require 'packetfu'
require 'em-proxy'
require 'webrick'
require 'rubydns'
24 25 26 27 28 29 30 31 32
require 'colorize'
require 'json'
require 'net/dns'
require 'net/http'
require 'optparse'

Object.send :remove_const, :Config rescue nil
Config = RbConfig

Sophie Brun's avatar
Sophie Brun committed
33
def bettercap_autoload(path = '')
34 35 36 37 38
  dir    = File.dirname(__FILE__) + "/bettercap/#{path}"
  deps   = []
  files  = []
  monkey = []

Sophie Brun's avatar
Sophie Brun committed
39 40
  Dir[dir + '**/*.rb'].each do |filename|
    filename = filename.gsub(dir, '').gsub('.rb', '')
41
    filename = "bettercap/#{path}#{filename}"
Sophie Brun's avatar
Sophie Brun committed
42 43

    next if filename.include?('proxy/http/modules')
44
    # Proxy modules must be loaded at runtime.
Sophie Brun's avatar
Sophie Brun committed
45 46 47 48 49 50
    if filename.end_with?('/base') || filename.include?('pluggable')
      deps << filename
    elsif filename.include?('monkey')
      monkey << filename
    else
      files << filename
51 52 53
    end
  end

Sophie Brun's avatar
Sophie Brun committed
54
  (deps + files + monkey).each do |file|
55 56 57 58 59
    require file
  end
end

bettercap_autoload