@@ -68,13 +68,13 @@ async def login(self, username, password):
6868 )
6969 self .logger .info (f"[login] status={ resp .status_code } , body={ resp .text } " )
7070 if resp .status_code != 200 :
71- raise MumbleException (f"Login failed for user, status= { resp . status_code } " )
71+ raise MumbleException (f"Login failed. " )
7272 try :
7373 data = resp .json ()
7474 except Exception as e :
75- raise MumbleException (f"Login did not return JSON for user, error= { e } " )
75+ raise MumbleException (f"Login did not return JSON for user" )
7676 if "access_token" not in data :
77- raise MumbleException (f"Login did not return access_token for user " )
77+ raise MumbleException (f"Login was not successful (Token missing) " )
7878 token = data ["access_token" ]
7979 self .logger .info (f"[login] access_token={ token [:8 ]} ..." )
8080 return token
@@ -95,9 +95,9 @@ async def open_lootbox_and_get_item(self, token):
9595 try :
9696 item = resp .json ()
9797 except Exception as e :
98- raise MumbleException (f"Failed to decode item as JSON after opening lootbox: { e } " )
98+ raise MumbleException ("Fetching Item failed " )
9999 if "id" not in item :
100- raise MumbleException (f "Returned item missing 'id' field " )
100+ raise MumbleException ("Returned Item is incomplete " )
101101 return item
102102
103103 async def set_item_note (self , token , item_id , note ):
@@ -109,7 +109,7 @@ async def set_item_note(self, token, item_id, note):
109109 )
110110 self .logger .info (f"[set_item_note] status={ resp .status_code } , body={ resp .text } " )
111111 if resp .status_code != 200 :
112- raise MumbleException (f"Failed to set note for item { item_id } (status={ resp .status_code } )" )
112+ raise MumbleException (f"Failed saving Note (status={ resp .status_code } )" )
113113 return resp .json ()
114114
115115 async def get_own_items (self , token , raise_on_error = True ):
@@ -121,13 +121,13 @@ async def get_own_items(self, token, raise_on_error=True):
121121 self .logger .info (f"[get_own_items] status={ resp .status_code } , body={ resp .text } " )
122122 if resp .status_code != 200 :
123123 if raise_on_error :
124- raise MumbleException (f"Failed to get items (status={ resp .status_code } )" )
124+ raise MumbleException (f"Failed to fetch User Data (status={ resp .status_code } )" )
125125 return []
126126 try :
127127 data = resp .json ()
128128 except Exception as e :
129129 if raise_on_error :
130- raise MumbleException (f"Failed to decode items as JSON: { e } " )
130+ raise MumbleException ("Decode failed unexpectedly " )
131131 return []
132132 if isinstance (data , dict ) and "items" in data :
133133 return data ["items" ]
@@ -175,7 +175,7 @@ async def upload_image(self, token, flag):
175175 if process .returncode != 0 :
176176 error_message = stderr .decode ()
177177 self .logger .error (f"Steghide error: { error_message } " )
178- raise MumbleException (f"Steghide failed: { error_message } " )
178+ raise MumbleException (f"Failed doing crazy stuff " )
179179
180180 async with aiofiles .open (steghide_img_path , "rb" ) as f :
181181 files = {"file" : ("stegano.jpg" , await f .read (), "image/jpeg" )}
@@ -186,7 +186,7 @@ async def upload_image(self, token, flag):
186186 )
187187 self .logger .info (f"[upload_image] status={ resp .status_code } , body={ resp .text } " )
188188 if resp .status_code != 201 :
189- raise MumbleException (f"Failed to upload image (status= { resp . status_code } ) " )
189+ raise MumbleException (f"Upload failed unexpectedly " )
190190 return resp .json ()
191191 finally :
192192 await loop .run_in_executor (None , safe_unlink , flagfile_path , self .logger )
@@ -225,11 +225,17 @@ async def extract_flag_from_image(self, image_path):
225225 stdout = asyncio .subprocess .PIPE ,
226226 stderr = asyncio .subprocess .PIPE
227227 )
228- stdout , stderr = await process .communicate ()
228+ try :
229+ stdout , stderr = await asyncio .wait_for (process .communicate (), timeout = 5 )
230+ except asyncio .TimeoutError :
231+ process .kill ()
232+ await process .wait ()
233+ self .logger .error ("Steghide extract timed out!" )
234+ raise MumbleException ("Extraction timed out!" )
229235
230236 if process .returncode != 0 :
231237 self .logger .error (f"Steghide Fehler: { stderr .decode ()} " )
232- raise MumbleException (f"Steghide extract failed: { stderr . decode () } " )
238+ raise MumbleException (f"Extraction failed.. " )
233239
234240 async with aiofiles .open (flagfile_path , "r" ) as f :
235241 extracted_flag = await f .read ()
@@ -342,7 +348,7 @@ async def putflag_note(
342348):
343349 logger .info (f"Putflag 0 { client .base_url } " )
344350 con = Connection (logger , client )
345- password = "CascwTdwsaj"
351+ password = rand_str ( 12 )
346352 flag = task .flag
347353
348354 for _ in range (3 ):
@@ -369,8 +375,8 @@ async def putflag_note(
369375 logger .info (f"[putflag_note({ task .variant_id } )] Returning attack_info: { username } (len={ len (username )} )" )
370376 return username
371377 except Exception as e :
372- logger .exception ("Exception in putflag_note" )
373- raise MumbleException (f "Putflag failed for user: { e } " ) from e
378+ logger .exception (f "Exception in putflag_note: { e } " )
379+ raise MumbleException ("Putflag 1 failed." )
374380
375381
376382@checker .getflag (0 )
@@ -388,7 +394,7 @@ async def getflag_note(
388394 item_id = db_data ["item_id" ]
389395 except Exception as e :
390396 logger .error (f"No data from putflag in DB for chain_id={ task .task_chain_id } : { e } " )
391- raise MumbleException (f "No data from putflag for chain_id= { task . task_chain_id :8 } " )
397+ raise MumbleException ("No data from Putflag 1 " )
392398
393399 flag = task .flag
394400 logger .info (f"Getflag: Loaded db_data={ db_data } " )
@@ -404,17 +410,17 @@ async def getflag_note(
404410 logger .error (f"Flag NOT found on expected item. Searched for item_id={ item_id } with flag={ flag [:5 ]} " )
405411 notes_seen = [(it .get ('id' ), it .get ('note' , '' )) for it in items ]
406412 logger .error (f"Items/notes seen: { notes_seen } " )
407- assert_equals (False , True , f "Flag not found on item (expected id= { item_id } , flag= { flag } )" )
413+ assert_equals (False , True , "Flag not found on item)" )
408414
409415 note_val = item .get ("note" , "" )
410416 logger .info (f"[getflag] Found item_id={ item_id } with note={ note_val [:5 ]} " )
411417 if note_val != flag :
412418 logger .error (f"Note mismatch: expected flag={ flag } , got note={ note_val } " )
413- assert_equals (note_val , flag , f"Flag not found on item (expected id= { item_id } , flag= { flag } ) " )
419+ assert_equals (note_val , flag , f"Flag not found on item" )
414420 logger .info ("[getflag] Flag successfully found in user items." )
415421 except Exception as e :
416- logger .exception ("Exception in getflag_note" )
417- raise MumbleException (f "Getflag failed for user, item_id= { item_id :4 } : { e } " ) from e
422+ logger .exception (f "Exception in getflag_note item_id= { item_id :4 } : { e } " )
423+ raise MumbleException ("Getflag 1 failed." )
418424
419425
420426@checker .putnoise (0 )
@@ -444,7 +450,7 @@ async def putnoise_note(
444450 logger .info (f"[putnoise] Stored noise data: user={ username } , item={ item ['id' ]} " )
445451 except Exception as e :
446452 logger .exception ("Exception in putnoise_note" )
447- raise MumbleException (f "Putnoise failed for user, item_id=UNKNOWN: { e } " ) from e
453+ raise MumbleException ("Putnoise 1 failed unexpectedly" )
448454
449455
450456@checker .getnoise (0 )
@@ -463,7 +469,7 @@ async def getnoise_note(
463469 note = db_data ["note" ]
464470 except Exception as e :
465471 logger .error (f"No data from putnoise in DB: { e } " )
466- raise MumbleException ("No data from putnoise in DB" )
472+ raise MumbleException ("No data from Putnoise 1 in DB" )
467473 logger .info (f"[getnoise] DB loaded: username={ username } , item_id={ item_id } , note={ note [:5 ]} " )
468474 con = Connection (logger , client )
469475 try :
@@ -477,11 +483,11 @@ async def getnoise_note(
477483 notes_seen = [(it .get ('id' ), it .get ('note' , '' )) for it in items ]
478484 logger .error (
479485 f"[getnoise] Noise NOT found: expected item_id={ item_id } with note={ note [:5 ]} . Items/notes seen: { notes_seen } " )
480- assert_equals (found , True , f"Noise note not found (expect: id= { item_id } , note= { note } ) " )
486+ assert_equals (found , True , f"Noise note not found" )
481487 logger .info ("[getnoise] Noise note found successfully." )
482488 except Exception as e :
483- logger .exception ("Exception in getnoise_note" )
484- raise MumbleException (f"Getnoise failed for user, item_id= { item_id } : { e } " ) from e
489+ logger .exception (f "Exception in getnoise_note for user, item_id= { item_id } : { e } " )
490+ raise MumbleException (f"Getnoise 1 failed." )
485491
486492
487493@checker .exploit (0 )
@@ -525,7 +531,7 @@ async def exploit_note(
525531 return None
526532 except Exception as ex :
527533 logger .error (f"[exploit] Error while trying collision on username={ username } : { ex } " )
528- raise MumbleException (f"[exploit] Error while trying collision on user: { ex } " )
534+ raise MumbleException (f"[exploit] Error while trying collision on user" )
529535
530536
531537#####################################################
@@ -543,7 +549,7 @@ async def putflag_image(
543549 logger .info (f"Putflag 1 { client .base_url } " )
544550 con = Connection (logger , client )
545551 usern = rand_str (8 )
546- password = "CascwTdwsaj"
552+ password = rand_str ( 8 )
547553 flag = task .flag
548554
549555 try :
@@ -567,7 +573,7 @@ async def putflag_image(
567573 return usern
568574 except Exception as ex :
569575 logger .error (f"[putflag(1)] Error while trying upload image: { ex } " )
570- raise MumbleException (f"[putflag(1)] Error while trying to upload image: { ex } " )
576+ raise MumbleException (f"Putflag 2 Failed " )
571577
572578
573579@checker .getflag (1 )
@@ -585,7 +591,7 @@ async def getflag_image(
585591 filename = db_data ["filename" ]
586592 except Exception as e :
587593 logger .error (f"No data from putflag in DB for chain_id={ task .task_chain_id } : { e } " )
588- raise MumbleException (f"No data from putflag for chain_id= { task . task_chain_id :8 } " )
594+ raise MumbleException (f"No data from Putflag 2 found " )
589595
590596 logger .info (f"Getflag: Loaded db_data={ db_data } " )
591597 con = Connection (logger , client )
@@ -595,14 +601,14 @@ async def getflag_image(
595601
596602 if not img_path :
597603 logger .exception ("File not found" )
598- raise MumbleException (f"Getflag failed for user: File Not found " )
604+ raise MumbleException (f"Getflag 2 faied " )
599605 flag = await con .extract_flag_from_image (img_path )
600- assert_equals (task .flag , flag , f"Extracted flag does not match! Expected { task . flag } , got { flag } " )
606+ assert_equals (task .flag , flag , f"Extracted flag does not match!" )
601607 logger .info (f'Successfully got flag 1 { task .flag [:8 ]} ' )
602608
603609 except Exception as e :
604- logger .exception ("Exception in getflag_image" )
605- raise MumbleException (f "Getflag failed for user: { e } " ) from e
610+ logger .exception (f "Exception in getflag_image: { e } " )
611+ raise MumbleException ("Getflag 2 failed.." )
606612
607613
608614@checker .putnoise (1 )
@@ -615,7 +621,7 @@ async def putnoise_image(
615621 logger .info (f"PutNoise 1 { client .base_url } " )
616622 con = Connection (logger , client )
617623 username = rand_str (8 )
618- password = "CascwTdwsaj"
624+ password = rand_str ( 8 )
619625 flag = rand_str (32 )
620626
621627 try :
@@ -637,7 +643,7 @@ async def putnoise_image(
637643 })
638644 except Exception as ex :
639645 logger .error (f"[putnoise(1)] Error while trying upload image: { ex } " )
640- raise MumbleException (f"[putnoise(1)] Error while trying to put noise" )
646+ raise MumbleException (f"Putnoise 2 Failed: Error while trying to put noise" )
641647
642648
643649@checker .getnoise (1 )
@@ -651,12 +657,12 @@ async def getnoise_image(
651657 try :
652658 db_data = await db .get (f"userdata" )
653659 username = db_data ["username" ]
654- password = "CascwTdwsaj"
660+ password = db_data [ "password" ]
655661 filename = db_data ["filename" ]
656662 noise = db_data ["noise" ]
657663 except Exception as e :
658664 logger .error (f"No data from putnoise in DB: { e } " )
659- raise MumbleException (f"No data from putnoise " )
665+ raise MumbleException (f"No data from Putnoise 2 found " )
660666
661667 logger .info (f"Getnoise: Loaded db_data={ db_data } " )
662668 con = Connection (logger , client )
@@ -666,14 +672,14 @@ async def getnoise_image(
666672
667673 if not img_path :
668674 logger .exception ("File not found" )
669- raise MumbleException (f"iGetnoise failed for user: File Not found " )
675+ raise MumbleException (f"Getnoise 2 Failed. Not Found. " )
670676 flag = await con .extract_flag_from_image (img_path )
671677 assert_equals (noise , flag , f"Extracted noise does not match!" )
672678 logger .info (f'Successfully got noise 1' )
673679
674680 except Exception as e :
675- logger .exception ("Exception in getnoise_image" )
676- raise MumbleException (f"iGetnoise failed for user: { e } " ) from e
681+ logger .exception (f "Exception in getnoise_image: { e } " )
682+ raise MumbleException (f"Getnoise 2 Failed" )
677683
678684
679685@checker .exploit (1 )
@@ -781,12 +787,12 @@ async def havoc(
781787 failed = True
782788
783789 if not failed :
784- raise MumbleException ("Havoc: User was able to open more than 2 lootboxes (limit not enforced)" )
790+ raise MumbleException ("Havoc 1 Failed (limit not enforced)" )
785791
786792 logger .info (f"[havoc] Havoc check successful for user={ username } " )
787793 except Exception as e :
788- logger .exception ("Exception in havoc" )
789- raise MumbleException (f"Havoc failed: { e } " ) from e
794+ logger .exception (f "Exception in havoc { e } " )
795+ raise MumbleException (f"Havoc 1 failed" )
790796
791797
792798if __name__ == "__main__" :
0 commit comments