Update srv.js
Browse files
srv.js
CHANGED
|
@@ -6,41 +6,41 @@ const https = require('https');
|
|
| 6 |
|
| 7 |
const app = express();
|
| 8 |
const port = 7860;
|
| 9 |
-
|
| 10 |
const allowed = ['MLBB', 'BS', 'PUBG'];
|
| 11 |
-
|
| 12 |
-
const
|
| 13 |
-
const agent = new https.Agent({ rejectUnauthorized: false });
|
| 14 |
-
const rand = () => Array.from({ length: 4 }, () => Math.floor(Math.random() * 256)).join('.');
|
| 15 |
-
return (url, opts = {}) =>
|
| 16 |
-
axios({
|
| 17 |
-
url,
|
| 18 |
-
httpsAgent: agent,
|
| 19 |
-
headers: {
|
| 20 |
-
'X-Forwarded-For': rand(),
|
| 21 |
-
'X-Real-IP': rand(),
|
| 22 |
-
'Via': '1.1 ' + Math.random().toString(36).slice(2)
|
| 23 |
-
},
|
| 24 |
-
...opts
|
| 25 |
-
});
|
| 26 |
-
})();
|
| 27 |
-
|
| 28 |
|
| 29 |
async function fetchKey(game) {
|
| 30 |
if (!allowed.includes(game)) throw new Error('Invalid game');
|
| 31 |
|
| 32 |
-
const idxRes = await
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
const m = idxTxt.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
|
| 35 |
if (!m) throw new Error('sessionToken not found');
|
| 36 |
const sessionToken = m[1];
|
| 37 |
|
| 38 |
const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
|
| 39 |
-
const genRes = await
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
|
| 42 |
if (!k) throw new Error('key not found in response');
|
| 43 |
-
return k[1]?.trim()
|
| 44 |
}
|
| 45 |
|
| 46 |
app.get('/key', async (req, res) => {
|
|
@@ -57,12 +57,8 @@ app.get('/key/bulk', async (req, res) => {
|
|
| 57 |
try {
|
| 58 |
const game = (req.query.game || 'MLBB').toUpperCase();
|
| 59 |
const qty = Math.min(parseInt(req.query.qty) || 10, 1000);
|
| 60 |
-
|
| 61 |
const keys = [];
|
| 62 |
-
for (let i = 0; i < qty; i++)
|
| 63 |
-
keys.push(await fetchKey(game));
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
const file = `${path.tmpdir()}/${game}-${Date.now()}.txt`;
|
| 67 |
fs.writeFileSync(file, keys.join('\n'));
|
| 68 |
res.download(file, `${game}-keys.txt`, () => fs.unlinkSync(file));
|
|
|
|
| 6 |
|
| 7 |
const app = express();
|
| 8 |
const port = 7860;
|
|
|
|
| 9 |
const allowed = ['MLBB', 'BS', 'PUBG'];
|
| 10 |
+
const agent = new https.Agent({ rejectUnauthorized: false });
|
| 11 |
+
const rand = () => Array.from({ length: 4 }, () => Math.floor(Math.random() * 256)).join('.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
async function fetchKey(game) {
|
| 14 |
if (!allowed.includes(game)) throw new Error('Invalid game');
|
| 15 |
|
| 16 |
+
const idxRes = await axios({
|
| 17 |
+
url: 'https://web.aachann.my.id/Get-key/',
|
| 18 |
+
httpsAgent: agent,
|
| 19 |
+
headers: {
|
| 20 |
+
'X-Forwarded-For': rand(),
|
| 21 |
+
'X-Real-IP': rand(),
|
| 22 |
+
'Via': '1.1 ' + Math.random().toString(36).slice(2)
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
const idxTxt = idxRes.data;
|
| 26 |
const m = idxTxt.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
|
| 27 |
if (!m) throw new Error('sessionToken not found');
|
| 28 |
const sessionToken = m[1];
|
| 29 |
|
| 30 |
const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
|
| 31 |
+
const genRes = await axios({
|
| 32 |
+
url: `https://web.aachann.my.id/Get-key/genkey.php?data=${data}`,
|
| 33 |
+
httpsAgent: agent,
|
| 34 |
+
headers: {
|
| 35 |
+
'X-Forwarded-For': rand(),
|
| 36 |
+
'X-Real-IP': rand(),
|
| 37 |
+
'Via': '1.1 ' + Math.random().toString(36).slice(2)
|
| 38 |
+
}
|
| 39 |
+
});
|
| 40 |
+
const genTxt = genRes.data;
|
| 41 |
const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
|
| 42 |
if (!k) throw new Error('key not found in response');
|
| 43 |
+
return k[1]?.trim();
|
| 44 |
}
|
| 45 |
|
| 46 |
app.get('/key', async (req, res) => {
|
|
|
|
| 57 |
try {
|
| 58 |
const game = (req.query.game || 'MLBB').toUpperCase();
|
| 59 |
const qty = Math.min(parseInt(req.query.qty) || 10, 1000);
|
|
|
|
| 60 |
const keys = [];
|
| 61 |
+
for (let i = 0; i < qty; i++) keys.push(await fetchKey(game));
|
|
|
|
|
|
|
|
|
|
| 62 |
const file = `${path.tmpdir()}/${game}-${Date.now()}.txt`;
|
| 63 |
fs.writeFileSync(file, keys.join('\n'));
|
| 64 |
res.download(file, `${game}-keys.txt`, () => fs.unlinkSync(file));
|