aboutsummaryrefslogtreecommitdiffstats
path: root/checker/src/checker.py
diff options
context:
space:
mode:
Diffstat (limited to 'checker/src/checker.py')
-rw-r--r--checker/src/checker.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/checker/src/checker.py b/checker/src/checker.py
index ee21a45..7da1719 100644
--- a/checker/src/checker.py
+++ b/checker/src/checker.py
@@ -173,20 +173,22 @@ def leetify(clean: str) -> str:
return "".join([conv[c] if c in conv else c for c in out])
-def fakeid(havoc: bool = False) -> bytes:
+def fakeid(havoc: bool = False, minlen: int = 20, maxlen: int = 60) -> bytes:
if havoc:
- idlen = rand.randint(10, 40)
+ idlen = rand.randint(minlen, maxlen)
return bytes([rand.randint(32, 127) for i in range(idlen)])
else:
- words = []
- for i in range(rand.randint(2, 3)):
+ idstr = b""
+ while len(idstr) < minlen:
word = rand.choice(wordlist)
- words.append(leetify(word).encode() if randbool() else word.encode())
- return b"-".join(words)
+ if idstr != b"":
+ idstr += b"-"
+ idstr += leetify(word).encode() if randbool() else word.encode()
+ return idstr[:maxlen]
def fakeids(n: int, havoc: bool = False) -> list[bytes]:
- return [fakeid(havoc) for i in range(n)]
+ return [fakeid(havoc=havoc) for i in range(n)]
def approx_equal(f1: float, f2: float, precision: int = 2) -> bool:
@@ -1011,9 +1013,13 @@ async def havoc_fluff_upload(di: DependencyInjector) -> None:
if len(extra_models) == 0:
return
model = rand.choice(extra_models)
- modelname = os.path.basename(model).split("-")[0].encode()
- modelname += bytes([rand.choice(b"0123456789") for i in range(5)])
stlfile = open(model, "rb").read()
+ if model.endswith("-bin.stl"):
+ modelname = fakeid(minlen=15, maxlen=15)
+ stlfile = modelname + stlfile[15:] # replaces "OpenSCAD Model\n"
+ else:
+ modelname = fakeid()
+ stlfile = stlfile.replace(b"OpenSCAD_Model", modelname)
# Simple Upload
session = await di.get(Session)