Beispiel #1
0
def mitmdumpex(args=None):
    from . import dumpex
    parser = cmdline.mitmdumpex()

    options = parser.parse_args(args)
    if options.quiet:
        options.verbose = 0
        options.flow_detail = 0

    proxy_config = process_proxy_options(parser, options)
    dump_options = dumpex.Options(**cmdline.get_common_options(options))
    dump_options.flow_detail = options.flow_detail
    dump_options.keepserving = options.keepserving
    dump_options.filtstr = " ".join(options.args) if options.args else None

    dump_options.rotate_logs = options.rotate_logs

    server = main.get_server(dump_options.no_server, proxy_config)

    try:
        master = dumpex.DumpExMaster(server, dump_options)

        def cleankill(*args, **kwargs):
            master.shutdown()

        signal.signal(signal.SIGTERM, cleankill)
        master.run()
    except dumpex.DumpError as e:
        print("mitmdump: %s" % e, file=sys.stderr)
        sys.exit(1)
    except KeyboardInterrupt:
        pass
Beispiel #2
0
def mitmdumpex(args=None):
    from . import dumpex
    parser = cmdline.mitmdumpex()

    options = parser.parse_args(args)
    if options.quiet:
        options.verbose = 0
        options.flow_detail = 0

    proxy_config = process_proxy_options(parser, options)
    dump_options = dumpex.Options(**cmdline.get_common_options(options))
    dump_options.flow_detail = options.flow_detail
    dump_options.keepserving = options.keepserving
    dump_options.filtstr = " ".join(options.args) if options.args else None

    dump_options.rotate_logs = options.rotate_logs

    server = main.get_server(dump_options.no_server, proxy_config)

    try:
        master = dumpex.DumpExMaster(server, dump_options)

        def cleankill(*args, **kwargs):
            master.shutdown()

        signal.signal(signal.SIGTERM, cleankill)
        master.run()
    except dumpex.DumpError as e:
        print("mitmdump: %s" % e, file=sys.stderr)
        sys.exit(1)
    except KeyboardInterrupt:
        pass
Beispiel #3
0
def main():
    
    
    #config stuff
    if(len(sys.argv) == 2):
        if(os.path.isfile(sys.argv[1])):
            sys.argv[1] = "@" + sys.argv[1]
            os.chdir(os.path.split(inspect.getfile( inspect.currentframe() ))[0])
            
    defaultConfig = (len(sys.argv) == 1)
    if defaultConfig and os.path.exists('default.conf'):
        sys.argv.insert(1,'@default.conf')
    parser = ArgumentParser(
                            usage = "%(prog)s [options]",
                            fromfile_prefix_chars="@"
                            )
    ArgumentParser.convert_arg_line_to_args = hcmdline.convert_arg_line_to_args
    parser.add_argument('--version', action='version', version=version.NAMEVERSION)
    mcmdline.common_options(parser)
    hcmdline.fix_options(parser) #remove some mitmproxy stuff

    options = parser.parse_args()
    
    dumpoptions = dump.Options(dumpdir=options.dumpdir,**mcmdline.get_common_options(options))
    
    #set up proxy server
    proxyconfig = mproxy.process_proxy_options(parser, options)
    
    if options.no_server:
        server = mproxy.DummyServer(proxyconfig)
    else:
        try:
            server = mproxy.ProxyServer(proxyconfig, options.port, options.addr)
        except mproxy.ProxyServerError, v:
            print >> sys.stderr, "%(name)s: %(args)s" % {"name": version.NAME, "args": v.args[0]}
            sys.exit(1)
Beispiel #4
0
def main():
    
    
    #config stuff
    if(len(sys.argv) == 2):
        if(os.path.isfile(sys.argv[1])):
            sys.argv[1] = "@" + sys.argv[1]
            os.chdir(os.path.split(inspect.getfile( inspect.currentframe() ))[0])
            
    defaultConfig = (len(sys.argv) == 1)
    if defaultConfig and os.path.exists('default.conf'):
        sys.argv.insert(1,'@default.conf')
    parser = ArgumentParser(
                            usage = "%(prog)s [options]",
                            fromfile_prefix_chars="@"
                            )
    ArgumentParser.convert_arg_line_to_args = hcmdline.convert_arg_line_to_args
    parser.add_argument('--version', action='version', version=version.NAMEVERSION)
    mcmdline.common_options(parser)
    hcmdline.fix_options(parser) #remove some mitmproxy stuff

    options = parser.parse_args()
    
    dumpoptions = dump.Options(dumpdir=options.dumpdir,**mcmdline.get_common_options(options))
    
    #set up proxy server
    proxyconfig = mproxy.process_proxy_options(parser, options)
    
    if options.no_server:
        server = mproxy.DummyServer(proxyconfig)
    else:
        try:
            server = mproxy.ProxyServer(proxyconfig, options.port, options.addr)
        except mproxy.ProxyServerError, v:
            print >> sys.stderr, "%(name)s: %(args)s" % {"name": version.NAME, "args": v.args[0]}
            sys.exit(1)
Beispiel #5
0
 def p(self, *args):
     parser = argparse.ArgumentParser()
     cmdline.common_options(parser)
     opts = parser.parse_args(args=args)
     m = MockParser()
     return m, proxy.process_proxy_options(m, opts)
Beispiel #6
0
 def p(self, *args):
     parser = argparse.ArgumentParser()
     cmdline.common_options(parser)
     opts = parser.parse_args(args=args)
     m = MockParser()
     return m, proxy.process_proxy_options(m, opts)
Beispiel #7
0
 def p(self, *args):
     parser = tutils.MockParser()
     cmdline.common_options(parser)
     opts = parser.parse_args(args=args)
     return parser, process_proxy_options(parser, opts)
Beispiel #8
0
 def p(self, *args):
     parser = tutils.MockParser()
     cmdline.common_options(parser)
     opts = parser.parse_args(args=args)
     return parser, process_proxy_options(parser, opts)