-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnet.py
107 lines (99 loc) · 3.31 KB
/
net.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import os, sys, json, base64
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
import lz4.block
gAesKey = b"cbs4/+-jDAf!?s/#cbs4/+-jDAf!?s/#"
gAesIv = b"=!r19kCsGHTAcr/@"
gLdr1 = {
"a": "Item",
"b": "Character",
"c": "CharacterSkill",
"d": "CharacterSkin",
"e": "Pet",
"f": "Card",
"g": "CharacterCardSlot",
"h": "CardDeploy",
"i": "CardDeployName",
"j": "CharacterDNA",
"k": "CharacterDNALink"
}
gLdr2 = {
"a": "Weapon",
"b": "WeaponExpert",
"c": "WeaponSkill",
"d": "Equipment",
"e": "PlayerEquip",
"f": "FinalStrike",
"g": "Chip",
"h": "Charge",
"i": "Tutorial",
"j": "PlayerService",
"k": "BenchWeapon",
"l": "WeaponDiVESkill"
}
gLdr3 = {
"a": "Stage",
"b": "Gallery",
"c": "GalleryExp",
"d": "MailCount",
"e": "Mail",
"f": "ExtraSystemContext",
"g": "Mission",
"h": "Research",
"i": "ResearchRecord",
"j": "FreeResearch",
"k": "StageSecret",
"l": "TowerBoss",
"m": "GalleryMainId"
}
gLdr4 = {
"a": "GachaRecord",
"b": "GachaGuaranteeRecord",
"c": "MultiPlayerGacha",
"d": "ShopRecord",
"e": "BoxGachaRecord",
"f": "EventRanking",
"u": "Banner",
"v": "ItemEx",
"w": "GachaEx",
"x": "GachaEventEx",
"y": "ShopEx",
"z": "EventEx"
}
def _req(src):
return json.loads(
unpad(
AES.new(gAesKey, AES.MODE_CBC, gAesIv).decrypt(
base64.b64decode(open(src, "rb").read())
), AES.block_size
).decode("utf8")
)
def _ext(src):
def _iter():
s = gAesKey + gAesIv
while True:
for c in s: yield c
raw = unpad(AES.new(gAesKey, AES.MODE_CBC, gAesIv).decrypt(base64.b64decode(src)), AES.block_size)
raw = bytes([c ^ k for c, k in zip(raw, _iter())])
raw = lz4.block.decompress(raw)
# Todo: parse the bson
return raw
def procDecode(dst, src, crypto = None):
req = _req if crypto else json.loads
if src and not src.endswith("/") and not src.endswith("\\") : src += "/"
if dst and not dst.endswith("/") and not dst.endswith("\\") : dst += "/"
os.makedirs(dst, exist_ok = True)
C1 = req(src + "LoginRetrieveCollector1Req")
C2 = req(src + "LoginRetrieveCollector2Req")
C3 = req(src + "LoginRetrieveCollector3Req")
C4 = req(src + "LoginRetrieveCollector4Req")
open("Player.json", "wb").write(json.dumps(_req(src + "RetrievePlayerInfoReq"), indent = 4, sort_keys = False).encode("utf8"))
for k, v in gLdr1.items(): open(dst + v + ".json", "wb").write(json.dumps(C1[k], indent = 4, sort_keys = False).encode("utf8"))
for k, v in gLdr2.items(): open(dst + v + ".json", "wb").write(json.dumps(C2[k], indent = 4, sort_keys = False).encode("utf8"))
for k, v in gLdr3.items(): open(dst + v + ".json", "wb").write(json.dumps(C3[k], indent = 4, sort_keys = False).encode("utf8"))
for k, v in gLdr4.items(): open(dst + v + ".json", "wb").write(json.dumps(C4[k], indent = 4, sort_keys = False).encode("utf8"))
open(dst + "ExData.json", "wb").write(_ext((C1["aa"] + C2["aa"] + C3["aa"] + C4["aa"]).encode("utf8")))
if __name__ == "__main__":
argv = sys.argv
if len(argv) == 4:
procDecode(*argv[1 :])