forked from osufx/secret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
butterCake.py
243 lines (202 loc) · 7.03 KB
/
butterCake.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import json
import re
import traceback
from helpers import aeshelper
from objects import glob
from common.ripple import userUtils
from . import flavours
from . import ice_coffee
from . import police
#Cornflakes is nice when 90% is sugar
sugar = {
"hash": [],
"path": [],
"file": [],
"title": []
}
initialized_eggs = False
#Eggs
def init_eggs():
eggs = glob.db.fetchAll("SELECT * FROM eggs", [])
if eggs is not None:
for egg in eggs:
if egg["type"] not in ["hash", "path", "file", "title"]:
continue
sugar[egg["type"]].append(egg)
compile_regex()
initialized_eggs = True
def compile_regex():
#Cache regex searches
for carbohydrates in sugar:
for speed in sugar[carbohydrates]:
if speed["is_regex"]:
speed["regex"] = re.compile(speed["value"])
#Since this is still being worked on everything is in a try catch
def bake(submit, score):
"""
We have deprecated the process list scanning.
There is no config to re-enable this.
If you know what you are doing however you know how to re-enable this feature.
"""
return
try:
if not initialized_eggs:
init_eggs()
if not score.passed:
return
detected = []
flags = 0
if "osuver" in submit.request.arguments:
aeskey = "osu!-scoreburgr---------{}".format(submit.get_argument("osuver"))
else:
aeskey = "h89f2-890h2h89b34g-h80g134n90133"
iv = submit.get_argument("iv")
score_data = aeshelper.decryptRinjdael(aeskey, iv, submit.get_argument("score"), True).split(":")
username = score_data[1].strip()
user_id = userUtils.getID(username)
restricted = userUtils.isRestricted(user_id)
if restricted == True or user_id == 0: #We dont care about this since this person is already taken care off
return
flags = score_data[17].count(' ')
try:
pl = aeshelper.decryptRinjdael(aeskey, iv, submit.get_argument("pl"), True).split("\r\n")
except:
police.call("Unable to decrypt process list from USERNAME()", user_id=user_id)
detected.append({
"tag":"Unable to decrypt process list (Hacked)",
"ban": False
})
eat(score, {}, detected, flags)
return
pl = sell(pl)
#I dont really like chocolate that much >.<
for p in pl:
for t in sugar.keys():
if p[t] is None:
continue
for speed in sugar[t]:
if speed in detected:
continue
if speed["is_regex"]:
if "regex" not in speed: #Some weird bug where it unsets itself
speed["regex"] = re.compile(speed["value"])
if speed["regex"].search(p[t]) is not None:
detected.append(speed)
else:
if speed["value"] == p[t]:
detected.append(speed)
eat(score, pl, detected, flags)
except:
police.call(traceback.format_exc(), discord_m=True)
police.call("Oh no! The cake is on fire! Abort!")
def sell(processes):
formatted_pl = []
for p in processes: #Formats the process list
try:
t = p.split(" | ", 1)
try:
d = t[0].split(" ", 1)
file_hash = d[0]
file_path = d[1]
except:
file_hash = None
file_path = None
h = t[1].split(" (", 1)
file_name = h[0]
file_title = None
if len(h[1]) > 1:
file_title = h[1][:-1]
formatted_pl.append({"hash":file_hash, "path":file_path,
"file":file_name, "title":file_title})
except:
continue
return formatted_pl
def eat(score, processes, detected, flags):
if flavours.config is None:
police.cache_config()
do_restrict = False
for toppings in detected:
if toppings["ban"]:
do_restrict = True
tag_list = [x["tag"] for x in detected]
hax_flags = flags & ~ice_coffee.IGNORE_HAX_FLAGS
beatmap_id = get_beatmap_id(score.fileMd5)["beatmap_id"]
username = userUtils.getUsername(score.playerUserID)
fields = [
{
"name": "BeatmapID: {}".format(beatmap_id),
"value": "[Download Beatmap](http://{}/b/{})".format(flavours.config["urls"]["main_domain"], beatmap_id),
"inline": True
},
{
"name": "ScoreID: {}".format(score.scoreID),
"value": "[Download Replay](http://{}/web/replays/{})".format(flavours.config["urls"]["main_domain"], score.scoreID),
"inline": True
}
]
if len(detected) > 0:
reason = " & ".join(tag_list)
if len(reason) > 86:
reason = "reasons..."
extra_data = ""
if hax_flags != 0:
extra_data = "\nHad bad flags: ({}) -> ({})".format(flags, make_flags_string(flags))
if do_restrict:
userUtils.restrict(score.playerUserID)
userUtils.appendNotes(score.playerUserID, "Restricted due to {}".format(reason))
police.call("{} was restricted for: {} {}".format(username, reason, extra_data),
discord_m=True,
embed_args={
"color": 0xd9534f,
"title": "Bad cake detected",
"title_url": "http://old.{}/index.php?p=129&sid={}".format(flavours.config["urls"]["main_domain"], score.scoreID),
"desc": "Restricted for: {} {}".format(reason, extra_data),
"author": username,
"author_icon": "http://a.{}/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"author_url": "http://{}/u/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"thumbnail": flavours.config["images"]["bad_cake_ban"],
"fields": fields
}
)
else:
userUtils.appendNotes(score.playerUserID, reason)
police.call("{} submitted bad cake: {} {}".format(username, reason, extra_data),
discord_m=True,
embed_args={
"color": 0xf0ad4e,
"title": "Bad cake detected",
"title_url": "http://old.{}/index.php?p=129&sid={}".format(flavours.config["urls"]["main_domain"], score.scoreID),
"desc": "Had bad cake: {} {}".format(reason, extra_data),
"author": username,
"author_icon": "http://a.{}/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"author_url": "http://{}/u/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"thumbnail": flavours.config["images"]["bad_cake"],
"fields": fields
}
)
elif hax_flags != 0:
police.call("{} submitted bad flags: ({}) -> ({})".format(username, flags, make_flags_string(flags)),
discord_m=True,
embed_args={
"color": 0xf0ad4e,
"title": "Bad flags detected",
"title_url": "http://old.{}/index.php?p=129&sid={}".format(flavours.config["urls"]["main_domain"], score.scoreID),
"desc": "({}) -> ({})".format(flags, make_flags_string(flags)),
"author": username,
"author_icon": "http://a.{}/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"author_url": "http://{}/u/{}".format(flavours.config["urls"]["main_domain"], score.playerUserID),
"thumbnail": flavours.config["images"]["bad_flag"],
"fields": fields
}
)
glob.db.execute("INSERT INTO cakes(id, userid, score_id, processes, detected, flags) VALUES (NULL,%s,%s,%s,%s,%s)", [score.playerUserID, score.scoreID, json.dumps(processes), json.dumps(tag_list), flags])
def make_flags_string(i):
s = []
flags = [e for e in ice_coffee.Flags]
for flag in flags:
if i & flag.value and i & ~ice_coffee.IGNORE_HAX_FLAGS:
s.append(flag.name)
return ", ".join(s)
def get_beatmap_id(hash):
query = "SELECT beatmap_id,beatmapset_id FROM beatmaps WHERE beatmap_md5 = %s"
return glob.db.fetch(query, [hash])