3
2
forked from Dniel97/artemis

sao: parse header. add crypt

This commit is contained in:
Hay1tsme 2023-11-09 13:16:32 -05:00
parent 8560c05928
commit b0ebcaf0cf
2 changed files with 103 additions and 82 deletions

View File

@ -5,10 +5,18 @@ import sys
import csv import csv
from csv import * from csv import *
class SaoBaseRequest: class SaoRequestHeader:
def __init__(self, data: bytes) -> None: def __init__(self, data: bytes) -> None:
self.cmd = struct.unpack_from("!H", bytes)[0] collection = struct.unpack_from("!HIIIs16", data)
# TODO: The rest of the request header self.cmd: int = collection[0]
self.vendor_id: int = collection[1]
self.game_id: int = collection[2]
self.version_id: int = collection[3]
self.checksum: str = collection[4]
class SaoBaseRequest:
def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
self.header = header
class SaoBaseResponse: class SaoBaseResponse:
def __init__(self, cmd_id: int) -> None: def __init__(self, cmd_id: int) -> None:
@ -33,8 +41,8 @@ class SaoNoopResponse(SaoBaseResponse):
return super().make() + struct.pack("!bI", self.result, 0) return super().make() + struct.pack("!bI", self.result, 0)
class SaoGetMaintRequest(SaoBaseRequest): class SaoGetMaintRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
# TODO: The rest of the mait info request # TODO: The rest of the mait info request
class SaoGetMaintResponse(SaoBaseResponse): class SaoGetMaintResponse(SaoBaseResponse):
@ -68,8 +76,8 @@ class SaoGetMaintResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCommonAcCabinetBootNotificationRequest(SaoBaseRequest): class SaoCommonAcCabinetBootNotificationRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCommonAcCabinetBootNotificationResponse(SaoBaseResponse): class SaoCommonAcCabinetBootNotificationResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -90,8 +98,8 @@ class SaoCommonAcCabinetBootNotificationResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoMasterDataVersionCheckRequest(SaoBaseRequest): class SaoMasterDataVersionCheckRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoMasterDataVersionCheckResponse(SaoBaseResponse): class SaoMasterDataVersionCheckResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -118,8 +126,8 @@ class SaoMasterDataVersionCheckResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCommonGetAppVersionsRequest(SaoBaseRequest): class SaoCommonGetAppVersionsRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCommonGetAppVersionsRequest(SaoBaseResponse): class SaoCommonGetAppVersionsRequest(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -154,8 +162,8 @@ class SaoCommonGetAppVersionsRequest(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCommonPayingPlayStartRequest(SaoBaseRequest): class SaoCommonPayingPlayStartRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCommonPayingPlayStartRequest(SaoBaseResponse): class SaoCommonPayingPlayStartRequest(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -181,8 +189,8 @@ class SaoCommonPayingPlayStartRequest(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetAuthCardDataRequest(SaoBaseRequest): class SaoGetAuthCardDataRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetAuthCardDataResponse(SaoBaseResponse): #GssSite.dll / GssSiteSystem / GameConnectProt / public class get_auth_card_data_R : GameConnect.GssProtocolBase class SaoGetAuthCardDataResponse(SaoBaseResponse): #GssSite.dll / GssSiteSystem / GameConnectProt / public class get_auth_card_data_R : GameConnect.GssProtocolBase
def __init__(self, cmd, profile_data) -> None: def __init__(self, cmd, profile_data) -> None:
@ -225,8 +233,8 @@ class SaoGetAuthCardDataResponse(SaoBaseResponse): #GssSite.dll / GssSiteSystem
return super().make() + resp_data return super().make() + resp_data
class SaoHomeCheckAcLoginBonusRequest(SaoBaseRequest): class SaoHomeCheckAcLoginBonusRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoHomeCheckAcLoginBonusResponse(SaoBaseResponse): class SaoHomeCheckAcLoginBonusResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -262,8 +270,8 @@ class SaoHomeCheckAcLoginBonusResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetQuestSceneMultiPlayPhotonServerRequest(SaoBaseRequest): class SaoGetQuestSceneMultiPlayPhotonServerRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetQuestSceneMultiPlayPhotonServerResponse(SaoBaseResponse): class SaoGetQuestSceneMultiPlayPhotonServerResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -289,8 +297,8 @@ class SaoGetQuestSceneMultiPlayPhotonServerResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoTicketRequest(SaoBaseRequest): class SaoTicketRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoTicketResponse(SaoBaseResponse): class SaoTicketResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -318,8 +326,8 @@ class SaoTicketResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCommonLoginRequest(SaoBaseRequest): class SaoCommonLoginRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCommonLoginResponse(SaoBaseResponse): class SaoCommonLoginResponse(SaoBaseResponse):
def __init__(self, cmd, profile_data) -> None: def __init__(self, cmd, profile_data) -> None:
@ -362,8 +370,8 @@ class SaoCommonLoginResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCheckComebackEventRequest(SaoBaseRequest): class SaoCheckComebackEventRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCheckComebackEventRequest(SaoBaseResponse): class SaoCheckComebackEventRequest(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -392,8 +400,8 @@ class SaoCheckComebackEventRequest(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetUserBasicDataRequest(SaoBaseRequest): class SaoGetUserBasicDataRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetUserBasicDataResponse(SaoBaseResponse): class SaoGetUserBasicDataResponse(SaoBaseResponse):
def __init__(self, cmd, profile_data) -> None: def __init__(self, cmd, profile_data) -> None:
@ -476,8 +484,8 @@ class SaoGetUserBasicDataResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetHeroLogUserDataListRequest(SaoBaseRequest): class SaoGetHeroLogUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetHeroLogUserDataListResponse(SaoBaseResponse): class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, hero_data) -> None: def __init__(self, cmd, hero_data) -> None:
@ -654,8 +662,8 @@ class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetEquipmentUserDataListRequest(SaoBaseRequest): class SaoGetEquipmentUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetEquipmentUserDataListResponse(SaoBaseResponse): class SaoGetEquipmentUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, equipment_data) -> None: def __init__(self, cmd, equipment_data) -> None:
@ -810,8 +818,8 @@ class SaoGetEquipmentUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetItemUserDataListRequest(SaoBaseRequest): class SaoGetItemUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetItemUserDataListResponse(SaoBaseResponse): class SaoGetItemUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, item_data) -> None: def __init__(self, cmd, item_data) -> None:
@ -874,8 +882,8 @@ class SaoGetItemUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetSupportLogUserDataListRequest(SaoBaseRequest): class SaoGetSupportLogUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetSupportLogUserDataListResponse(SaoBaseResponse): class SaoGetSupportLogUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, supportIdsData) -> None: def __init__(self, cmd, supportIdsData) -> None:
@ -945,8 +953,8 @@ class SaoGetSupportLogUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetTitleUserDataListRequest(SaoBaseRequest): class SaoGetTitleUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetTitleUserDataListResponse(SaoBaseResponse): class SaoGetTitleUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, titleIdsData) -> None: def __init__(self, cmd, titleIdsData) -> None:
@ -993,8 +1001,8 @@ class SaoGetTitleUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetEpisodeAppendDataListRequest(SaoBaseRequest): class SaoGetEpisodeAppendDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetEpisodeAppendDataListResponse(SaoBaseResponse): class SaoGetEpisodeAppendDataListResponse(SaoBaseResponse):
def __init__(self, cmd, profile_data) -> None: def __init__(self, cmd, profile_data) -> None:
@ -1051,8 +1059,8 @@ class SaoGetEpisodeAppendDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetPartyDataListRequest(SaoBaseRequest): class SaoGetPartyDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetPartyDataListResponse(SaoBaseResponse): # Default party class SaoGetPartyDataListResponse(SaoBaseResponse): # Default party
def __init__(self, cmd, hero1_data, hero2_data, hero3_data) -> None: def __init__(self, cmd, hero1_data, hero2_data, hero3_data) -> None:
@ -1215,8 +1223,8 @@ class SaoGetPartyDataListResponse(SaoBaseResponse): # Default party
return super().make() + resp_data return super().make() + resp_data
class SaoGetQuestScenePrevScanProfileCardRequest(SaoBaseRequest): class SaoGetQuestScenePrevScanProfileCardRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetQuestScenePrevScanProfileCardResponse(SaoBaseResponse): class SaoGetQuestScenePrevScanProfileCardResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1352,8 +1360,8 @@ class SaoGetQuestScenePrevScanProfileCardResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetResourcePathInfoRequest(SaoBaseRequest): class SaoGetResourcePathInfoRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetResourcePathInfoResponse(SaoBaseResponse): class SaoGetResourcePathInfoResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1394,8 +1402,8 @@ class SaoGetResourcePathInfoResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoEpisodePlayStartRequest(SaoBaseRequest): class SaoEpisodePlayStartRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoEpisodePlayStartResponse(SaoBaseResponse): class SaoEpisodePlayStartResponse(SaoBaseResponse):
def __init__(self, cmd, profile_data) -> None: def __init__(self, cmd, profile_data) -> None:
@ -1441,8 +1449,8 @@ class SaoEpisodePlayStartResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoEpisodePlayEndRequest(SaoBaseRequest): class SaoEpisodePlayEndRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoEpisodePlayEndResponse(SaoBaseResponse): class SaoEpisodePlayEndResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1529,8 +1537,8 @@ class SaoEpisodePlayEndResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoTrialTowerPlayEndRequest(SaoBaseRequest): class SaoTrialTowerPlayEndRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoTrialTowerPlayEndResponse(SaoBaseResponse): class SaoTrialTowerPlayEndResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1655,8 +1663,8 @@ class SaoTrialTowerPlayEndResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoEpisodePlayEndUnanalyzedLogFixedRequest(SaoBaseRequest): class SaoEpisodePlayEndUnanalyzedLogFixedRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoEpisodePlayEndUnanalyzedLogFixedResponse(SaoBaseResponse): class SaoEpisodePlayEndUnanalyzedLogFixedResponse(SaoBaseResponse):
def __init__(self, cmd, end_session_data) -> None: def __init__(self, cmd, end_session_data) -> None:
@ -1735,8 +1743,8 @@ class SaoEpisodePlayEndUnanalyzedLogFixedResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetQuestSceneUserDataListRequest(SaoBaseRequest): class SaoGetQuestSceneUserDataListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetQuestSceneUserDataListResponse(SaoBaseResponse): class SaoGetQuestSceneUserDataListResponse(SaoBaseResponse):
def __init__(self, cmd, quest_data) -> None: def __init__(self, cmd, quest_data) -> None:
@ -1844,8 +1852,8 @@ class SaoGetQuestSceneUserDataListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCheckYuiMedalGetConditionRequest(SaoBaseRequest): class SaoCheckYuiMedalGetConditionRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCheckYuiMedalGetConditionResponse(SaoBaseResponse): class SaoCheckYuiMedalGetConditionResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1875,8 +1883,8 @@ class SaoCheckYuiMedalGetConditionResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetYuiMedalBonusUserDataRequest(SaoBaseRequest): class SaoGetYuiMedalBonusUserDataRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetYuiMedalBonusUserDataResponse(SaoBaseResponse): class SaoGetYuiMedalBonusUserDataResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1920,8 +1928,8 @@ class SaoGetYuiMedalBonusUserDataResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoCheckProfileCardUsedRewardRequest(SaoBaseRequest): class SaoCheckProfileCardUsedRewardRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoCheckProfileCardUsedRewardResponse(SaoBaseResponse): class SaoCheckProfileCardUsedRewardResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -1952,8 +1960,8 @@ class SaoCheckProfileCardUsedRewardResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoSynthesizeEnhancementHeroLogRequest(SaoBaseRequest): class SaoSynthesizeEnhancementHeroLogRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoSynthesizeEnhancementHeroLogResponse(SaoBaseResponse): class SaoSynthesizeEnhancementHeroLogResponse(SaoBaseResponse):
def __init__(self, cmd, hero_data) -> None: def __init__(self, cmd, hero_data) -> None:
@ -2107,8 +2115,8 @@ class SaoSynthesizeEnhancementHeroLogResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoSynthesizeEnhancementEquipment(SaoBaseRequest): class SaoSynthesizeEnhancementEquipment(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoSynthesizeEnhancementEquipmentResponse(SaoBaseResponse): class SaoSynthesizeEnhancementEquipmentResponse(SaoBaseResponse):
def __init__(self, cmd, synthesize_equipment_data) -> None: def __init__(self, cmd, synthesize_equipment_data) -> None:
@ -2244,8 +2252,8 @@ class SaoSynthesizeEnhancementEquipmentResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetDefragMatchBasicDataRequest(SaoBaseRequest): class SaoGetDefragMatchBasicDataRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetDefragMatchBasicDataResponse(SaoBaseResponse): class SaoGetDefragMatchBasicDataResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -2291,8 +2299,8 @@ class SaoGetDefragMatchBasicDataResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetDefragMatchRankingUserDataRequest(SaoBaseRequest): class SaoGetDefragMatchRankingUserDataRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetDefragMatchRankingUserDataResponse(SaoBaseResponse): class SaoGetDefragMatchRankingUserDataResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -2351,8 +2359,8 @@ class SaoGetDefragMatchRankingUserDataResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetDefragMatchLeaguePointRankingListRequest(SaoBaseRequest): class SaoGetDefragMatchLeaguePointRankingListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetDefragMatchLeaguePointRankingListResponse(SaoBaseResponse): class SaoGetDefragMatchLeaguePointRankingListResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -2423,8 +2431,8 @@ class SaoGetDefragMatchLeaguePointRankingListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoGetDefragMatchLeagueScoreRankingListRequest(SaoBaseRequest): class SaoGetDefragMatchLeagueScoreRankingListRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoGetDefragMatchLeagueScoreRankingListResponse(SaoBaseResponse): class SaoGetDefragMatchLeagueScoreRankingListResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -2495,8 +2503,8 @@ class SaoGetDefragMatchLeagueScoreRankingListResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoBnidSerialCodeCheckRequest(SaoBaseRequest): class SaoBnidSerialCodeCheckRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoBnidSerialCodeCheckResponse(SaoBaseResponse): class SaoBnidSerialCodeCheckResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:
@ -2526,8 +2534,8 @@ class SaoBnidSerialCodeCheckResponse(SaoBaseResponse):
return super().make() + resp_data return super().make() + resp_data
class SaoScanQrQuestProfileCardRequest(SaoBaseRequest): class SaoScanQrQuestProfileCardRequest(SaoBaseRequest):
def __init__(self, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(data) super().__init__(header, data)
class SaoScanQrQuestProfileCardResponse(SaoBaseResponse): class SaoScanQrQuestProfileCardResponse(SaoBaseResponse):
def __init__(self, cmd) -> None: def __init__(self, cmd) -> None:

View File

@ -87,17 +87,30 @@ class SaoServlet(BaseServlet):
endpoint = matchers.get('endpoint', '') endpoint = matchers.get('endpoint', '')
request.responseHeaders.addRawHeader(b"content-type", b"text/html; charset=utf-8") request.responseHeaders.addRawHeader(b"content-type", b"text/html; charset=utf-8")
sao_request = request.content.getvalue().hex() req_raw = request.content.read()
sao_request = req_raw.hex()
req_header = SaoRequestHeader(req_raw)
cmd_str = f"{req_header.cmd:04x}"
if self.game_cfg.crypt.enable:
iv = req_raw[30:38]
cipher = Blowfish.new(self.game_cfg.crypt.key, Blowfish.MODE_CBC, iv)
crypt_data = req_raw[38:]
req_data = cipher.decrypt(crypt_data)
else:
req_data = req_raw[30:]
handler = getattr(self.base, f"handle_{sao_request[:4]}", None) handler = getattr(self.base, f"handle_{cmd_str}", None)
if handler is None: if handler is None:
self.logger.info(f"Generic Handler for {endpoint} - {sao_request[:4]}") self.logger.info(f"Generic Handler for {endpoint} - {cmd_str}")
self.logger.debug(f"Request: {request.content.getvalue().hex()}") self.logger.debug(f"Request: {request.content.getvalue().hex()}")
resp = SaoNoopResponse(int.from_bytes(bytes.fromhex(sao_request[:4]), "big")+1) resp = SaoNoopResponse(req_header.cmd + 1)
self.logger.debug(f"Response: {resp.make().hex()}") self.logger.debug(f"Response: {resp.make().hex()}")
return resp.make() return resp.make()
self.logger.info(f"Handler {endpoint} - {sao_request[:4]} request") self.logger.info(f"Handler {endpoint} - {cmd_str} request")
self.logger.debug(f"Request: {request.content.getvalue().hex()}") self.logger.debug(f"Request: {request.content.getvalue().hex()}")
resp = handler(sao_request) resp = handler(sao_request)
self.logger.debug(f"Response: {resp.hex()}") self.logger.debug(f"Response: {resp.hex()}")