-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
119 lines (77 loc) · 2.62 KB
/
main.py
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
from fastapi.responses import HTMLResponse
from fastapi import FastAPI, Request, HTTPException
from rich import print
import uvicorn
import requests
import time
import sys
from Tor_install import *
from pyngrok import ngrok
from rich import print
import atexit
_connection = None
print("[blue] [=] Checking if Tor installed[/blue]")
if not check_tor_installed():
print("[red] [-] Tor not found -- > Installing Tor[/red]")
try:
install_tor()
print("[green] [+] Installed Tor[/green]")
except:
print("[red] [-] Tor couldn't be installed -- > Exiting[/red]")
exit()
print("[green] [+] Starting Tor [/green]")
def start_tor():
if sys.platform.startswith('linux'):
subprocess.run(['sudo', 'service', 'tor', 'start'])
elif sys.platform.startswith('win'):
subprocess.run(['net', 'start', 'tor'])
elif sys.platform.startswith('darwin'):
subprocess.run(['sudo', 'launchctl', 'start', 'homebrew.mxcl.tor'])
else:
print("[red] [-] Unsupported operating system. [/red]")
exit()
print("[green] [+] Tor service restarted successfully.[/green]")
start_tor()
def close():
global _connection
ngrok.disconnect(_connection.public_url)
def start_ngrok(auth, t):
global _connection
ngrok.set_auth_token(auth)
if t == "2":
_connection = ngrok.connect(8088, "http")
else:
_connection = ngrok.connect(8088, "tcp")
print(f"\n[bold][dark_orange]Ngrok Public URL : {_connection.public_url}[/dark_orange][/bold]\n\n")
atexit.register(close)
tor_proxy = {
'http': 'socks5h://localhost:9050',
'https': 'socks5h://localhost:9050'
}
app = FastAPI()
@app.get('/{e}', response_class=HTMLResponse)
async def get(e):
if not e.startswith("http://") or e.startswith("https://"):
e = "http://" + e
try:
t = requests.get(e, proxies=tor_proxy)
return t.text
except:
raise HTTPException(status_code=500, detail="Server error")
if input("Public or Private (1/2): ") == "1":
start_ngrok(input("Ngrok Auth : "), input("1 Http or 2 Https (note using https can get 'your ip expossed') : "))
else:
print(f"\n[bold][dark_orange]Private URL : http://localhost:8088[/dark_orange][/bold]\n\n")
print("""[dark_orange]
NOTE :
uses port 8088
installs tor if not found
runs tor service
Example :
ngrok_url:port/<****.onion> or http://localhost:8088/<darkwebspagejknewlkn11232.onion>
[/dark_orange]""")
uvicorn.run(
app,
host= "localhost",
port= 8088,
)