unreal.js
Version:
A pak reader for games like VALORANT & Fortnite written in Node.JS
48 lines (47 loc) • 2.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
const fs_1 = require("fs");
const axios_1 = __importDefault(require("axios"));
(async () => {
const usmap = fs_1.readFileSync("D:/Downloads/++Fortnite+Release-19.20-CL-18775446-Windows_oo.usmap");
const provider = new index_1.FileProvider("D:/Programme/Fortnite/FortniteGame/Content/Paks", index_1.Ue4Version.GAME_UE5_LATEST, new index_1.UsmapTypeMappingsProvider(usmap), {
GDebug: false,
GUseLocalTypeRegistry: true
});
//provider.ioStoreTocReadOptions = 0
provider.mappingsProvider.reload();
const s = Date.now();
await provider.initialize();
await mountFn(provider);
// await provider.submitKey(FGuid.mainGuid, "0x4BE71AF2459CF83899EC9DC2CB60E22AC4B3047E0211034BBABE9D174C069DD6") // VALORANT
console.log("Mounted paks in: " + (Date.now() - s) + "ms");
const path = "FortniteGame/Content/Athena/Artemis/Maps/Artemis_terrain.umap";
const pkg = provider.loadGameFile(path);
//const tex = pkg.getExportOfType(UTexture2D) as UTexture2D
//const image = Image.convert(tex)
//writeFileSync("image.png", image)
const json = pkg.toJson();
//console.log(json);
fs_1.writeFileSync("result.json", JSON.stringify(json, null, 4));
})();
async function mountFn(provider) {
const { data } = await axios_1.default.get("https://benbot.app/api/v1/aes");
await provider.submitKey(index_1.FGuid.mainGuid, data.mainKey);
for (const reader of provider.unloadedPaks) {
if (reader.isEncrypted) {
const p = reader.path.substring(reader.path.indexOf("FortniteGame"));
const key = data.dynamicKeys[p];
if (key) {
await provider.submitKey(reader.encryptionKeyGuid, key);
}
else
console.warn("Missing aes key for: " + p);
}
else
provider.mount(reader);
}
}