feat: add felica fun to get accessCode by using felica id from aimedb.
This commit is contained in:
parent
5d1fcaeca2
commit
e90104788f
53
sdga/sdgb.py
53
sdga/sdgb.py
@ -59,6 +59,7 @@ def sdgb_api(data, useApi, userId):
|
|||||||
data_def = zlib.compress(data)
|
data_def = zlib.compress(data)
|
||||||
data_enc = aes.encrypt(data_def)
|
data_enc = aes.encrypt(data_def)
|
||||||
endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/"
|
endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/"
|
||||||
|
requests.packages.urllib3.disable_warnings()
|
||||||
r = requests.post(endpoint + get_hash_api(useApi), headers={
|
r = requests.post(endpoint + get_hash_api(useApi), headers={
|
||||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -75,12 +76,60 @@ def sdgb_api(data, useApi, userId):
|
|||||||
resp_def = resp_enc
|
resp_def = resp_enc
|
||||||
return zlib.decompress(resp_def).decode('utf-8')
|
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):
|
def aimedb_api(accessCode):
|
||||||
key = b'Copyright(C)SEGA'
|
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)
|
access_code = str(accessCode)
|
||||||
end_stream = "000201020304"
|
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)
|
plaintext = unhexlify(plaintext_hex_stream)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user