enowars5-service-stldoctor

STL-Analyzing A/D Service for ENOWARS5 in 2021
git clone https://git.sinitax.com/sinitax/enowars5-service-stldoctor
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 45cd6b006e78faa12617ddcdf629967527a3f31d
parent 314ebbbd9e02b6c8c01554bd73ed9b1a7ce2d232
Author: Louis Burda <quent.burda@gmail.com>
Date:   Thu, 10 Jun 2021 22:48:25 +0200

improved logging

Diffstat:
Mchecker/src/checker.py | 36++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/checker/src/checker.py b/checker/src/checker.py @@ -55,11 +55,6 @@ class STLDoctorChecker(BaseChecker): prompt = b"$ " - def login_user(self, conn, password): - self.debug("Sending command to login.") - conn.write(f"login\n{password}\n") - conn.readline_expect(b"logged in!", recvuntil=self.prompt, exception_message="Failed to log in") - def openconn(self): conn = self.connect() resp = conn.recvuntil(self.prompt) @@ -83,6 +78,7 @@ class STLDoctorChecker(BaseChecker): def do_auth(self, conn, authstr): authstr = ensure_bytes(authstr) + self.debug(f"Logging in with {authstr}") conn.write("auth\n") conn.write(authstr + b"\n") resp = conn.recvuntil(self.prompt) @@ -92,16 +88,15 @@ class STLDoctorChecker(BaseChecker): modelid = ensure_bytes(modelid) conn.write("list\n") resp = conn.recvuntil(self.prompt) - assert_in(modelid, resp, f"Uploaded model is missing from list command") + assert_in(modelid, resp, f"Uploaded model {modelid} is missing from list command") def querydb(self, *args): - self.debug("Querying db contents"); vals = [] for arg in args: try: val: str = self.chain_db[arg] except KeyError as ex: - raise BrokenServiceException("Invalid db contents") + raise BrokenServiceException(f"Invalid db contents, missing: {arg}") vals.append(val) return vals @@ -176,22 +171,21 @@ class STLDoctorChecker(BaseChecker): stlfile = self.genfile(filetype, solidname) # Upload file - self.debug("Sending command to submit file") + self.debug(f"Uploading model with name {modelname}") conn.write("upload\n") conn.write(f"{len(stlfile)}\n") conn.write(stlfile) conn.write(modelname + b"\n") # Parse ID - self.debug(conn.recvline()) + _ = conn.recvline() line = conn.recvline() self.debug(line) try: modelid = line.rsplit(b"!", 1)[0].split(b"with ID ", 1)[1] if modelid == b"": raise Exception except: - raise BrokenServiceException("Invalid data returned on file upload") - self.debug(f"Uploaded file with name {modelid}") + raise BrokenServiceException(f"Invalid response during upload of {modelname}") # Consume rest of data in this call conn.recvuntil(self.prompt) @@ -202,7 +196,7 @@ class STLDoctorChecker(BaseChecker): modelname = ensure_bytes(modelname) # Initiate download - self.debug(f"Sending command to retrieve file with name {modelname}") + self.debug(f"Retrieving model with name {modelname}") conn.write("search\n") conn.write(modelname + b"\n") conn.write("0\n") # first result @@ -276,7 +270,7 @@ class STLDoctorChecker(BaseChecker): self.closeconn(conn) self.postdb(modelid=modelid, modelname=modelname, auth=authstr) else: - raise EnoException("Invalid variant_id provided") + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") def getflag(self): # type: () -> None if self.variant_id == 0: @@ -293,7 +287,7 @@ class STLDoctorChecker(BaseChecker): assert_in(self.flag.encode(), resp, "Flag not found in file info nor contents") self.closeconn(conn) else: - raise EnoException("Invalid variant_id provided") + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") def putnoise(self): # type: () -> None if self.variant_id == 0: @@ -313,7 +307,7 @@ class STLDoctorChecker(BaseChecker): self.closeconn(conn) self.postdb(modelid=modelid, modelname=modelname, solidname=solidname, contents=contents, auth=authstr) else: - raise EnoException("Invalid variant_id provided") + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") def getnoise(self): # type: () -> None if self.variant_id == 0: @@ -328,7 +322,7 @@ class STLDoctorChecker(BaseChecker): self.check_getfile(conn, modelname, solidname, contents, modelid) self.closeconn(conn) else: - raise EnoException("Invalid variant_id provided") + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") def havoc(self): # type: () -> None if self.variant_id == 0: @@ -340,7 +334,7 @@ class STLDoctorChecker(BaseChecker): elif self.variant_id == 3: self.havoc_upload('bin', True) else: - raise EnoException("Invalid variant_id provided"); + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") def exploit(self): # type: () -> None if self.variant_id == 0: @@ -355,7 +349,6 @@ class STLDoctorChecker(BaseChecker): # Parse evil file conn = self.openconn() resp = self.getfile(conn, name, download=False) - conn.write("search last\n") filelist = [l.strip().split(b" : ") for l in conn.recvuntil("?").split(b"\n") if b" : " in l] if len(filelist) == 0: raise BrokenServiceException("Failed to list files through search") @@ -401,11 +394,10 @@ class STLDoctorChecker(BaseChecker): user = self.reverse_hash(u.decode()) if user == b"": raise BrokenServiceException("Failed to find hash preimage") - self.debug(f"Hash preimage: {user}") conn.write(b"auth " + user + b"\n") resp = conn.recvuntil(self.prompt) if b"Welcome back" not in resp: - raise BrokenServiceException("Revhash returned invalid preimage") + raise BrokenServiceException(f"Reversing of hash {u} returned invalid preimage {user}") conn.write("list\n") resp = conn.recvuntil(self.prompt) names = b"\n".join([l.split(b": ", 1)[1] for l in resp.split(b"\n") if b"Solid Name: " in l]) @@ -418,7 +410,7 @@ class STLDoctorChecker(BaseChecker): raise BrokenServiceException("Exploit for flagstore 2 failed") return found else: - raise EnoException("Invalid variant_id provided") + raise EnoException(f"Invalid variant_id ({self.variant_id}) provided") app = STLDoctorChecker.service # This can be used for uswgi.