-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.py
75 lines (64 loc) · 2 KB
/
admin.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
from hashlib import sha256
from flask import Blueprint, request
import settings as s
import pagemaker as p
admin = Blueprint("admin", __name__)
def hash(pw=''):
hash = sha256()
hash.update(pw)
return str(hash.hexdigest())
@admin.route('/admin/')
def front():
return "password needed"
@admin.route('/admin/<pw>')
def login(pw):
page = ""
hpw = bytes(pw, "utf-8")
hashed = hash(hpw)
if hashed != s.phash:
return "password?"
cook = f"""<meta http-equiv="set-cookie" content="p={pw}">\n"""
page += "<pre>"
page += """* <a href="#log">log</a>
* <a href="#ips">ips</a>
* <a href="#delete">delete</a>
* <a href="#bans">bans</a>
* <a href="#friends">friends</a>
* tags
* threads
* an example thread
"""
# Show the comment / thread log
page += "<h1 id='log'>#log</h1>"
page += "site | thread | reply | ip\n"
with open("../0chan.vip/log.txt", "r") as log:
log = log.read().splitlines()[::-1]
for n, x in enumerate(log):
x = x.split(" ")
x[-1] = ".".join(x[-1].split(".")[:2])
log[n] = " ".join(x)
page += "\n".join(log)
# Show the trash posts
page += "</pre><hr><h1 id='delete'>#delete</h1><pre>"
with open("../0chan.vip/delete.txt", "r") as delete:
delete = delete.read().splitlines()[::-1]
page += "\n".join(delete)
page += "</pre><hr><h1 id='ips'>#ips</h1><pre>"
with open("../0chan.vip/ips.txt", "r") as ips:
ips = ips.read()
page += "time | ip | captcha | approved time\n"
page += ips
# Show the bans
page += "</pre><hr><h1 id='bans'>#bans</h1><pre>"
with open("../0chan.vip/bans.txt", "r") as bans:
bans = bans.read()
page += bans
# Show friends
page += "</pre><hr><h1 id='friends'>#friends</h1><pre>"
with open("../0chan.vip/threads/friends.txt", "r") as friends:
friends = friends.read()
page += friends
page += "</pre>"
return p.mk(page)
if __name__ == "__main__":
print(hash(s.password))