托人抓包看了一下,大部分要做的工作跟我在 Sail Girl 的回复类似,具体构造URL时不需要加salt,也不需要做md5,其他大抵是照旧的:
step1.还是先下载settings.json,构造url下载每个bundle的config.json,而index.js随意。此处有个对应的 version.json 影响url的path部分的构造格式:(假设)在version.json中的,拼接bundle/;反之,拼接game/assets/。
step2.整理config.json成manifest.json,会方便一点。
step3.下载Import集合,回填manifest.json的Native集合,手工再修一修。
step4.下载Native集合。
TTFont.ttf的URL生成逻辑(大概)
function _T(t) {
for (var e = t.output = t.input, i = 0; i < e.length; i++) {
var n = e[i];
if (!n.url) {
var r, s, a = n.config;
s = n.isNative ? a && a.nativeBase ? a.base + a.nativeBase : A.assetManager.generalNativeBase : a && a.importBase ? a.base + a.importBase : A.assetManager.generalImportBase;
var o = n.overrideUuid || n.uuid, h = "";
n.info && (h = n.isNative ? n.info.nativeVer ? "." + n.info.nativeVer : "" : n.info.ver ? "." + n.info.ver : ""),
r = ".ttf" === n.ext ? s + "/" + o.slice(0, 2) + "/" + o + h + "/" + n.options.__nativeName__ : s + "/" + o.slice(0, 2) + "/" + o + h + n.ext,
n.url = r
}
}
return null
}
关于图像资源数目
bundle内粗略预估(仅供参考):.png有6515个,.jpg有996个,.jpeg有2个,.pvr有6个, .pkm有6个, .astc有5757个。
有效资源数量小于以上总和(预估在7482个左右),因为同一资源有多种格式,优先只下载无损格式。
关于视频资源数目
bundle内粗略预估(仅供参考):.mp4有24个。
如果需要其他,请参考m3u8下载。
补:又被投喂一个setting.json(视频mp4 +8个,其他的没统计)。此处也有个对应的 version.json ,因为二者同一对象的版本号不一致了,所以此处在version.json中的对象的版本号也用version.json中的版本号。
image解密参考
(function(root) {
var exports = undefined, module = undefined, require = undefined;
var define = undefined;
var self = root, window = root, global = root, globalThis = root;
(function() {
const ENCRYPT_SIGN = "testsign";
const ENCRYPT_KEY = "vXjOTTiFuUXFiLGI";
const imgTypes = {
"png": "image/png",
"jpg": "image/jpg",
"jpeg": "image/jpeg"
};
const downloadArrayBuffer = (url, options, onComplete) => {
options.xhrResponseType = 'arraybuffer';
downloadFile(url, options, options.onFileProgress, onComplete);
};
function parseParameters(options, onProgress, onComplete) {
if (onComplete === undefined) {
var isCallback = typeof options === 'function';
if (onProgress) {
onComplete = onProgress;
if (!isCallback) {
onProgress = null;
}
} else if (onProgress === undefined && isCallback) {
onComplete = options;
options = null;
onProgress = null;
}
if (onProgress !== undefined && isCallback) {
onProgress = options;
options = null;
}
}
options = options || Object.create(null);
return {
options,
onProgress,
onComplete
};
}
const downloadFile = (url, options, onProgress, onComplete) => {
const xhr = new XMLHttpRequest();
const errInfo = `download failed: ${url}, status: `;
xhr.open('GET', url, true);
if (options.xhrResponseType !== undefined) {
xhr.responseType = options.xhrResponseType;
}
if (options.xhrWithCredentials !== undefined) {
xhr.withCredentials = options.xhrWithCredentials;
}
if (options.xhrMimeType !== undefined && xhr.overrideMimeType) {
xhr.overrideMimeType(options.xhrMimeType);
}
if (options.xhrTimeout !== undefined) {
xhr.timeout = options.xhrTimeout;
}
if (options.xhrHeader) {
for (const header in options.xhrHeader) {
xhr.setRequestHeader(header, options.xhrHeader[header]);
}
}
xhr.onload = () => {
if (xhr.status === 200 || xhr.status === 0) {
if (onComplete) {
onComplete(null, xhr.response);
}
} else if (onComplete) {
onComplete(new Error(`${errInfo}${xhr.status}(no response)`));
}
};
if (onProgress) {
xhr.onprogress = e => {
if (e.lengthComputable) {
onProgress(e.loaded, e.total);
}
};
}
xhr.onerror = () => {
if (onComplete) {
onComplete(new Error(`${errInfo}${xhr.status}(error)`));
}
};
xhr.ontimeout = () => {
if (onComplete) {
onComplete(new Error(`${errInfo}${xhr.status}(time out)`));
}
};
xhr.onabort = () => {
if (onComplete) {
onComplete(new Error(`${errInfo}${xhr.status}(abort)`));
}
};
xhr.send(null);
return xhr;
};
const downloadImage = (url, options, onComplete) => {
const func = cc.sys.hasFeature(cc.sys.Feature.IMAGE_BITMAP) && cc.assetManager.allowImageBitmap ? cc.assetManager.downloader.downloadBlob : downloadImageByBuffer;
func(url, options, onComplete);
};
const downloadImageByBuffer = (url, options, onComplete) => {
// console.debug("downloadImageByBuffer:" + url);
downloadArrayBuffer(url, options, function(err, data) {
if (err) {
onComplete && onComplete(null, data);
return;
}
if (checkIsEncripted(data, ENCRYPT_SIGN)) {
let index = url.lastIndexOf(".");
let suffix = url.substr(index + 1);
let typeStr = imgTypes[suffix] || imgTypes["png"];
data = decodeArrayBuffer(data, ENCRYPT_SIGN, ENCRYPT_KEY);
let base64code = arrayBufferToBase64Img(data);
base64code = `data:${typeStr};base64,${base64code}`;
cc.assetManager.downloader.downloadDomImage(base64code, options, onComplete);
} else {
cc.assetManager.downloader.downloadDomImage(url, options, onComplete);
}
});
}
;
const checkIsEncripted = (arrbuf, sign) => {
if (!sign) {
return false;
}
let signBuf = new Uint8Array(strToBytes(sign));
let buffer = new Uint8Array(arrbuf);
for (let i = 0; i < signBuf.length; i++) {
if (buffer[i] != signBuf[i]) {
return false;
}
}
return true;
};
const arrayBufferToBase64Img = buffer => {
let binary = "";
const myTypedArray = new Uint8Array(buffer);
for (let len = buffer.byteLength, i = 0; i < len; i++) {
binary += String.fromCharCode(myTypedArray[i]);
}
return btoa(binary);
};
const strToBytes = str => {
let size = str.length;
let result = [];
for (let i = 0; i < size; i++) {
result.push(str.charCodeAt(i));
}
return result;
};
const decodeArrayBuffer = (arrbuf, sign, key) => {
let signBuf = new Uint8Array(strToBytes(sign));
let keyBytes = strToBytes(key);
let buffer = new Uint8Array(arrbuf);
let size = buffer.length - signBuf.length;
let _outArrBuf = new ArrayBuffer(size);
let outBuffer = new Uint8Array(_outArrBuf);
let idx = 0;
for (let i = 0; i < size; i++) {
let b = buffer[signBuf.length + i];
let db = b ^ keyBytes[idx];
if (++idx >= keyBytes.length) {
idx = 0;
}
outBuffer[i] = db;
}
return outBuffer;
};
_downloaders = {
// Images
'.png': downloadImage,
'.jpg': downloadImage,
// '.bmp': downloadImage,
'.jpeg': downloadImage // '.gif': downloadImage,
// '.ico': downloadImage,
// '.tiff': downloadImage,
// '.webp': downloadImage,
// '.image': downloadImage,
// '.pvr': downloadArrayBuffer,
// '.pkm': downloadArrayBuffer,
// '.astc': downloadArrayBuffer,
// // Txt
// '.txt': downloadText,
// '.xml': downloadText,
// '.vsh': downloadText,
// '.fsh': downloadText,
// '.atlas': downloadText,
// '.tmx': downloadText,
// '.tsx': downloadText,
// '.json': downloadJson,
// '.ExportJson': downloadJson,
// '.plist': downloadText,
// '.ccon': downloadCCON,
// '.cconb': downloadCCONB,
// '.fnt': downloadText,
// // Binary
// '.binary': downloadArrayBuffer,
// '.bin': downloadArrayBuffer,
// '.dbbin': downloadArrayBuffer,
// '.skel': downloadArrayBuffer,
// '.js': downloadScript,
// bundle: downloadBundle,
// default: downloadText,
};
if (!cc.sys.isNative) {
cc.assetManager.downloader.register(_downloaders);
}
}
).call(root);
}
)(// The environment-specific global.
function() {
if (typeof globalThis !== 'undefined')
return globalThis;
if (typeof self !== 'undefined')
return self;
if (typeof window !== 'undefined')
return window;
if (typeof global !== 'undefined')
return global;
if (typeof this !== 'undefined')
return this;
return {};
}
.call(this));