From dce4d3a699a79920a8d8936a9910c4e815e68bb0 Mon Sep 17 00:00:00 2001 From: Usagi no Niku Date: Thu, 7 Dec 2023 16:56:44 +0000 Subject: [PATCH] fix: fix mistakes in merging anticheat --- app/api/domains/osu.py | 62 +++--------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/app/api/domains/osu.py b/app/api/domains/osu.py index 1d781833..8ec73cb9 100644 --- a/app/api/domains/osu.py +++ b/app/api/domains/osu.py @@ -721,63 +721,9 @@ async def osuSubmitModularSelector( ## perform checksum validation - unique_id1, unique_id2 = unique_ids.split("|", maxsplit=1) - unique_id1_md5 = hashlib.md5(unique_id1.encode()).hexdigest() - unique_id2_md5 = hashlib.md5(unique_id2.encode()).hexdigest() - - try: - assert player.client_details is not None - - bypass_client_check = ( - player.client_details.osu_version.stream == OsuStream.PPYSB - ) # ppysb feature - - if not bypass_client_check: - if osu_version != f"{player.client_details.osu_version.date:%Y%m%d}": - raise ValueError("osu! version mismatch") - - if client_hash_decoded != player.client_details.client_hash: - raise ValueError("client hash mismatch") - # assert unique ids (c1) are correct and match login params - if unique_id1_md5 != player.client_details.uninstall_md5: - raise ValueError( - f"unique_id1 mismatch ({unique_id1_md5} != {player.client_details.uninstall_md5})", - ) - - if unique_id2_md5 != player.client_details.disk_signature_md5: - raise ValueError( - f"unique_id2 mismatch ({unique_id2_md5} != {player.client_details.disk_signature_md5})", - ) - - # assert online checksums match - server_score_checksum = score.compute_online_checksum( - osu_version=osu_version, - osu_client_hash=client_hash_decoded, - storyboard_checksum=storyboard_md5 or "", - ) - if score.client_checksum != server_score_checksum: - raise ValueError( - f"online score checksum mismatch ({server_score_checksum} != {score.client_checksum})", - ) - - # assert beatmap hashes match - if bmap_md5 != updated_beatmap_hash: - raise ValueError( - f"beatmap hash mismatch ({bmap_md5} != {updated_beatmap_hash})", - ) - - except (ValueError, AssertionError) as error: - if error.args.count == 1: - await player.restrict( - admin=app.state.sessions.bot, - reason=error.args[0], - ) - - # refresh their client state - if player.online: - player.logout() - - return b"error: ban" + asyncio.ensure_future( + anticheat.validate_checksum(unique_ids, osu_version, client_hash_decoded, storyboard_md5, bmap_md5, updated_beatmap_hash, player, score) + ) # we should update their activity no matter # what the result of the score submission is. @@ -973,7 +919,7 @@ async def osuSubmitModularSelector( score.player.logout() # suspect the score after the replay file written - await score.check_suspicion() + asyncio.ensure_future(anticheat.check_suspicion(player, score)) """ Update the user's & beatmap's stats """