bump sdga key and title api header to latest 1.55 & add mifare kind aimedb request (command id 15)
This commit is contained in:
67
sdga/sdgb.py
67
sdga/sdgb.py
@@ -12,9 +12,14 @@ from datetime import datetime
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
|
||||
AesKey = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
||||
AesIV = "9FM:sd9xA91X14v]"
|
||||
ObfuscateParam = "M9aBNKuY"
|
||||
# Key 1.50
|
||||
# AesKey = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
||||
# AesIV = "9FM:sd9xA91X14v]"
|
||||
# ObfuscateParam = "M9aBNKuY"
|
||||
|
||||
AesKey = "Z6@9UJ@U79^4TH7H^7Pd25Z@;YiIZS9Z"
|
||||
AesIV = "f@FTcYHXVGYLM5UK"
|
||||
ObfuscateParam = "X7eBJcEU"
|
||||
|
||||
class aes_pkcs7(object):
|
||||
def __init__(self, key: str, iv: str):
|
||||
@@ -62,13 +67,14 @@ def sdgb_api(data, useApi, userId):
|
||||
headers = {
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
"Content-Type": "application/json",
|
||||
"Mai-Encoding": "1.51",
|
||||
"Mai-Encoding": "1.55",
|
||||
"Accept-Encoding": "",
|
||||
"Charset": "UTF-8",
|
||||
"Content-Encoding": "deflate",
|
||||
"Expect": "100-continue"
|
||||
"Content-Encoding": "deflate"
|
||||
},
|
||||
data = data_enc
|
||||
content = data_enc,
|
||||
timeout = 10000,
|
||||
proxy = "http://127.0.0.1:6152"
|
||||
)
|
||||
resp_enc = r.content
|
||||
try:
|
||||
@@ -158,3 +164,50 @@ def aimedb_api(accessCode):
|
||||
|
||||
decimal_value = int(rearranged_hex, 16)
|
||||
return decimal_value
|
||||
|
||||
def mifare(accessCode, serial):
|
||||
key = b'Copyright(C)SEGA'
|
||||
# https://sega.bsnk.me/allnet/aimedb/common/
|
||||
magic = "3ea1"
|
||||
version = "2140"
|
||||
command_id = "0f00" # ID = 15
|
||||
length = "3000" # 48
|
||||
gameId = "534447410000" # SDGA
|
||||
storeId = "bc310000"
|
||||
keychip_ID = "413633453031453032363400" # A63E01E0264
|
||||
header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID
|
||||
|
||||
access_code = str(accessCode)
|
||||
serial = str(serial)
|
||||
company_code = "00"
|
||||
firmware_version = "02"
|
||||
|
||||
|
||||
plaintext_hex_stream = header + access_code + company_code + firmware_version + serial
|
||||
|
||||
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')
|
||||
|
||||
match = re.search(r'[0-9a-f]{64}([0-9a-f]{6})', decrypted_hex_stream)
|
||||
if match:
|
||||
six_digit_code = match.group(1)
|
||||
|
||||
rearranged_hex = six_digit_code[4:6] + six_digit_code[2:4] + six_digit_code[0:2]
|
||||
|
||||
decimal_value = int(rearranged_hex, 16)
|
||||
return decimal_value
|
||||
|
||||
Reference in New Issue
Block a user