Skip to content

Commit

Permalink
fix: fix mistakes in merging anticheat
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueRou committed Dec 7, 2023
1 parent 282d3b9 commit dce4d3a
Showing 1 changed file with 4 additions and 58 deletions.
62 changes: 4 additions & 58 deletions app/api/domains/osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 """

Expand Down

0 comments on commit dce4d3a

Please sign in to comment.