Update srv.js
Browse files
srv.js
CHANGED
|
@@ -1,12 +1,54 @@
|
|
| 1 |
-
const express=require('express')
|
| 2 |
-
const
|
| 3 |
-
const
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
-
|
| 11 |
-
app.get('/key
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const path = require('os');
|
| 4 |
+
const app = express();
|
| 5 |
+
const port = 7860;
|
| 6 |
+
|
| 7 |
+
const allowed = ['MLBB', 'BS', 'PUBG'];
|
| 8 |
+
|
| 9 |
+
async function fetchKey(game) {
|
| 10 |
+
if (!allowed.includes(game)) throw new Error('Invalid game');
|
| 11 |
+
|
| 12 |
+
const idxRes = await fetch('https://aamod.site/genkey/index.php');
|
| 13 |
+
const idxTxt = await idxRes.text();
|
| 14 |
+
const m = idxTxt.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
|
| 15 |
+
if (!m) throw new Error('sessionToken not found');
|
| 16 |
+
const sessionToken = m[1];
|
| 17 |
+
|
| 18 |
+
const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
|
| 19 |
+
const genRes = await fetch(`https://aamod.site/genkey/genkey.php?data=${data}`);
|
| 20 |
+
const genTxt = await genRes.text();
|
| 21 |
+
const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
|
| 22 |
+
if (!k) throw new Error('key not found in response');
|
| 23 |
+
return k[1].trim();
|
| 24 |
}
|
| 25 |
+
|
| 26 |
+
app.get('/key', async (req, res) => {
|
| 27 |
+
try {
|
| 28 |
+
const game = (req.query.game || 'MLBB').toUpperCase();
|
| 29 |
+
const key = await fetchKey(game);
|
| 30 |
+
res.json({ game, key });
|
| 31 |
+
} catch (e) {
|
| 32 |
+
res.status(500).json({ error: e.message });
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
app.get('/key/bulk', async (req, res) => {
|
| 37 |
+
try {
|
| 38 |
+
const game = (req.query.game || 'MLBB').toUpperCase();
|
| 39 |
+
const qty = Math.min(parseInt(req.query.qty) || 10, 1000);
|
| 40 |
+
|
| 41 |
+
const keys = [];
|
| 42 |
+
for (let i = 0; i < qty; i++) {
|
| 43 |
+
keys.push(await fetchKey(game));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
const file = `${path.tmpdir()}/${game}-${Date.now()}.txt`;
|
| 47 |
+
fs.writeFileSync(file, keys.join('\n'));
|
| 48 |
+
res.download(file, `${game}-keys.txt`, () => fs.unlinkSync(file));
|
| 49 |
+
} catch (e) {
|
| 50 |
+
res.status(500).json({ error: e.message });
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
app.listen(port, () => console.log(`Running on :${port}`));
|