From e90104788f193dd2ac46bc5767276a40b244e425 Mon Sep 17 00:00:00 2001 From: 91c0e59d-6161-45ab-8aa4-2371574db28f <91c0e59d-6161-45ab-8aa4-2371574db28f@bankofchina.com> Date: Mon, 20 Jan 2025 14:11:28 +0800 Subject: [PATCH] feat: add felica fun to get accessCode by using felica id from aimedb. --- sdga/sdgb.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/sdga/sdgb.py b/sdga/sdgb.py index 20cfda3..e3b35c3 100644 --- a/sdga/sdgb.py +++ b/sdga/sdgb.py @@ -59,6 +59,7 @@ def sdgb_api(data, useApi, userId): data_def = zlib.compress(data) data_enc = aes.encrypt(data_def) endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/" + requests.packages.urllib3.disable_warnings() r = requests.post(endpoint + get_hash_api(useApi), headers={ "User-Agent": "%s#%d"%(get_hash_api(useApi), userId), "Content-Type": "application/json", @@ -75,12 +76,60 @@ def sdgb_api(data, useApi, userId): resp_def = resp_enc return zlib.decompress(resp_def).decode('utf-8') +def felica(IDm): + key = b'Copyright(C)SEGA' + # https://sega.bsnk.me/allnet/aimedb/common/ + magic = "3ea1" + version = "2140" + command_id = "0100" # ID = 1 + length = "3000" # 48 + gameId = "534447410000" # SDGA + storeId = "0c190000" + keychip_ID = "413633453031453030343800" # A63E01E0048 + header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID + + IDm = str(IDm) + PMm = "00F1000000014300" + + plaintext_hex_stream = header + IDm + PMm + + plaintext = unhexlify(plaintext_hex_stream) + + cipher = AES.new(key, AES.MODE_ECB) + encrypted_message = cipher.encrypt(plaintext) + + encrypted_hex_stream = hexlify(encrypted_message).decode('utf-8') + + server_address = ('aime.naominet.jp', 22345) + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + sock.connect(server_address) + sock.sendall(encrypted_message) + + response = sock.recv(1024) + + decrypted_response = cipher.decrypt(response) + + decrypted_hex_stream = hexlify(decrypted_response).decode('utf-8') + + return decrypted_hex_stream + def aimedb_api(accessCode): key = b'Copyright(C)SEGA' - base_hex_stream = "3ea121400f00300000005344474100000c190000413633453031453030343800" + # https://sega.bsnk.me/allnet/aimedb/common/ + magic = "3ea1" + version = "2140" + command_id = "0f00" # ID = 1 + length = "3000" # 48 + gameId = "534447410000" # SDGA + storeId = "0c190000" + keychip_ID = "413633453031453030343800" # A63E01E0048 + header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID + access_code = str(accessCode) end_stream = "000201020304" - plaintext_hex_stream = base_hex_stream + access_code + end_stream + + + plaintext_hex_stream = header + access_code + end_stream plaintext = unhexlify(plaintext_hex_stream)