Esempio n. 1
0
 def start(self):
     config = proxy.ProxyConfig(port=8080, mode='transparent')
     print "[*] Pumpkin-Proxy running on port:8080 \n"
     server = ProxyServer(config)
     server.allow_reuse_address = True
     self.m = MasterHandler(server, self.session)
     self.m.run(self.send)
Esempio n. 2
0
def main():
    app = wx.App(False)
    if len(sys.argv) >= 2 and sys.argv[1] == '-test':
        config = wx.Config("padherder_proxy_test")
        print "In test mode"
    else:
        config = wx.Config("padherder_proxy")
    wx.ConfigBase.Set(config)
    frame = MainWindow(None, "Padherder Proxy v%s" % PH_PROXY_VERSION)

    host = config.Read("host") or socket.gethostbyname(socket.gethostname())

    logger = dnsproxy.MyDNSLogger(frame.dns_tab)
    thread.start_new_thread(dnsproxy.serveDNS, (logger, frame.main_tab, frame))

    try:
        app_config = proxy.ProxyConfig(options=moptions.Options(app_port=8080, app_host=host))
        app_server = ProxyServer(app_config)
        app_master = dump.DumpMaster(app_server, dump.Options(app_host='mitm.it', app_port=80, app=True))
        frame.app_master = app_master
        thread.start_new_thread(app_master.run, ())
    except:
        evt = custom_events.wxStatusEvent(message='Error initalizing mitm proxy:\n' + traceback.format_exc() + '\n\nYou probably put in an incorrect IP address in Settings')
        wx.PostEvent(frame.main_tab, evt)

    app.MainLoop()
Esempio n. 3
0
    def onDNSEvent(self, event):
        if self.proxy_master is not None:
            self.proxy_master.shutdown()

        if event.message.startswith('api-na'):
            region = 'NA'
        else:
            region = 'JP'

        config = wx.ConfigBase.Get()
        host = config.Read("host") or socket.gethostbyname(
            socket.gethostname())
        httpsport = config.Read("httpsport") or "443"

        try:
            proxy_config = proxy.ProxyConfig(
                port=int(httpsport),
                host=host,
                mode='reverse',
                upstream_server=cmdline.parse_server_spec('https://%s:443/' %
                                                          event.message))
            proxy_server = ProxyServer(proxy_config)
        except Exception as e:
            evt = custom_events.wxStatusEvent(
                message='Error starting HTTPS proxy: %s' % e)
            wx.PostEvent(self.main_tab, evt)
            return

        self.proxy_master = PadMaster(proxy_server, self, region)
        thread.start_new_thread(self.proxy_master.run, ())
Esempio n. 4
0
def start_server(proxy_port, proxy_mode):
    LOGO = r'''
 ____  _               ____    ____     ___   __  __ __   __
| __ )| |_   _  ___   |  _ \  |  _ \   / _ \  \ \/ / \ \ / /
|  _ \| | | | |/ _ \  | |_) | | |_) | | | | |  \  /   \ V /
| |_) | | |_| |  __/  |  __/  |  _ <  | |_| |  /  \    | |
|____/|_|\__,_|\___|  |_|     |_| \_\  \___/  /_/\_\   |_|
           '''
    cprint(LOGO, 'cyan')
    cprint('[+] Starting Proxy On 0.0.0.0:{0}'.format(proxy_port), 'cyan')
    cprint('[+] Starting Proxy Mode: {0}'.format(proxy_mode), 'cyan')
    port = int(proxy_port)
    if proxy_mode == 'http':
        mode = 'regular'
    else:
        mode = proxy_mode

    opts = options.Options(
        listen_port=port,
        mode=mode,
        cadir="./ssl/",
        ssl_insecure=True,
    )

    config = proxy.ProxyConfig(opts)
    server = ProxyServer(config)
    state = flow.State()
    m = BlueProxy(opts, server, state)
    m.run()
Esempio n. 5
0
 def start(self):
     print "[*] Pumpkin-Proxy running on port:8080 \n"
     opts = options.Options(listen_port=8080, mode="transparent")
     config = proxy.ProxyConfig(opts)
     state = flow.State()
     server = ProxyServer(config)
     server.allow_reuse_address = True
     self.m = MasterHandler(opts, server, state, self.session)
     self.m.run(self.send)
Esempio n. 6
0
def shutdown_proxy():
    opts = options.Options(
        listen_host=PROXY_LISTEN_HOST,
        listen_port=PROXY_LISTEN_PORT,
        mode=PROXY_LISTEN_MODE,
        cadir=PROXY_CACER_DIR,
    )

    config = proxy.ProxyConfig(opts)
    server = ProxyServer(config)

    m = master.Master(opts, server)
    m.shutdown()
Esempio n. 7
0
def _run(port, outfile, mode, cadir):
    opts = options.Options(listen_port=port, mode=mode, cadir=cadir)
    config = proxy.ProxyConfig(opts)
    server = ProxyServer(config)
    m = dump.DumpMaster(server, dump.Options(outfile=[outfile,'wb'], verbosity=0))

    # Define a handler for the shutdown signal so the parent process knows how to stop me
    def cleankill(*args, **kwargs):
        m.shutdown()
    signal.signal(signal.SIGTERM, cleankill)

    # Now start the server. This operation will block.
    m.run()
Esempio n. 8
0
def start():
    arguments = docopt(__doc__, version='dev')
    if arguments['--filter'] not in ('NONE', 'LOW', 'HIGH'):
        print "--filter should set to (NONE|LOW|HIGH)"
        print __doc__
        exit()
    config = proxy.ProxyConfig(port=PORT)
    server = ProxyServer(config)

    flow_filter = FlowFilter(arguments['--filter'], arguments['-p'], arguments['-d'], arguments['--blacklist'])
    flow_handler = FlowHandler(arguments['-u'], arguments['--debug'])
    m = Master(server, flow_filter, flow_handler)
    m.run()
Esempio n. 9
0
def capture(request):
    port = request.GET.get('port', 8888)  #
    mode = request.GET.get('mode', 'regular')  #mode=regular
    opts = options.Options(
        listen_port=int(port),
        mode=mode,
        cadir="./ssl/",
    )
    unsave_data = False
    config = proxy.ProxyConfig(opts)
    state = flow.State()
    server = ProxyServer(config)
    m = WSProxy(opts, server, state, unsave_data)
    m.run()
Esempio n. 10
0
def start_proxy():
    opts = options.Options(
        listen_host=PROXY_LISTEN_HOST,
        listen_port=PROXY_LISTEN_PORT,
        mode=PROXY_LISTEN_MODE,
        cadir=BASE_DIR+"/ssl/",
    )

    config = proxy.ProxyConfig(opts)
    try:
        server = ProxyServer(config)

        m = ProxyMaster(opts, server)
        m.run()
    except:
        pass
Esempio n. 11
0
def start_server(proxy_port, proxy_mode):
    port = int(proxy_port) if proxy_port else 8090
    mode = proxy_mode if proxy_mode else 'regular'

    if proxy_mode == 'http':
        mode = 'regular'

    opts = options.Options(
        listen_port=port,
        mode=mode,
        cadir="~/.mitmproxy/",
    )
    config = proxy.ProxyConfig(opts)
    state = flow.State()
    server = ProxyServer(config)
    m = ProxyClass(opts, server, state)
    m.run()
Esempio n. 12
0
def start_server(proxy_port, proxy_mode, unsave_data):
    port = int(proxy_port) if proxy_port else 8080
    mode = proxy_mode if proxy_mode else 'regular'

    if proxy_mode == 'http':
        mode = 'regular'

    config = proxy.ProxyConfig(
        port=port,
        mode=mode,
        cadir="./ssl/",
    )

    state = flow.State()
    server = ProxyServer(config)
    m = WYProxy(server, state, unsave_data)
    m.run()
Esempio n. 13
0
def start_server(proxy_port, proxy_mode, unsave_data):
    port = int(proxy_port) if proxy_port else 8080
    mode = proxy_mode if proxy_mode else 'regular'

    if proxy_mode == 'http':
        mode = 'regular'
    opts = options.Options(
        listen_port=port,
        mode=mode,
        # cadir="./ssl/",
        )

    config = proxy.ProxyConfig(opts)

    state = flow.State()
    server = ProxyServer(config)
    m = WYProxy(opts, server, state, unsave_data)
    m.run()
Esempio n. 14
0
    def start_master(self, dump_file_path, op_mode):
        logger.info('Starting master')
        config = proxy.ProxyConfig(
            port = self.port,
            mode = op_mode
        )

        dump_options = dump.Options(
            verbosity = 3,
            eventlog = True,
            flow_detail = True,
            showhost = True,
            outfile = (dump_file_path, 'wb')
        )

        server = proxy.ProxyServer(config)
        proxy_master = ProxyMaster(server, dump_options)
        proxy_master.run()
Esempio n. 15
0
def start_server(proxy_port, proxy_mode):
    port = int(proxy_port) if proxy_port else 8080
    mode = proxy_mode if proxy_mode else 'regular'

    if proxy_mode == 'http':
        mode = 'regular'

    opts = options.Options(
        listen_port=port,
        mode=mode,
        cadir="/data/MingDao/ssl/",
    )

    config = proxy.ProxyConfig(opts)

    state = flow.State()
    server = ProxyServer(config)
    m = mingdaoproxy(opts, server, state)
    m.run()
Esempio n. 16
0
    def _prepare_handler(self):
        proxy_opts      = options.Options(
                            clientcerts=self.client_cert,
                            certs=self.certs,
                            #listen_host=self.listen_host,
                            listen_port=self.listen_port,
                            mode='transparent',
                            )
        proxy_config    = proxy.ProxyConfig(proxy_opts)
        proxy_server = ProxyServer(proxy_config)
        self.master_handler = EvilInTheMiddleHandler(proxy_opts, proxy_server)

        # Initialize plugins. Same method as in WiFi-Pumpkin
        for plugin in MITMPlugin.__subclasses__():
            plugin_instance = plugin()
            if plugin_instance.name in self.plugins:
                self.master_handler.plugins.append(plugin_instance)
                plugin_instance.setup()
                print "[+] Successfully loaded '{}' plugin.".format(plugin_instance.name)
Esempio n. 17
0
    def __init__(self, port, kb, logger, allow_domain_re, restrict_path_re):
        """
        :port:          监听端口
        :kb:            Universal KnowledgeBase
        :logger:        输出
        :allow_domain:  允许的域名,本来应该在Crawler里了,现在还是单独放在这里
        :restrict_path: 限制目录,同上
        """
        super(ClickProxy, self).__init__()

        config = proxy.ProxyConfig(port=port)
        server = ProxyServer(config)
        self.cproxy = MasterOfProxy(server=server,
                                    kb=kb,
                                    allow_domain_re=allow_domain_re,
                                    restrict_path_re=restrict_path_re)

        self.logger = logger
        self.exit_flag = False
        self.seconds_wait = 2
Esempio n. 18
0
def main():
    opts, args = getopt.getopt(sys.argv[1:], "hp:w:")
    strPort = 8888
    fnamescript = '__crisschan_TEMP' + str(time.time())
    for op, value in opts:
        if op == "-p":
            strPort = value
        elif op == "-w":
            fnamescript = value
        elif op == "-h":
            #usage()
            print '-p the proxy port\r\n-w the script_solution  name'
            sys.exit()

    config = proxy.ProxyConfig(cadir=os.path.expanduser("~/.mitmproxy/"),
                               port=int(strPort))
    server = proxy.ProxyServer(config)
    print 'the porxy port is ' + str(strPort)
    m = FriedRing(server, fnamescript)
    m.run()
Esempio n. 19
0
                except OSError as exc:  # Guard against race condition
                    if exc.errno != errno.EEXIST:
                        raise
            with open(path, 'w') as f:
                f.write(content)
            ## should save this to file
        elif self.is_supported_host(host):
            print "Received a: %d for %s/%s" % (flow.response.status_code,
                                                host, path)

        flow.reply()

    def is_supported_api(self, host):
        """
        Used to limit the capture/stub to specific requests
        """
        return self.is_supported_host(host)

    def is_supported_host(self, host):
        """
        Used to limit the capture/stub to specific hosts
        """
        if host.endswith("example.com"):
            return True


config = proxy.ProxyConfig(port=8888)
server = ProxyServer(config)
m = StubMaster(server)
m.run()
Esempio n. 20
0
def main():
    opts, args = getopt.getopt(sys.argv[1:], "hp:w:r:t:u:i:b:c:x:v:", [
        "help", "proxyport=", "workspace=", "run=", "runtime=", "rampup=",
        "resultinterval=", "progressbar=", "consolelogging=", "xmlreport=",
        "vusers="
    ])
    strPort = 8888
    fnamescript = '__crisschan_TEMP' + time.strftime(
        "%Y%m%d%H%M%S", time.localtime(time.time()))
    op = ''
    sTargetRun = 'c'
    run_time = 30
    rampup = 0
    results_ts_interval = 1
    progress_bar = 'on'
    console_logging = 'on'
    xml_report = 'off'
    threads = 10
    for op, value in opts:
        if op in ("-p", "--proxyport"):
            strPort = value
        elif op in ("-w", "--workspace"):
            fnamescript = value
        elif op in ("-r", "--run"):
            sTargetRun = value
        elif op in ('-t', "--runtime"):
            run_time = value
        elif op in ("-u", "--rampup"):
            rampup = value
        elif op in ("-i", "--resultinterval"):
            results_ts_interval = value
        elif op in ("-b", "--progressbar"):
            progress_bar = value
        elif op in ("-c", "--consolelogging"):
            console_logging = value
        elif op in ("-x", "--xmlreport"):
            xml_report = value
        elif op in ("-v", "--vusers"):
            threads = value
        elif op in ("-h", "--help"):
            # usage()
            print '-p the proxy port\r\n' \
                  '-r the run all scenario under test workspace,the param is:\r\n' \
                  '    s - is serial run all scenrio \r\n' \
                  '    p - is parralle run all scenrio\r\n' \
                  '-w the performance test workspace name \r\n\r\n' \
                  'other is the scenrio config seting that is available for parralle run:\r\n' \
                  '    -t is runtime that duration of test (seconds)\r\n' \
                  '    -u is rampup that duration of user rampup\r\n' \
                  '    -i is resultinterval that time series interval for results analysis (seconds) \r\n' \
                  '    -b is progressbar that turn on/off console progress bar during test run default = on\r\n' \
                  '    -c is consolelogging that turn on/off logging to stdout default = on\r\n' \
                  '    -x is xmlreport that turn on/off xml/jtl report default = off\r\n' \
                  '    -v is vusers that number of threads/virtual users for each scenrio default=10\r\n'

            sys.exit()

    config = proxy.ProxyConfig(cadir=os.path.expanduser("~/.mitmproxy/"),
                               port=int(strPort))
    #print run_time,rampup,results_ts_interval,progress_bar,console_logging,xml_report,threads
    if sTargetRun != 'c':
        ARun = alasRun()
        if sTargetRun == 's':
            ARun.sRun()
        elif sTargetRun == 'p':

            if progress_bar != 'on' and progress_bar != 'off':
                print 'progress_bar only input on/off!'
                return 0
            if console_logging != 'on' and console_logging != 'off':
                print 'console_logging only input on/off!'
                return 0
            if xml_report != 'on' and xml_report != 'off':
                print 'xml_report only input on/off!'
                return 0

            ARun.pRun(run_time, rampup, results_ts_interval, progress_bar,
                      console_logging, xml_report, threads)
        else:
            print '-r is the error input!!!!'
            return 0
    else:
        server = proxy.ProxyServer(config)
        print 'the porxy port is ' + str(strPort)
        m = FriedRing(server, fnamescript)
        m.run()
    '''
Esempio n. 21
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
try:
    from mitmproxy import controller, proxy
    from mitmproxy.proxy.server import ProxyServer
except:
    from libmproxy import controller, proxy
    from libmproxy.proxy.server import ProxyServer

from core.handler import MasterHandler
from time import sleep
if __name__ == '__main__':
    import os
    #ssl = proxy.SSLConfig("/home/mh4x0f/.mitmproxy/mitmproxy-ca-cert.pem")
    config = proxy.ProxyConfig(cadir='/home/mh4x0f/.mitmproxy/', port=8080)
    print "PumpkinProxy running on port:8080 \n"
    server = ProxyServer(config)
    m = MasterHandler(server, 'KnHKlOuk==')
    try:
        m.run()
        print('[*] all plugins started...\n')
        while True:
            pass
    except KeyboardInterrupt:
        m.shutdown()
Esempio n. 22
0
            self.shutdown()

    def handle_request(self, flow):
        print 'running'
        hid = (flow.request.host, flow.request.port)
        a = str(hid)
        print a
        ser = serial.Serial('/dev/cu.usbmodem1421', 9600)
        time.sleep(1.5)
        written = ser.write('5')
        ser.close()
        print "Bytes Written to port:", written

        if "cookie" in flow.request.headers:
            self.stickyhosts[hid] = flow.request.headers.get_all("cookie")
        elif hid in self.stickyhosts:
            flow.request.headers.set_all("cookie", self.stickyhosts[hid])
        flow.reply()

    def handle_response(self, flow):
        hid = (flow.request.host, flow.request.port)
        if "set-cookie" in flow.response.headers:
            self.stickyhosts[hid] = flow.response.headers.get_all("set-cookie")
        flow.reply()


config = proxy.ProxyConfig(port=8080)
server = ProxyServer(config)
m = StickyMaster(server)
m.run()
Esempio n. 23
0
 proxyMode) = parseOptions(sys.argv[1:])

# ------------------------------------
# FruityProxy (setup)
# ------------------------------------
if upStreamServer == False:
    mitmOptions = options.Options(listen_port=listenPort, mode=proxyMode)
    start_msg = "FruityProxy running on port " + str(listenPort)
else:
    mitmOptions = options.Options(listen_port=listenPort,
                                  mode="upstream",
                                  upstream_server=upStreamServer)
    start_msg = "FruityProxy running on port " + str(
        listenPort) + ", upstream proxy: " + str(upStreamServer)

config = proxy.ProxyConfig(mitmOptions)
server = ProxyServer(config)
m = ProxyHandler(mitmOptions, server)


def startProxy():
    try:
        m.run()
    except:
        pass


# ------------------------------------
# API
# ------------------------------------
app = Flask(__name__)
Esempio n. 24
0
################################## START MAIN #######################################

CONFIGFILE = "bdfproxy.cfg"
BDFOLDER = "backdoored"

# Initial CONFIG reading
user_config = ConfigObj(CONFIGFILE)

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

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

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

server = ProxyServer(config)

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

if not isinstance(numericLogLevel, int):
Esempio n. 25
0
            elif opt in ("-m", "--mode"):
                proxyMode = arg

        return (listenPort, listenPortApi, upStreamServer, upStreamPort, proxyMode)
                    
    except getopt.GetoptError:
        usage()
        sys.exit(2)

(listenPort, listenPortApi, upStreamServer, upStreamPort, proxyMode) = parseOptions(sys.argv[1:])

# ------------------------------------
# FruityProxy (setup)
# ------------------------------------
if upStreamServer == False or upStreamPort == False:
    config = proxy.ProxyConfig(port=listenPort, mode=proxyMode)
    start_msg = "FruityProxy running on port " +  str(listenPort)
else:
    config = proxy.ProxyConfig(port=listenPort, mode="upstream",upstream_server=[False, False, upStreamServer, int(upStreamPort)])
    start_msg = "FruityProxy running on port " +  str(listenPort) + ", upstream proxy: " + str(upStreamServer) + ":" + str(upStreamPort)
    
server = ProxyServer(config)
m = ProxyHandler(server)

def startProxy():
    try:
        m.run()
    except:
        pass