コード例 #1
0
ファイル: __init__.py プロジェクト: r4b3rt/pocsuite3
    def __init__(self, bind_ip='0.0.0.0', bind_port=666, is_ipv6=False, use_https=False,
                 certfile=os.path.join(paths.POCSUITE_TMP_PATH, 'cacert.pem'),
                 requestHandler=BaseRequestHandler):
        gen_cert(filepath=certfile)
        threading.Thread.__init__(self)
        self.bind_ip = bind_ip
        self.bind_port = int(bind_port)
        self.is_ipv6 = is_ipv6
        self.https = use_https
        if self.https:
            self.scheme = 'https'
        else:
            self.scheme = 'http'
        self.certfile = certfile
        self.server_locked = False  # Avoid call start method muti-times
        self.server_started = False  # Aviod start server mutl-times
        self.requestHandler = requestHandler
        if ':' in bind_ip:
            ipv6 = get_host_ipv6()
            if not ipv6:
                logger.error('Your machine may not support ipv6')
                raise PocsuiteSystemException
            self.host_ip = ipv6
            self.httpserver = HTTPServerV6
            self.is_ipv6 = True
        else:
            self.is_ipv6 = False
            self.host_ip = get_host_ip()
            self.httpserver = HTTPServerV4

        self.__flag = threading.Event()  # The identifier used to pause the thread
        self.__flag.set()  # set flag True
        self.__running = threading.Event()  # The identifier used to stop the thread
        self.__running.set()  # set running True
コード例 #2
0
ファイル: option.py プロジェクト: r4b3rt/pocsuite3
def _set_connect_back():
    if conf.mode == "shell" and conf.connect_back_host is None:
        wan_ipv4 = get_host_ip()
        kb.data.local_ips = get_local_ip(all=True)
        data_to_stdout(
            "[i] pocsusite is running in shell mode, you need to set connect back host:\n"
        )
        message = '----- Local IP Address -----\n'
        for i, ip in enumerate(kb.data.local_ips):
            v = ip
            if conf.ppt:
                v = desensitization(v)
            if ip == wan_ipv4:
                v = colored(f'{v}    *wan*', 'green')
            message += "{0}    {1}\n".format(i, v)
        data_to_stdout(message)
        while True:
            choose = None
            choose = input('Choose>: ').strip()
            if not choose:
                continue
            try:
                if choose.isdigit():
                    choose = int(choose)
                    conf.connect_back_host = kb.data.local_ips[choose]
                    data_to_stdout("you choose {0}\n".format(
                        desensitization(conf.connect_back_host) if conf.
                        ppt else conf.connect_back_host))
                    break
            except Exception:
                data_to_stdout("wrong number, choose again\n")
コード例 #3
0
 def test_ipv4_https(self):
     try:
         logger.info('Test https server in ipv4')
         PHTTPServer._instance = None
         httpd = PHTTPServer(bind_ip='0.0.0.0', bind_port=6666, use_https=True,
                             requestHandler=BaseRequestHandler)
         httpd.start()
         url = '{}://{}:{}/'.format('https', get_host_ip(), 6666)
         requests.get(url)
     except requests.exceptions.SSLError:
         url = '{}://{}:{}/'.format('https', get_host_ip(), 6666)
         resp = requests.get(url, verify=False)
         self.assertEqual(resp.status_code, 200)
     except Exception:
         assert False
     finally:
         httpd.stop()