Compare commits
20 Commits
Author | SHA1 | Date |
---|---|---|
jesopo | 11af215bc4 | |
Ben Harris | 070e74cd56 | |
tilde services | a3b917ee73 | |
Ben Harris | 2b7d0e5b20 | |
Ben Harris | 3e4eb055c7 | |
aewens | 99be0c244d | |
aewens | 81bf0a5cca | |
Ben Harris | fd78aabe07 | |
aewens | b3fd8fdbc0 | |
aewens | be8adb6d7a | |
Ben Harris | 8486c660eb | |
Robert Miles | e437bfd1ab | |
Robert Miles | a119f53607 | |
Ben Harris | ec6344383c | |
aewens | 67d781bd7c | |
aewens | 90a03da496 | |
Ben Harris | 42c285a0ff | |
Ben Harris | 315f1bfe24 | |
Ben Harris | f2da85e437 | |
tilde services | 13816f1d80 |
|
@ -1,2 +1,5 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
.py[cod]
|
.py[cod]
|
||||||
|
db.sqlite
|
||||||
|
up/
|
||||||
|
*.pyc
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# /etc/systemd/system/nullpointer.service
|
||||||
|
[Unit]
|
||||||
|
Description=null pointer
|
||||||
|
After=0x0.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/home/services/0x0
|
||||||
|
ExecStart=/usr/local/bin/uwsgi --socket 127.0.0.1:3031 --wsgi-file fhost.py --callable app --processes 4 --threads 2
|
||||||
|
User=services
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=60s
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
|
95
fhost.py
95
fhost.py
|
@ -46,7 +46,7 @@ app.config["FHOST_MIME_BLACKLIST"] = [
|
||||||
|
|
||||||
app.config["FHOST_UPLOAD_BLACKLIST"] = "tornodes.txt"
|
app.config["FHOST_UPLOAD_BLACKLIST"] = "tornodes.txt"
|
||||||
|
|
||||||
app.config["NSFW_DETECT"] = True
|
app.config["NSFW_DETECT"] = False
|
||||||
app.config["NSFW_THRESHOLD"] = 0.608
|
app.config["NSFW_THRESHOLD"] = 0.608
|
||||||
|
|
||||||
if app.config["NSFW_DETECT"]:
|
if app.config["NSFW_DETECT"]:
|
||||||
|
@ -132,6 +132,12 @@ def is_fhost_url(url):
|
||||||
return url.startswith(fhost_url()) or url.startswith(fhost_url("https"))
|
return url.startswith(fhost_url()) or url.startswith(fhost_url("https"))
|
||||||
|
|
||||||
def shorten(url):
|
def shorten(url):
|
||||||
|
# handler to convert gopher links to HTTP(S) proxy
|
||||||
|
gopher = "gopher://"
|
||||||
|
length = len(gopher)
|
||||||
|
if url[:length] == gopher:
|
||||||
|
url = "https://gopher.tilde.team/{}".format(url[length:])
|
||||||
|
|
||||||
if len(url) > app.config["MAX_URL_LENGTH"]:
|
if len(url) > app.config["MAX_URL_LENGTH"]:
|
||||||
abort(414)
|
abort(414)
|
||||||
|
|
||||||
|
@ -233,6 +239,12 @@ def store_file(f, addr):
|
||||||
return sf.geturl()
|
return sf.geturl()
|
||||||
|
|
||||||
def store_url(url, addr):
|
def store_url(url, addr):
|
||||||
|
# handler to convert gopher links to HTTP(S) proxy
|
||||||
|
gopher = "gopher://"
|
||||||
|
length = len(gopher)
|
||||||
|
if url[:length] == gopher:
|
||||||
|
url = "https://gopher.tilde.team/{}".format(url[length:])
|
||||||
|
|
||||||
if is_fhost_url(url):
|
if is_fhost_url(url):
|
||||||
return segfault(508)
|
return segfault(508)
|
||||||
|
|
||||||
|
@ -318,14 +330,17 @@ def dump_urls(start=0):
|
||||||
@app.route("/", methods=["GET", "POST"])
|
@app.route("/", methods=["GET", "POST"])
|
||||||
def fhost():
|
def fhost():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
sf = None
|
out = None
|
||||||
|
|
||||||
if "file" in request.files:
|
if "file" in request.files:
|
||||||
return store_file(request.files["file"], request.remote_addr)
|
out = store_file(request.files["file"], request.remote_addr)
|
||||||
elif "url" in request.form:
|
elif "url" in request.form:
|
||||||
return store_url(request.form["url"], request.remote_addr)
|
out = store_url(request.form["url"], request.remote_addr)
|
||||||
elif "shorten" in request.form:
|
elif "shorten" in request.form:
|
||||||
return shorten(request.form["shorten"])
|
out = shorten(request.form["shorten"])
|
||||||
|
|
||||||
|
if not out == None:
|
||||||
|
return Response(out, mimetype="text/plain")
|
||||||
|
|
||||||
abort(400)
|
abort(400)
|
||||||
else:
|
else:
|
||||||
|
@ -341,27 +356,39 @@ def fhost():
|
||||||
if maxsizehalf.is_integer():
|
if maxsizehalf.is_integer():
|
||||||
maxsizehalf = int(maxsizehalf)
|
maxsizehalf = int(maxsizehalf)
|
||||||
|
|
||||||
return """<pre>
|
return """
|
||||||
THE NULL POINTER
|
<html>
|
||||||
================
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://tilde.team/css/hacker.css">
|
||||||
|
<title>{6}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h1>THE NULL POINTER</h1>
|
||||||
|
<hr>
|
||||||
|
|
||||||
HTTP POST files here:
|
HTTP POST files here:
|
||||||
curl -F'file=@yourfile.png' {0}
|
<pre>curl -F'file=@yourfile.png' {0}</pre>
|
||||||
You can also POST remote URLs:
|
You can also POST remote URLs:
|
||||||
curl -F'url=http://example.com/image.jpg' {0}
|
<pre>curl -F'url=http://example.com/image.jpg' {0}</pre>
|
||||||
Or you can shorten URLs:
|
Or you can shorten URLs:
|
||||||
curl -F'shorten=http://example.com/some/long/url' {0}
|
<pre>curl -F'shorten=http://example.com/some/long/url' {0}</pre>
|
||||||
|
|
||||||
File URLs are valid for at least 30 days and up to a year (see below).
|
<p>File URLs are valid for at least 30 days and up to a year (see below).
|
||||||
Shortened URLs do not expire.
|
Shortened URLs do not expire.</p>
|
||||||
|
|
||||||
Maximum file size: {1}
|
<p>Maximum file size: {1}</p>
|
||||||
Not allowed: {5}
|
<p>Not allowed: {5}</p>
|
||||||
|
|
||||||
|
<em>if you want a nice wrapper, try <a href="https://tildegit.org/tomasino/pb">~tomasino's pb</a></em>
|
||||||
|
|
||||||
FILE RETENTION PERIOD
|
<h3>FILE RETENTION PERIOD</h3>
|
||||||
---------------------
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
|
retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
|
||||||
|
|
||||||
days
|
days
|
||||||
|
@ -385,20 +412,34 @@ retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
|
||||||
30 | ....................
|
30 | ....................
|
||||||
0{2}{3}
|
0{2}{3}
|
||||||
{4}
|
{4}
|
||||||
|
|
||||||
|
|
||||||
ABUSE
|
|
||||||
-----
|
|
||||||
|
|
||||||
If you would like to request permanent deletion, please contact lachs0r via
|
|
||||||
IRC on Freenode, or send an email to lachs0r@(this domain).
|
|
||||||
|
|
||||||
Please allow up to 24 hours for a response.
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<h3>ABUSE</h3>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>If you would like to request permanent deletion, please contact ben or khuxkm via
|
||||||
|
IRC on <a href="https://web.tilde.chat">tilde.chat</a>, or send an email to sudoers@tilde.team.</p>
|
||||||
|
|
||||||
|
<p>Please allow up to 24 hours for a response.</p>
|
||||||
|
|
||||||
|
<h3>UPLOAD DIRECTLY</h3>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<form action="{0}" method="POST" enctype="multipart/form-data">
|
||||||
|
<label for="file">File:</label>
|
||||||
|
<input class="form-control" type="file" name="file"><br><br>
|
||||||
|
<input class="form-control" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<footer class="text-center"><a href="https://tildegit.org/tildeverse/0x0">source here</a></footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
""".format(fhost_url(),
|
""".format(fhost_url(),
|
||||||
maxsize, str(maxsizehalf).rjust(27), str(maxsizenum).rjust(27),
|
maxsize, str(maxsizehalf).rjust(27), str(maxsizenum).rjust(27),
|
||||||
maxsizeunit.rjust(54),
|
maxsizeunit.rjust(54),
|
||||||
", ".join(app.config["FHOST_MIME_BLACKLIST"]))
|
", ".join(app.config["FHOST_MIME_BLACKLIST"]),fhost_url().split("/",2)[2])
|
||||||
|
|
||||||
@app.route("/robots.txt")
|
@app.route("/robots.txt")
|
||||||
def robots():
|
def robots():
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name ttm.sh;
|
||||||
|
return 307 https://$server_name$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
server_name ttm.sh;
|
||||||
|
|
||||||
|
# include your certs
|
||||||
|
ssl_certificate /etc/letsencrypt/live/ttm.sh/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/ttm.sh/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||||
|
|
||||||
|
root /home/services/0x0;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
include uwsgi_params;
|
||||||
|
uwsgi_param UWSGI_SCHEME $scheme;
|
||||||
|
|
||||||
|
# make sure this matches the port you're running uwsgi on
|
||||||
|
uwsgi_pass 127.0.0.1:3031;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /up {
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue