Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -14,12 +14,12 @@ const DUMMY_ZIP = 'dummy_lite.zepeto.zip';
|
|
| 14 |
if (!fs.existsSync('uploads')) fs.mkdirSync('uploads', { recursive: true });
|
| 15 |
|
| 16 |
function copyLooseFiles(srcDir, destDir, logMsg) {
|
|
|
|
| 17 |
const items = fs.readdirSync(srcDir);
|
| 18 |
for (const item of items) {
|
| 19 |
const srcPath = path.join(srcDir, item);
|
| 20 |
const destPath = path.join(destDir, item);
|
| 21 |
const stat = fs.lstatSync(srcPath);
|
| 22 |
-
|
| 23 |
if (stat.isDirectory()) {
|
| 24 |
if (item.toLowerCase() !== 'assetbundles') {
|
| 25 |
if (!fs.existsSync(destPath)) fs.mkdirSync(destPath, { recursive: true });
|
|
@@ -27,7 +27,6 @@ function copyLooseFiles(srcDir, destDir, logMsg) {
|
|
| 27 |
}
|
| 28 |
} else {
|
| 29 |
const ext = path.extname(item).toLowerCase();
|
| 30 |
-
// JANGAN GANTI PREFAB DUMMY AGAR CAB TETAP VALID
|
| 31 |
if (!['.prefab', '.meta'].includes(ext)) {
|
| 32 |
fs.copyFileSync(srcPath, destPath);
|
| 33 |
}
|
|
@@ -36,6 +35,7 @@ function copyLooseFiles(srcDir, destDir, logMsg) {
|
|
| 36 |
}
|
| 37 |
|
| 38 |
function getDirectoryTree(dir, prefix = '') {
|
|
|
|
| 39 |
let tree = '';
|
| 40 |
const files = fs.readdirSync(dir);
|
| 41 |
files.forEach((file, index) => {
|
|
@@ -56,11 +56,6 @@ app.post('/convert', async (req, res) => {
|
|
| 56 |
logMsg(`\n======================================================`);
|
| 57 |
logMsg(`[INIT] BOT MENEMBAK! Misi AssetRipper + UABE untuk: ${req.body.filename || 'result.zepeto'}`);
|
| 58 |
|
| 59 |
-
if (!req.body.file_url) {
|
| 60 |
-
logMsg(`[ERROR] file_url is required`);
|
| 61 |
-
return res.status(400).json({ error: "file_url is required", step_logs: logs });
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
const timeId = Date.now();
|
| 65 |
const tempHighPoly = path.join(__dirname, 'uploads', `hp_${timeId}.zepeto`);
|
| 66 |
const tempOutput = path.join(__dirname, 'uploads', req.body.filename || `out_${timeId}.zepeto`);
|
|
@@ -79,46 +74,58 @@ app.post('/convert', async (req, res) => {
|
|
| 79 |
logMsg(`[STEP 2] Unzip Native...`);
|
| 80 |
fs.mkdirSync(extractDummyPath, { recursive: true });
|
| 81 |
fs.mkdirSync(extractHpPath, { recursive: true });
|
| 82 |
-
|
| 83 |
execSync(`unzip -q -o "${DUMMY_ZIP}" -d "${extractDummyPath}"`);
|
| 84 |
execSync(`unzip -q -o "${tempHighPoly}" -d "${extractHpPath}"`);
|
| 85 |
|
| 86 |
-
logMsg(`[STEP 3] ASSET-RIPPER:
|
| 87 |
const hpAssetBundles = path.join(extractHpPath, 'assetbundles');
|
| 88 |
try {
|
| 89 |
-
const ripperExe =
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
} catch (ripperErr) {
|
| 98 |
logMsg(`[ASSET-RIPPER WARN] ${ripperErr.message}`);
|
| 99 |
}
|
| 100 |
|
| 101 |
-
logMsg(`[STEP 4] Mengamankan Loose Files
|
| 102 |
copyLooseFiles(extractHpPath, extractDummyPath, logMsg);
|
| 103 |
|
| 104 |
const dummyAssetBundles = path.join(extractDummyPath, 'assetbundles');
|
|
|
|
| 105 |
|
| 106 |
-
logMsg(`[STEP 5] Memerintahkan UABE (UnityPy) Packing
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
logMsg(`[STEP 6] Membungkus ZIP Anti-Korup (Archiver)...`);
|
| 112 |
const output = fs.createWriteStream(tempOutput);
|
| 113 |
const archive = archiver('zip', { zlib: { level: 9 } });
|
| 114 |
|
| 115 |
output.on('close', () => {
|
| 116 |
-
logMsg(`[SUCCESS] File Bypass siap dikirim
|
| 117 |
res.download(tempOutput, req.body.filename || 'result.zepeto', () => {
|
| 118 |
try {
|
| 119 |
fs.rmSync(extractDummyPath, { recursive: true, force: true });
|
| 120 |
fs.rmSync(extractHpPath, { recursive: true, force: true });
|
| 121 |
-
fs.rmSync(rippedHpPath, { recursive: true, force: true });
|
| 122 |
fs.unlinkSync(tempHighPoly);
|
| 123 |
fs.unlinkSync(tempOutput);
|
| 124 |
} catch (e) {}
|
|
@@ -130,8 +137,10 @@ app.post('/convert', async (req, res) => {
|
|
| 130 |
archive.directory(extractDummyPath, false);
|
| 131 |
archive.finalize();
|
| 132 |
|
| 133 |
-
}
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
} catch (err) {
|
|
@@ -146,5 +155,4 @@ app.post('/convert', async (req, res) => {
|
|
| 146 |
}
|
| 147 |
});
|
| 148 |
|
| 149 |
-
|
| 150 |
-
app.listen(PORT, () => console.log(`๐ Server AssetRipper + UABE Packing Aktif di Port ${PORT}`));
|
|
|
|
| 14 |
if (!fs.existsSync('uploads')) fs.mkdirSync('uploads', { recursive: true });
|
| 15 |
|
| 16 |
function copyLooseFiles(srcDir, destDir, logMsg) {
|
| 17 |
+
if (!fs.existsSync(srcDir)) return;
|
| 18 |
const items = fs.readdirSync(srcDir);
|
| 19 |
for (const item of items) {
|
| 20 |
const srcPath = path.join(srcDir, item);
|
| 21 |
const destPath = path.join(destDir, item);
|
| 22 |
const stat = fs.lstatSync(srcPath);
|
|
|
|
| 23 |
if (stat.isDirectory()) {
|
| 24 |
if (item.toLowerCase() !== 'assetbundles') {
|
| 25 |
if (!fs.existsSync(destPath)) fs.mkdirSync(destPath, { recursive: true });
|
|
|
|
| 27 |
}
|
| 28 |
} else {
|
| 29 |
const ext = path.extname(item).toLowerCase();
|
|
|
|
| 30 |
if (!['.prefab', '.meta'].includes(ext)) {
|
| 31 |
fs.copyFileSync(srcPath, destPath);
|
| 32 |
}
|
|
|
|
| 35 |
}
|
| 36 |
|
| 37 |
function getDirectoryTree(dir, prefix = '') {
|
| 38 |
+
if (!fs.existsSync(dir)) return 'Folder tidak ditemukan\n';
|
| 39 |
let tree = '';
|
| 40 |
const files = fs.readdirSync(dir);
|
| 41 |
files.forEach((file, index) => {
|
|
|
|
| 56 |
logMsg(`\n======================================================`);
|
| 57 |
logMsg(`[INIT] BOT MENEMBAK! Misi AssetRipper + UABE untuk: ${req.body.filename || 'result.zepeto'}`);
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
const timeId = Date.now();
|
| 60 |
const tempHighPoly = path.join(__dirname, 'uploads', `hp_${timeId}.zepeto`);
|
| 61 |
const tempOutput = path.join(__dirname, 'uploads', req.body.filename || `out_${timeId}.zepeto`);
|
|
|
|
| 74 |
logMsg(`[STEP 2] Unzip Native...`);
|
| 75 |
fs.mkdirSync(extractDummyPath, { recursive: true });
|
| 76 |
fs.mkdirSync(extractHpPath, { recursive: true });
|
|
|
|
| 77 |
execSync(`unzip -q -o "${DUMMY_ZIP}" -d "${extractDummyPath}"`);
|
| 78 |
execSync(`unzip -q -o "${tempHighPoly}" -d "${extractHpPath}"`);
|
| 79 |
|
| 80 |
+
logMsg(`[STEP 3] ASSET-RIPPER: Membongkar Biner...`);
|
| 81 |
const hpAssetBundles = path.join(extractHpPath, 'assetbundles');
|
| 82 |
try {
|
| 83 |
+
const ripperExe = execSync('find /opt/assetripper -type f -name "AssetRipper*" | head -n 1').toString().trim();
|
| 84 |
+
logMsg(`[ASSET-RIPPER] Mengeksekusi: ${ripperExe}`);
|
| 85 |
|
| 86 |
+
// ๐ฏ PERBAIKAN: Gunakan perintah minimalis agar versi GUI mau mengekstrak
|
| 87 |
+
execSync(`"${ripperExe}" "${hpAssetBundles}"`);
|
| 88 |
+
|
| 89 |
+
// AssetRipper biasanya mengekstrak ke folder 'Ripped' di root atau di samping input
|
| 90 |
+
// Kita cari folder hasil ekstranya
|
| 91 |
+
const possibleRipped = ['Ripped', 'ExportedProject'].map(n => path.join(process.cwd(), n));
|
| 92 |
+
let foundRipped = '';
|
| 93 |
+
for (const p of possibleRipped) { if (fs.existsSync(p)) foundRipped = p; }
|
| 94 |
+
|
| 95 |
+
if (foundRipped) {
|
| 96 |
+
logMsg(`[ASSET-RIPPER] Sukses membongkar ke: ${foundRipped}`);
|
| 97 |
+
logMsg(`\n=== ๐ LOG DEBUG STRUKTUR ===\n${getDirectoryTree(foundRipped)}============================\n`);
|
| 98 |
+
// Pindahkan ke lokasi rippedHpPath agar bisa dihapus nanti
|
| 99 |
+
execSync(`mv "${foundRipped}" "${rippedHpPath}"`);
|
| 100 |
}
|
| 101 |
} catch (ripperErr) {
|
| 102 |
logMsg(`[ASSET-RIPPER WARN] ${ripperErr.message}`);
|
| 103 |
}
|
| 104 |
|
| 105 |
+
logMsg(`[STEP 4] Mengamankan Loose Files...`);
|
| 106 |
copyLooseFiles(extractHpPath, extractDummyPath, logMsg);
|
| 107 |
|
| 108 |
const dummyAssetBundles = path.join(extractDummyPath, 'assetbundles');
|
| 109 |
+
const hpAssetBundlesFix = path.join(extractHpPath, 'assetbundles');
|
| 110 |
|
| 111 |
+
logMsg(`[STEP 5] Memerintahkan UABE (UnityPy) Packing...`);
|
| 112 |
+
try {
|
| 113 |
+
const pyLog = execSync(`python3 uabe_packer.py "${dummyAssetBundles}" "${hpAssetBundlesFix}"`).toString();
|
| 114 |
+
logMsg(`[UABE LOG]\n${pyLog}`);
|
| 115 |
+
|
| 116 |
+
if (!pyLog.includes('[SUCCESS]')) throw new Error("Operasi UABE Gagal");
|
| 117 |
|
| 118 |
+
logMsg(`[STEP 6] Membungkus ZIP Anti-Korup...`);
|
|
|
|
| 119 |
const output = fs.createWriteStream(tempOutput);
|
| 120 |
const archive = archiver('zip', { zlib: { level: 9 } });
|
| 121 |
|
| 122 |
output.on('close', () => {
|
| 123 |
+
logMsg(`[SUCCESS] File Bypass siap dikirim!\n`);
|
| 124 |
res.download(tempOutput, req.body.filename || 'result.zepeto', () => {
|
| 125 |
try {
|
| 126 |
fs.rmSync(extractDummyPath, { recursive: true, force: true });
|
| 127 |
fs.rmSync(extractHpPath, { recursive: true, force: true });
|
| 128 |
+
if (fs.existsSync(rippedHpPath)) fs.rmSync(rippedHpPath, { recursive: true, force: true });
|
| 129 |
fs.unlinkSync(tempHighPoly);
|
| 130 |
fs.unlinkSync(tempOutput);
|
| 131 |
} catch (e) {}
|
|
|
|
| 137 |
archive.directory(extractDummyPath, false);
|
| 138 |
archive.finalize();
|
| 139 |
|
| 140 |
+
} catch (pyErr) {
|
| 141 |
+
logMsg(`[UABE CRASH] ${pyErr.message}`);
|
| 142 |
+
if (pyErr.stderr) logMsg(`[STDERR] ${pyErr.stderr.toString()}`);
|
| 143 |
+
throw pyErr;
|
| 144 |
}
|
| 145 |
|
| 146 |
} catch (err) {
|
|
|
|
| 155 |
}
|
| 156 |
});
|
| 157 |
|
| 158 |
+
app.listen(7860, () => console.log(`๐ Server AssetRipper + UABE Aktif di Port 7860`));
|
|
|