Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Junk code collection

resource_fetch.php

batch export card image


api_decrypt.php

attempt to decrypt api response
About api: The first two (GetNativeToken & Login) are encrypted with embedded key, then RequestEnvironment switched to sharedSecret mode, which should come from first two response
(Not well researched)

POST body ["pm"]: stringBuilder.append("{0}{1}{2}", bridgeToken, keyIndex, data)
response body: pure encrypted message


MD_AssetbundleDLPackVer.php

decrypt & deserialize MD_AssetbundleDLPackVer.snd, for resource download lookup


abip.php

decrypt .abip asset bundle


MD_Costume.php

deserialize MD_Costume.snd, for card name mapping

<?php
$dat = file_get_contents('cr0026_c005_0.abip');
$key = implode('', array_reverse(str_split(base64_decode('Y2VJOCQpWSNZcyRyNVJGNVd8NFctXzE7Kkw7KVZVenc='), 1)));
$iv = implode('', array_reverse(str_split(base64_decode('ZTBnJDJuUnAmIWRBUVJXP2pxeCxXPn1FI2ZKRzFEKkw='), 1)));
$head = substr($dat, 0, 0x400);
$body = substr($dat, 0x400);
$headdec = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $head, MCRYPT_MODE_CBC, $iv);
file_put_contents('cr0026_c005_0-dec.abip', $headdec.$body);
<?php
$key0 = ([
'mfQMG92mJ6R',
'D2L1L1aLJSBjLlLQ3fCdS8at',
'52hHwSInpbOVRq',
'M88yny3dvB5ZTVHpQD',
]);
$key1 = ([
'MW1LkPfxIrDB7PNTdupvw',
'jAWLuydO',
'sIQPwGnXVkOhMqks0p',
'W7rkDhakfa1PI0',
]);
function getApiKey($idx) {
global $key0;global $key1;
return $key0[$idx] . $key1[$idx];
}
function getApiKeyNext($idx) {
global $key0;global $key1;
$idx = ($idx +1) % 4;
return $key0[$idx] . $key1[$idx];
}
$dat = json_decode('{"pm":"QO0YGgQ+N4oueI425HLaYoYu8E0UOj1GS4S6AAByOgvPM9UC9I2yZCTE0ObdjsekAcIjfElVUhybI4En\/6gT2THEC4XUYaGkNZ6f4PMkzw2Oc1hrX9R4LPkb6\/TmX9VfMDiM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aOgsw0jZsMK840ISnGDmGMZ0NcGPMCbsUodpdnqZVldgTJ1UKhlgHTqHXDvQAsbFyz1f\/FGET\/QdaajH0RwfMDBAbFmRyydRjkTBQ63S+nPsGI+Qch0rdGoOQvnJk9k4lHz0hFJpl\/CnoPIce1c5PfOTka6KSYMV49r+UNxY4\/O32UbexEvOodoZNbUHWbpR4Zq4gHzVVwLg6hH7VYDY=","hs":"f705a0773e3ecc0a6348575f0f9bbd722cec908f66e270d053154217b1956133"}', true)['pm'];
//$dat = json_decode(file_get_contents('api_login.json'), true)['pm'];
//$dat = json_decode('{"hs":"3dee303b57bbbeefccb66b25c72e9243","pm":"2l/U6spKzAv2hKfXKDlUc494hjoi64+N8yHu0A9c5NkSVGHFI3hP88OFseRP6YsaWiPDiUVnwNNnLARyisHUo/DVyj2FDxje57XWbO+5C/uW7ectqmXbPqlo4gv3XuPAhVUWQZMNxYmf3hfXVP2aI+6avMUr63sN3FFYr/ebSmWKq08ugyRZGnzFitRqC8+3+zIwXOt++70gAfkeWDKzTNMpPChtjlxn5miOCArDs0znhugqD4bMmSSoye2eLzStVRRtCwbaUWp5wdskyrfiNjjBI1WAmwYR9TQt8YWf5PwFZm3jXWpPDYZcRP5hm1ERIcMBK2Ph91hluy2dwPJaTclTYVr05DNVRB46IhONUsMK/mkgvJB8KOFGpuCa1EvvqOpsLwpXjTL4qsTPw+y/AKJ4TypD3sdooixR+5DryUmc="}', true)['pm'];
//$dat = substr($dat, 1);
//$dat = json_decode('{"pm":"fAmrnW9WfKScSM+JsfWR40YzA76cFXkpybPgrhNXs+48Wi0M8Pmn5MLqcrCU4mRV\/6z888IgugL3CiJgjSyHrtlOflAh\/nUz9Xlds0suRx8U3vIzH50+XVUoPuK4heEFe0ZxUcVA7fehONlYTaikwJjKIgpJRsJo7EFpL4XaMqQmV9iksmJdyRvDYtfpDnAyETqhcJTbatjnrXE0FWLaQlvbb9Cnegdn7N9ribXxJmliOyghCHptNHwgeWOjZn9TfShlqBW8AAwF5A\/NSffBxOWyPOyGmnZMC7JR9Wa+I5h2qPJQXBHQ+Ufs8xR+HRAAt4aW9d1xQibpC6nlmo57bgqgoARGwmeBETFJX96gGME=","hs":"3d650d307ed2903ef40101743c4043f01dba302eeddc526705e89b2035fbf5bf"}', true)['pm'];
//$dat = $dat['pm'];
//var_dump(strlen(base64_decode($dat)));
for ($i=2; $i<3; $i++) {
$dec = openssl_decrypt(base64_decode($dat), 'AES-256-CBC', getApiKeyNext($i), OPENSSL_RAW_DATA+OPENSSL_ZERO_PADDING, substr(getApiKey($i), 0, 16));
$data = gzdecode(base64_decode($dec));
file_put_contents('response_login.json', $data);
//var_dump(getApiKeyNext($i), substr(getApiKey($i), 0, 16));
//$dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, getApiKeyNext($i), base64_decode(($dat)), MCRYPT_MODE_CBC, substr(getApiKey($i), 0, 16));
//var_dump((base64_decode($dec)));
//var_dump($dec);
//echo bin2hex($dec);
//$end = base64_decode(trim(substr($dec, 16), "\0"));
//var_dump(bin2hex(base64_decode(substr($dec, 16))));
//echo bin2hex(substr($dec, 0, 2))."\n";
}
<?php
// https://github.com/esterTion/unity-texture-toolkit
require 'UnityBundle.php';
$sndFile = 'MD_AssetbundleDLPackVer';
$dat = file_get_contents($sndFile.'.snd');
$mdkey = 'j6GWCVK9UMKKd3pnNDtxYFSZ4zHiQ9xD';
$mdiv = 'dQATZ4QY7gahQaT5';
$dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $mdkey, $dat, MCRYPT_MODE_CBC, $mdiv);
$pad = ord(substr($dec, -1, 1));
$dec = substr($dec, 0, -$pad);
file_put_contents($sndFile.'-dec.snd.gz', $dec);
file_put_contents($sndFile.'-dec.snd', gzdecode($dec));
$st = new FileStream($sndFile.'-dec.snd');
$st->littleEndian = true;
$st->long;
$entries = $st->long;
$st->long;$st->long;
$map = [];
echo "$entries\n";
for ($i=0; $i<$entries; $i++) {
$name = readString($st);
$val = [
$st->long, // size android
$st->long, // size ios
readString($st), // version_ios
readString($st) // version android
];
$resCount = readString($st);
$val[] = $resCount;
$resCount = intval(substr($resCount, 1));
for ($j = 0; $j<$resCount; $j++) {
$val[] = readString($st);
}
$map[$name] = $val;
echo "\r$i";
//var_dump($name);
//print_r($map[$name]);
//sleep(1);
}
//print_r($map);
file_put_contents($sndFile.'-dec.json', json_encode($map));
function readString($stream) {
$len = ord($stream->byte);
return $stream->readData($len);
}
<?php
if (!function_exists('mb_ord')) {
function mb_ord($v) {
$k = mb_convert_encoding($v, 'UCS-2LE', 'UTF-8');
$k1 = ord(substr($k, 0, 1));
$k2 = ord(substr($k, 1, 1));
return $k2 * 256 + $k1;
}
function mb_chr($num){
return mb_convert_encoding('&#'.intval($num).';', 'UTF-8', 'HTML-ENTITIES');
}
}
require 'UnityBundle.php';
$sndFile = 'MD_Costume';
$sndMemberType = parseMemberType('osososoioioiososoioioioioiosoioioioioiosososososososososososososososoioioioiososososososososososososoiososoioi');
$sndMemberName = ['_ID','_Name','_Detail','_IsShowCollection','_ShowCollectionNo','_Default','_GraphicID','_CanEquipCharacterIds','_Rarity','_WeaponKind','_ItemKindID','_InitMaxLevel','_MaxLevel','_ExpTableID','_Element','_HPLevel1','_HPLevelMax','_AttackLevel1','_AttackLevelMax','_ActiveSkillID','_ActiveSkillIDLB1','_ActiveSkillIDLB2','_ActiveSkillIDLB3','_ActiveSkillIDLB4','_ActiveSkillID2','_ActiveSkillID2LB1','_ActiveSkillID2LB2','_ActiveSkillID2LB3','_ActiveSkillID2LB4','_LeaderSkillID','_LeaderSkillIDLB1','_LeaderSkillIDLB2','_LeaderSkillIDLB3','_LeaderSkillIDLB4','_GainExp','_SellGameCoin','_SellDollsPoint','_SellRealCoinFree','_UnLockSubScenarioID','_SpecialID','_HeadAvatarID','_FaceAvatarID','_EarAvatarID','_UpBodyAvatarID','_LowBodyAvatarID','_AnotherHeadAvatarID','_AnotherFaceAvatarID','_AnotherEarAvatarID','_AnotherUpBodyAvatarID','_AnotherLowBodyAvatarID','_CostumeVersion','_LimitbreakBonusHPID','_LimitbreakBonusATKID','_MaxLimitbreakCount','_IsSubLimited'];
//$sndFile = 'MD_AssetbundleDLPackVer';
//$sndMemberType = 'siissas';
$dat = file_get_contents($sndFile.'.snd');
$mdkey = 'j6GWCVK9UMKKd3pnNDtxYFSZ4zHiQ9xD';
$mdiv = 'dQATZ4QY7gahQaT5';
$dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $mdkey, $dat, MCRYPT_MODE_CBC, $mdiv);
$pad = ord(substr($dec, -1, 1));
$dec = substr($dec, 0, -$pad);
file_put_contents($sndFile.'-dec.snd.gz', $dec);
file_put_contents($sndFile.'-dec.snd', gzdecode($dec));
$st = new FileStream($sndFile.'-dec.snd');
$st->littleEndian = true;
$st->long;
$entries = $st->long;
$st->long;$st->long;
$map = [];
echo "$entries\n";
for ($i=0; $i<$entries; $i++) {
$val = [];
for ($j=0; $j<count($sndMemberType); $j++) {
$name = $sndMemberName[$j];
$value = readValue($sndMemberType[$j], $st);
$val[$name] = $value;
}
$map[$val['_ID']] = $val['_Name'];
echo "\r$i";
}
file_put_contents($sndFile.'-dec.json', json_encode($map));
function parseMemberType($typeStr) {
$val = [];
for ($i=0; $i<strlen($typeStr); $i++) {
//$isArray = false;
$isObfuscated = false;
/*if ($typeStr[$i] == 'a') {
$isArray = true;
$i++;
}*/
if ($typeStr[$i] == 'o') {
$isObfuscated = true;
$i++;
}
$val[] = [
'type' => $typeStr[$i],
//'isArray' => $isArray,
'isObfuscated' => $isObfuscated
];
}
return $val;
}
function readValue($type, Stream $stream) {
switch ($type['type']) {
case 's' : {
$len = ord($stream->byte);
$str = $stream->readData($len);
if ($type['isObfuscated']) {
// SimpleModules__Shift(string source, int shift, int step)
$output = '';
$shift = 11; $step = 3;
for ($i=0; $i<mb_strlen($str, 'UTF-8'); $i++) {
$v9 = mb_ord(mb_substr($str, $i, 1, 'UTF-8'));
$v11 = ($v9 + $shift);
$output .= mb_chr($v11);
$shift += $step;
}
$str = $output;
}
return $str;
}
case 'i': {
$val = $stream->long;
if ($type['isObfuscated']) {
$val ^= 0x7fef;
}
return $val;
}
default: {
throw new Exception("unknown type {$type[$index]}");
}
}
}
<?php
if (isset($_SERVER['HTTP_HOST']))exit;
require 'UnityAsset.php';
define('RES_DIR', '/data/home/web/_redive/tokyodolls/card/');
$key = implode('', array_reverse(str_split(base64_decode('Y2VJOCQpWSNZcyRyNVJGNVd8NFctXzE7Kkw7KVZVenc='), 1)));
$iv = implode('', array_reverse(str_split(base64_decode('ZTBnJDJuUnAmIWRBUVJXP2pxeCxXPn1FI2ZKRzFEKkw='), 1)));
$manifest = json_decode(file_get_contents('MD_AssetbundleDLPackVer-dec.json'), true);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CONNECTTIMEOUT=>5,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HEADER=>0,
CURLOPT_FILETIME=>true,
CURLOPT_SSL_VERIFYPEER=>false
]);
foreach ($manifest as $fileName=>$info) {
if (!preg_match('/_Costume_/', $fileName)) continue;
_log("Downloading $fileName ({$info[0]})");
$url = MakeUrlCore("cache.projecttokyodolls.jp", "dolls.prd.cdn", $fileName.'.abip', $info[2], 'ios');
curl_setopt($curl, CURLOPT_URL, $url);
$bundle = curl_exec($curl);
if (strlen($bundle) !== $info[0]) {
_log('Size mismatch, received: '.strlen($bundle));
exit;
continue;
}
$bundle = new MemoryStream($bundle);
$bundle->littleEndian = true;
if ($bundle->readData(4) !== 'ppir') {
_log('Wrong header');
continue;
}
$bundle->long; $bundle->long;
$dataOffset = $bundle->long;
$bundle->long; $bundle->long; $bundle->long;
$dataLen = $bundle->long;
$bundle->position = $dataOffset;
$bundle = $bundle->readData($dataLen);
$head = substr($bundle, 0, 0x400);
$body = substr($bundle, 0x400);
$headdec = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $head, MCRYPT_MODE_CBC, $iv);
$bundle = $headdec.$body;
$assetList = extractBundle(new MemoryStream($bundle));
foreach ($assetList as $assetFile) {
$asset = new AssetFile($assetFile);
foreach ($asset->preloadTable as $item) {
if ($item->typeString == 'Texture2D') {
$item = new Texture2D($item, true);
$item->exportTo(RES_DIR.$item->name, 'webp', '-lossless 1');
}
}
$asset->__desctruct();
unset($asset);
}
array_map('unlink', $assetList);
}
function _log($s) {
echo date('H:i:s ').$s."\n";
}
function MakeUrlCore(string $domain, string $backet, string $fileName, int $version, string $platform) {
$hash = md5("${backet}/${version}");
return "http://${domain}/".md5(
substr($hash, hexdec($hash[0]))
)."/${platform}/${fileName}";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.