proxyplugins.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:mitmfnz 作者: dropnz 项目源码 文件源码
def hook(self):
        '''Magic to hook various function calls in sslstrip'''
        #gets the function name and args of our caller
        frame = sys._getframe(1)
        fname = frame.f_code.co_name
        keys,_,_,values = inspect.getargvalues(frame)

        #assumes that no one calls del on an arg :-/
        args = {}
        for key in keys:
            args[key] = values[key]

        #prevent self conflict
        if (fname == "handleResponse") or (fname == "handleHeader") or (fname == "handleEndHeaders"):
            args['request']  = args['self']
            args['response'] = args['self'].client
        else:
            args['request'] = args['self']

        del args['self']

        log.debug("hooking {}()".format(fname))
        #calls any plugin that has this hook
        try:
            if self.plugin_mthds:
                for f in self.plugin_mthds[fname]:
                    a = f(**args)
                    if a != None: args = a
        except Exception as e:
            #This is needed because errors in hooked functions won't raise an Exception + Traceback (which can be infuriating)
            log.error("Exception occurred in hooked function")
            traceback.print_exc()

        #pass our changes to the locals back down
        return args
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号