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