コード例 #1
0
def setup_webhook():
    if PRODUCT_ID == "" or PHONE_ID == "" or API_TOKEN == "":
        print(
            "You need to change PRODUCT_ID, PHONE_ID and API_TOKEN values in app.py file.",
            file=sys.stdout,
            flush=True)
        return
    public_url = ngrok.connect(9000)
    url = INSTANCE_URL + "/" + PRODUCT_ID + "/setWebhook"
    print("url", url, file=sys.stdout, flush=True)
    headers = {
        "Content-Type": "application/json",
        "x-maytapi-key": API_TOKEN,
    }
    body = {"webhook": public_url.public_url + "/webhook"}
    response = requests.post(url, json=body, headers=headers)
    print("webhook ", response.json())
コード例 #2
0
ファイル: _geometry_extra.py プロジェクト: hjsuh94/drake
def StartMeshcat():
    """
    Constructs a Meshcat instance, with support for Deepnote and Google Colab.

    On most platforms, this method is equivalent to calling `meshcat =
    Meshcat()`. On Deepnote or Google Colab, this provides extra functionality,
    setting Meshcat to use the appropriate ports and to use ngrok if necessary.

    Note that the free/unregistered version of ngrok only allows two
    connections. On Google Colab, this means one can only have two viable
    Meshcat instances running per provisioned machine. On Deepnote, we have one
    additional port available (port 8080) which does not require ngrok; you
    must "Allow incoming connections" in the environment settings to use it.

    If you run out of available ports, you can reset the notebook to free any
    ports that are currently used by the notebook.
    """
    prev_log_level = set_log_level("warn")
    use_ngrok = False
    if ("DEEPNOTE_PROJECT_ID" in os.environ):
        # Deepnote exposes port 8080 (only).  If we need multiple meshcats,
        # then we fall back to ngrok.
        try:
            meshcat = Meshcat(8080)
        except RuntimeError:
            use_ngrok = True
        else:
            set_log_level(prev_log_level)
            web_url = f"https://{os.environ['DEEPNOTE_PROJECT_ID']}.deepnoteproject.com"  # noqa
            print(f'Meshcat is now available at {web_url}')
            return meshcat

    if 'google.colab' in sys.modules:
        use_ngrok = True

    meshcat = Meshcat()
    web_url = meshcat.web_url()
    if use_ngrok:
        from pyngrok import ngrok
        http_tunnel = ngrok.connect(meshcat.port(), bind_tls=False)
        web_url = http_tunnel.public_url

    set_log_level(prev_log_level)
    print(f'Meshcat is now available at {web_url}')

    return meshcat
コード例 #3
0
    def test_get_tunnel_fileserver(self):
        if "NGROK_AUTHTOKEN" not in os.environ:
            self.skipTest("NGROK_AUTHTOKEN environment variable not set")

        # GIVEN
        self.assertEqual(len(process._current_processes.keys()), 0)
        pyngrok_config = self.copy_with_updates(self.pyngrok_config, auth_token=os.environ["NGROK_AUTHTOKEN"])
        ngrok_tunnel = ngrok.connect("file:///", pyngrok_config=pyngrok_config)
        time.sleep(1)
        api_url = ngrok.get_ngrok_process(pyngrok_config).api_url

        # WHEN
        response = ngrok.api_request("{}{}".format(api_url, ngrok_tunnel.uri), "GET")

        # THEN
        self.assertEqual(ngrok_tunnel.name, response["name"])
        self.assertTrue(ngrok_tunnel.name.startswith("http-file-"))
コード例 #4
0
def StartMeshcat(open_window=False):
    """
    A wrapper around the Meshcat constructor that supports Deepnote and Google
    Colab via ngrok when necessary.
    """
    prev_log_level = set_log_level("warn")
    use_ngrok = False
    if ("DEEPNOTE_PROJECT_ID" in os.environ):
        # Deepnote exposes port 8080 (only).  If we need multiple meshcats,
        # then we fall back to ngrok.
        try:
            meshcat = Meshcat(8080)
        except RuntimeError:
            use_ngrok = True
        else:
            set_log_level(prev_log_level)
            web_url = f"https://{os.environ['DEEPNOTE_PROJECT_ID']}.deepnoteproject.com"  # noqa
            print(f"Meshcat is now available at {web_url}")
            if open_window:
                display(Javascript(f'window.open("{web_url}");'))
            return meshcat

    if 'google.colab' in sys.modules:
        use_ngrok = True

    meshcat = Meshcat()
    web_url = meshcat.web_url()
    if use_ngrok:
        from pyngrok import ngrok
        http_tunnel = ngrok.connect(meshcat.port(), bind_tls=False)
        web_url = http_tunnel.public_url

    set_log_level(prev_log_level)
    display(
        HTML('Meshcat is now available at '
             f'<a href="{web_url}">{web_url}</a>'))

    if open_window:
        if 'google.colab' in sys.modules:
            from google.colab import output
            output.eval_js(f'window.open("{web_url}");', ignore_result=True)
        else:
            display(Javascript(f'window.open("{web_url}");'))

    return meshcat
コード例 #5
0
    def test_disconnect_fileserver(self):
        if "NGROK_AUTHTOKEN" not in os.environ:
            self.skipTest("NGROK_AUTHTOKEN environment variable not set")

        # GIVEN
        self.assertEqual(len(process._current_processes.keys()), 0)
        pyngrok_config = self.copy_with_updates(self.pyngrok_config, auth_token=os.environ["NGROK_AUTHTOKEN"])
        url = ngrok.connect("file:///", pyngrok_config=pyngrok_config).public_url
        time.sleep(1)

        # WHEN
        ngrok.disconnect(url)
        time.sleep(1)
        tunnels = ngrok.get_tunnels()

        # THEN
        # There is still one tunnel left, as we only disconnected the http tunnel
        self.assertEqual(len(tunnels), 1)
コード例 #6
0
def start(config, model_name, force_cpu):

    if force_cpu:
        os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

    model = config.model_manager.models.get(model_name)
    if not model:
        click.echo(f"Model `{model_name}` is not installed.")
        return

    app.generator = GPT2Generator(model)

    # Open a tunnel on the default port 80
    public_url = ngrok.connect(port=5000)

    print(public_url)

    app.run()
コード例 #7
0
def connect_to_ngrok(port, authtoken=None):
    time.sleep(1)
    try:
        active_tunnels = ngrok.get_tunnels()
        time.sleep(1)
        for tunnel in active_tunnels:
            public_url = tunnel.public_url
            print(f"Disconnecting {public_url}")
            ngrok.disconnect(public_url)
            time.sleep(1)
    except:
        print("Some error in ngrok.get_tunnels()")
#     url = ngrok.connect(addr=port, options={"bind_tls":True})
    if authtoken: ngrok.set_auth_token(authtoken)
    url = ngrok.connect(addr=port, bind_tls=True)
    time.sleep(1)
    print(f"Remote server can be assesed on : {url}")
    return url
コード例 #8
0
ファイル: ngrok.py プロジェクト: KlimDos/refresher
def main():
    try:
        public_url = ngrok.connect(8080, "http")
        logging.info("ngrok has been started")
    except Exception as e:
        logging.error(f"ngrok start error \n{e}")
    url = "https://api.telegram.org/bot" + config.tg_token + \
        "/setWebhook?url=https://" + public_url[7:] + "/postjson"
    try:
        requests.get(url)
        logging.info("Bot has been connected to ngrok")
    except Exception as e:
        logging.error(f"Bot connecting error \n{e}")
    logging.info("ngrok service running")
    input("ngrok service running \npress any key to exit")
    logging.info("ngrok service stop")
    ngrok.kill()
    return()
コード例 #9
0
ファイル: hermes.py プロジェクト: jxoesneon/hermesbot
    def start_local_server(self):
        """Start a local Ngrok webhook for the bot

        This will check for a preexisting Ngrook server and raise an exeption if it finds one as only one instance can be running on the free version of Ngrok

        Raises:\n
            SystemExit: When it finds a previous Ngrook service running.
        """
        try:
            self.bot_url = ngrok.connect(port=8080, proto="http")
            print(self.bot_url)
        except Exception:
            self.clear_screen()
            print(
                "You need to close the current terminal, otherwise the HTTP tunnel wont connect"
            )
            input("Press enter to exit.\n")
            raise SystemExit
コード例 #10
0
ファイル: code.py プロジェクト: imneonizer/imcode
    def _start_server(self):
        if self.authtoken:
            ngrok.set_auth_token(self.authtoken)

        active_tunnels = ngrok.get_tunnels()
        for tunnel in active_tunnels:
            used_port = int(tunnel.data['config']['addr'].rsplit(":")[-1])
            public_url = tunnel.public_url
            if used_port == self.port:
                self.log("port already used {} -> localhost:{}".format(
                    public_url, used_port),
                         level="warn")
                self.log("disonnecting {}".format(public_url))
                ngrok.disconnect(public_url)

        url = ngrok.connect(addr=self.port, options={"bind_tls": True})
        url = str(url.public_url).replace("http", "https")
        self.log("code-server url {}".format(url))
コード例 #11
0
def start_a_tunnel(port=8080):
    """
    This function will start a tunnel in port given port, default is 8080
    By default ngrok opens two tunnels 1. http 2. https
    I don't need http
    bind_tls=True tells ngrok to open only https tunnel
    """
    # first I will check if there is any tunnel active
    # if there is any active tunnel we will disconnect it
    for each_tunnel in ngrok.get_tunnels():
        print('Shutting down: ' + each_tunnel.public_url)
        ngrok.disconnect(each_tunnel.public_url)

    # now that it is made sure that there is no tunnels
    # we can open a new_tunnel
    tunnel = ngrok.connect(addr=port, proto='http', bind_tls=True)

    return tunnel.public_url
コード例 #12
0
ファイル: models.py プロジェクト: Mernus/ngrok_dbvolsu
    def __new__(cls):
        if cls.__working:
            return

        cls.__init_settings()

        cls.__active_tunnel = ngrok.connect(settings.PORT, "tcp")
        ngrok_process = ngrok.get_ngrok_process()

        if not ngrok_process.healthy():
            print("\n\033[31m[ERROR]: Ngrok server has some error\033[0m")
            print(settings.NGROK_DOWN_STR)

            ngrok.kill()
        else:
            cls.__working = True

        return super(NgrokServer, cls).__new__(cls)
コード例 #13
0
ファイル: test_ngrok.py プロジェクト: fieldOfView/pyngrok
    def test_get_tunnels(self):
        # GIVEN
        url = ngrok.connect(pyngrok_config=self.pyngrok_config)
        time.sleep(1)

        # WHEN
        tunnels = ngrok.get_tunnels()

        # THEN
        self.assertEqual(len(tunnels), 2)
        for tunnel in tunnels:
            if tunnel.proto == "http":
                self.assertEqual(tunnel.public_url, url)
                self.assertEqual(tunnel.config["addr"], "http://localhost:80")
            else:
                self.assertEqual(tunnel.proto, "https")
                self.assertEqual(tunnel.public_url, url.replace("http", "https"))
                self.assertEqual(tunnel.config["addr"], "http://localhost:80")
コード例 #14
0
ファイル: test_ngrok.py プロジェクト: aps1503/pyngrok
    def test_disconnect(self):
        # GIVEN
        url = ngrok.connect(pyngrok_config=self.pyngrok_config).public_url
        time.sleep(1)
        tunnels = ngrok.get_tunnels()
        # Two tunnels, as one each was created for "http" and "https"
        self.assertEqual(len(ngrok._current_tunnels.keys()), 2)
        self.assertEqual(len(tunnels), 2)

        # WHEN
        ngrok.disconnect(url)
        self.assertEqual(len(ngrok._current_tunnels.keys()), 1)
        time.sleep(1)
        tunnels = ngrok.get_tunnels()

        # THEN
        # There is still one tunnel left, as we only disconnected the http tunnel
        self.assertEqual(len(ngrok._current_tunnels.keys()), 1)
        self.assertEqual(len(tunnels), 1)
コード例 #15
0
def start_ngrok(context):
    from pyngrok import ngrok

    site = get_site(context)
    frappe.init(site=site)

    port = frappe.conf.http_port or frappe.conf.webserver_port
    tunnel = ngrok.connect(addr=str(port), host_header=site)
    print(f"Public URL: {tunnel.public_url}")
    print("Inspect logs at http://localhost:4040")

    ngrok_process = ngrok.get_ngrok_process()
    try:
        # Block until CTRL-C or some other terminating event
        ngrok_process.proc.wait()
    except KeyboardInterrupt:
        print("Shutting down server...")
        frappe.destroy()
        ngrok.kill()
コード例 #16
0
    def server():

        global port

        with open("logs/server.log", "w") as phplog:
            subprocess.Popen(("php", "-S", "localhost:" + port, "-t", temp),
                             stderr=phplog,
                             stdout=phplog)

        conf.get_default().region = region
        tunnel = ngrok.connect(port, "http", auth_token=token)
        tunnel = str(tunnel).replace("NgrokTunnel:", "").replace(
            "http://", "https://").replace('"', '').replace("->", "").replace(
                "https://localhost:" + port, "").replace(" ", "")

        print(Fore.RED + " [!] " + Fore.WHITE + "Your Ngrok Tunnel : " +
              tunnel)
        print(Fore.YELLOW + "\n [+] " + Fore.WHITE +
              "Please Send Link To Target" + "\n")
コード例 #17
0
    def ready(self):
        if settings.DEV_SERVER and settings.USE_NGROK:
            # pyngrok will only be installed, and should only ever be initialized, in a dev environment
            from pyngrok import ngrok

            # Get the dev server port (defaults to 8000 for Django, can be overridden with the
            # last arg when calling `runserver`)
            addrport = urlparse(f"http://{sys.argv[-1]}")
            port = addrport.port if addrport.netloc and addrport.port else 8000

            # Open a ngrok tunnel to the dev server
            public_url = ngrok.connect(port).public_url
            print(
                f"ngrok tunnel \"{public_url}\" -> \"http://127.0.0.1:{port}\""
            )

            # Update any base URLs or webhooks to use the public ngrok URL
            settings.PROJECT_HOST = public_url
            CommonConfig.init_webhooks(public_url)
コード例 #18
0
def start_ngrok(context):
    from pyngrok import ngrok

    site = get_site(context)
    frappe.init(site=site)

    port = frappe.conf.http_port or frappe.conf.webserver_port
    public_url = ngrok.connect(port=port, options={'host_header': site})
    print(f'Public URL: {public_url}')
    print('Inspect logs at http://localhost:4040')

    ngrok_process = ngrok.get_ngrok_process()
    try:
        # Block until CTRL-C or some other terminating event
        ngrok_process.proc.wait()
    except KeyboardInterrupt:
        print("Shutting down server...")
        frappe.destroy()
        ngrok.kill()
コード例 #19
0
ファイル: apps.py プロジェクト: staceb/twilio-taskrouter-demo
    def ready(self):
        if os.environ.get('RUN_MAIN',
                          None) and settings.DEV_SERVER and settings.USE_NGROK:
            # pyngrok will only be installed, and should only ever be initialized, in a dev environment
            from pyngrok import ngrok

            # Get the dev server port (defaults to 8000 for Django, can be overridden with the
            # last arg when calling `runserver`)
            addrport = urlparse('http://{}'.format(sys.argv[-1]))
            port = addrport.port if addrport.netloc and addrport.port else 8000

            # Open a ngrok tunnel to the dev server
            public_url = ngrok.connect(port).rstrip("/")
            print('ngrok tunnel "{}" -> "http://127.0.0.1:{}/"'.format(
                public_url, port))

            # Update any base URLs or webhooks to use the public ngrok URL
            settings.PROJECT_HOST = public_url
            CommonConfig.init_webhooks(public_url)
コード例 #20
0
    def test_ngrok_tunnel_refresh_metrics(self):
        # GIVEN
        current_process = ngrok.get_ngrok_process(
            pyngrok_config=self.pyngrok_config)
        public_url = ngrok.connect(urlparse(current_process.api_url).port)
        time.sleep(1)
        ngrok_tunnel = list(
            filter(lambda t: t.public_url == public_url,
                   ngrok.get_tunnels()))[0]
        self.assertEqual(0, ngrok_tunnel.metrics.get("http").get("count"))

        urlopen("{}/status".format(public_url)).read()
        time.sleep(3)

        # WHEN
        ngrok_tunnel.refresh_metrics()

        # THEN
        self.assertGreater(ngrok_tunnel.metrics.get("http").get("count"), 0)
コード例 #21
0
    def init_app(self, app):
        if app is not None:
            self.app = app

        if self.app.config.get('ENVIRONMENT') == 'DEVELOPMENT':
            self.app.logger.debug(f'connecting to ngrok')
            # ngrok.kill()
            http_tunnel = ngrok.connect(bind_tls=True,
                                        addr=self.app.config.get('HOST') +
                                        ':' + self.app.config.get('PORT'))
            self.app.config.update({'HOST_URL': http_tunnel.public_url})
            self.app.logger.debug(http_tunnel)
        elif self.app.config.get('ENVIRONMENT') == 'PRODUCTION':
            self.app.logger.debug(f'setting up HOST_URL to heroku')
            heroku_app_name = self.app.config.get('HEROKU_APP_NAME')
            app.config.update(
                {'HOST_URL': f'https://{heroku_app_name}.herokuapp.com'})

            atexit.register(self.teardown)
コード例 #22
0
def setup():
    parser = ConfigParser()
    parser.read("bots/bot.ini")
    client_id = parser.get("OAuth", "client_id")
    client_secret = parser.get("OAuth", "client_secret")
    port = parser.getint("OAuth", "port", fallback=4001)
    browser_path = parser.get("OAuth", "browser_path")
    print(f'id: {client_id} browser: {browser_path}')

    redirect_url = ngrok.connect(port, "http")
    print("Redirect URL is", redirect_url)

    client = OAuthZoomClient(client_id, client_secret, port, redirect_url, browser_path)

    user_response = client.user.get(id='me')
    user = json.loads(user_response.content)
    print(user)
    print('---')
    return client
コード例 #23
0
def start_from_cloud(filename: Union[str, None] = None,
                     dm=',',
                     port=8000,
                     lowmem=True):

    from pyngrok import ngrok
    try:
        ngrok_tunnel = ngrok.connect(port)

        if filename is None:
            print(f'\n\033[93mVisit: {ngrok_tunnel.public_url}/index\033[0m\n')
        else:
            print(f'\n\033[93mVisit: {ngrok_tunnel.public_url}\033[0m\n')
            set_global_filedetail(filename=filename, dm=dm, lowmem=lowmem)

        uvicorn.run(app, port=port)

    except Exception as e:

        print(e)
コード例 #24
0
def run(directory, port, remote):
    click.echo(f'Sharing {directory}')
    # ----- Change directory
    chdir(directory)
    click.echo('Running the server')
    # ----- Define server
    solan_server = HTTPServer
    solan_handler = SimpleHTTPRequestHandler
    solan_server_address = ('', port)
    httpd = solan_server(solan_server_address, solan_handler)
    # ----- Get local IP
    hostname = gethostname()
    ip = gethostbyname(hostname)
    click.echo(f'Local service active on {ip}:{port}')
    # ----- Enable remote access
    if remote:
        public_url = ngrok.connect(port)
        click.echo(f'Remote service active on {public_url}')
    # ----- Run server
    httpd.serve_forever()
コード例 #25
0
    def test_stop_monitor_thread(self):
        # GIVEN
        self.given_ngrok_installed(self.pyngrok_config)
        current_process = ngrok.get_ngrok_process(pyngrok_config=self.pyngrok_config)
        public_url = ngrok.connect(urlparse(current_process.api_url).port, bind_tls=True,
                                   pyngrok_config=self.pyngrok_config).public_url
        ngrok_process = ngrok.get_ngrok_process()
        monitor_thread = ngrok_process._monitor_thread

        # WHEN
        time.sleep(1)
        self.assertTrue(monitor_thread.is_alive())
        ngrok_process.stop_monitor_thread()
        # Make a request to the tunnel to force a log through, which will allow the thread to trigger its own teardown
        urlopen("{}/status".format(public_url)).read()
        time.sleep(1)

        # THEN
        self.assertFalse(monitor_thread.is_alive())
        self.assertIsNone(ngrok_process._monitor_thread)
        self.assertTrue(ngrok_process.pyngrok_config.monitor_thread)
コード例 #26
0
ファイル: test_ngrok.py プロジェクト: alirezabayatmk/pyngrok
    def test_ngrok_tunnel_refresh_metrics(self):
        # GIVEN
        current_process = ngrok.get_ngrok_process(
            pyngrok_config=self.pyngrok_config)
        ngrok_tunnel = ngrok.connect(urlparse(current_process.api_url).port,
                                     bind_tls=True)
        time.sleep(1)
        self.assertEqual(0, ngrok_tunnel.metrics.get("http").get("count"))
        self.assertEqual(ngrok_tunnel.data["metrics"].get("http").get("count"),
                         0)

        urlopen("{}/status".format(ngrok_tunnel.public_url)).read()
        time.sleep(3)

        # WHEN
        ngrok_tunnel.refresh_metrics()

        # THEN
        self.assertGreater(ngrok_tunnel.metrics.get("http").get("count"), 0)
        self.assertGreater(
            ngrok_tunnel.data["metrics"].get("http").get("count"), 0)
コード例 #27
0
ファイル: test_ngrok.py プロジェクト: aps1503/pyngrok
    def test_connect(self):
        # GIVEN
        self.assertEqual(len(process._current_processes.keys()), 0)
        self.assertEqual(len(ngrok._current_tunnels.keys()), 0)

        # WHEN
        ngrok_tunnel = ngrok.connect(5000, pyngrok_config=self.pyngrok_config)
        current_process = ngrok.get_ngrok_process()

        # THEN
        self.assertEqual(len(ngrok._current_tunnels.keys()), 1)
        self.assertIsNotNone(current_process)
        self.assertIsNone(current_process.proc.poll())
        self.assertTrue(current_process._monitor_thread.is_alive())
        self.assertTrue(ngrok_tunnel.name.startswith("http-5000-"))
        self.assertEqual("http", ngrok_tunnel.proto)
        self.assertEqual("http://localhost:5000", ngrok_tunnel.config["addr"])
        self.assertIsNotNone(ngrok_tunnel.public_url)
        self.assertIsNotNone(process.get_process(self.pyngrok_config))
        self.assertIn('http://', ngrok_tunnel.public_url)
        self.assertEqual(len(process._current_processes.keys()), 1)
コード例 #28
0
def runNgrok():
    # 	p = subprocess.Popen('ngrok http 5000', shell=True, stderr=subprocess.PIPE)
    # 	print ('hi')

    # ## But do not wait till netstat finish, start displaying output immediately ##
    # 	while True:
    # 		out = p.stderr.read(1)
    # 		if out == '' and p.poll() != None:
    # 			break
    # 		if out != '':
    # 			#sys.stdout.write(out)
    # 			print('!'+out)
    # 			#sys.stdout.flush()

    # 		if 'Forwarding' in out:
    # 			url = re.search('Forwarding\s*(http.*)\s->')
    # 			print (url)
    # 			break

    public_url = ngrok.connect(5000, 'http')
    return (public_url)
コード例 #29
0
ファイル: server.py プロジェクト: 4xx404/BrutoNova
def runServer():
    print(bc.BC + " Starting Ngrok HTTP Tunnel...")
    try:
        http_tunnel = ngrok.connect()
        time.sleep(1)
        if http_tunnel:
            serverStatus = sBan + ' Ngrok Tunnel: ' + bc.GC + 'Connected'
        else:
            serverStatus = eBan + ' Ngrok Tunnel: ' + bc.RC + 'Disconnected'

        os.system('clear')
        print(banner)
        print(serverStatus)
        brutoNovaURL = str(http_tunnel).replace('"', '').replace(
            'NgrokTunnel: ',
            '').replace(' -> http://localhost:80', '').replace(
                'http', 'https') + "/BrutoNova-UI/"
        time.sleep(0.5)
        print(bc.BC + ' Interface URL: ' + bc.GC + brutoNovaURL)
        ngrok_process = ngrok.get_ngrok_process()
        print(bc.BC + "\n" + iBan + bc.GC + " CTRL + C" + bc.BC +
              " to stop the server\n")
        os.chdir('/var/www/html/')
        subprocess.call(['php', '-S', 'localhost:80'])
        ngrok_process.proc.wait()
    except KeyboardInterrupt:
        os.system('clear')
        print(banner)
        print(bc.BC + " Closing PHP Web Server...")
        time.sleep(0.5)
        print(bc.BC + " Closing Ngrok HTTP Tunnel...")
        ngrok.disconnect(http_tunnel.public_url)
        time.sleep(0.5)
        print(bc.BC + " Killing Ngrok process...")
        time.sleep(0.5)
        ngrok.kill()
        time.sleep(0.5)
        os.system('clear')
        print(banner)
        quit()
コード例 #30
0
ファイル: blackawz.py プロジェクト: bobyboooa/BlackAWZ
def social():
    banner.banner()
    menu = input(">>>")
    deb.menu(menu)
    print(" ")

    def phpserver():
        with open("Server", "w") as phplog:
            Popen(("php", "-S", "localhost:4040", "-t", "./template"),
                  stderr=phplog,
                  stdout=phplog)

    phpserver()

    url = ngrok.connect(4040, "http").replace("http", "https")
    print(Style.BRIGHT + Fore.CYAN + "[-] Link " + Fore.BLUE + url +
          Style.RESET_ALL)

    def user():
        global stat_file
        if not str(os.stat("./template/username.json").st_size) == stat_file:
            stat_file = str(os.stat("./template/username.json").st_size)
            fileip = open("./template/username.json", "r")
            b = fileip.read()
            try:
                info = json.loads(b)
                for value in info['dev']:
                    print(Style.BRIGHT + Fore.GREEN + " [+] " + Fore.WHITE +
                          "Username : "******"username"])
                    print(Style.BRIGHT + Fore.GREEN + " [+] " + Fore.WHITE +
                          "Password : "******"password"])
                    jsonFile = open("./template/username.json", "w")
                    jsonWrite = jsonFile.write("")
                    jsonFile.close()
            except:
                print("\nCtrl + C To stop\n")
                #os.system("killall -9 php")

    while True:
        user()