dodd869 commited on
Commit
ffe24d8
·
verified ·
1 Parent(s): 82bbf24

Update srv.js

Browse files
Files changed (1) hide show
  1. srv.js +7 -12
srv.js CHANGED
@@ -2,27 +2,26 @@ const express = require('express');
2
  const fs = require('fs');
3
  const path = require('os');
4
  const axios = require('axios');
 
5
 
6
  const app = express();
7
  const port = 7860;
8
-
9
  const allowed = ['MLBB', 'BS', 'PUBG'];
10
 
11
  async function fetchKey(game) {
12
  if (!allowed.includes(game)) throw new Error('Invalid game');
13
 
14
  const idxRes = await axios.get('https://web.aachann.my.id/Get-key/');
15
- const idxTxt = idxRes.data;
16
- const m = idxTxt.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
17
  if (!m) throw new Error('sessionToken not found');
18
  const sessionToken = m[1];
19
 
20
  const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
21
  const genRes = await axios.get(`https://web.aachann.my.id/Get-key/genkey.php?data=${data}`);
22
- const genTxt = genRes.data;
23
- const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
24
- if (!k) throw new Error('key not found in response');
25
- return k[1].trim();
26
  }
27
 
28
  app.get('/key', async (req, res) => {
@@ -39,12 +38,8 @@ app.get('/key/bulk', async (req, res) => {
39
  try {
40
  const game = (req.query.game || 'MLBB').toUpperCase();
41
  const qty = Math.min(parseInt(req.query.qty) || 10, 1000);
42
-
43
  const keys = [];
44
- for (let i = 0; i < qty; i++) {
45
- keys.push(await fetchKey(game));
46
- }
47
-
48
  const file = `${path.tmpdir()}/${game}-${Date.now()}.txt`;
49
  fs.writeFileSync(file, keys.join('\n'));
50
  res.download(file, `${game}-keys.txt`, () => fs.unlinkSync(file));
 
2
  const fs = require('fs');
3
  const path = require('os');
4
  const axios = require('axios');
5
+ const cheerio = require('cheerio');
6
 
7
  const app = express();
8
  const port = 7860;
 
9
  const allowed = ['MLBB', 'BS', 'PUBG'];
10
 
11
  async function fetchKey(game) {
12
  if (!allowed.includes(game)) throw new Error('Invalid game');
13
 
14
  const idxRes = await axios.get('https://web.aachann.my.id/Get-key/');
15
+ const m = idxRes.data.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
 
16
  if (!m) throw new Error('sessionToken not found');
17
  const sessionToken = m[1];
18
 
19
  const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
20
  const genRes = await axios.get(`https://web.aachann.my.id/Get-key/genkey.php?data=${data}`);
21
+ const $ = cheerio.load(genRes.data);
22
+ const key = $('#gameKey').text().trim();
23
+ if (!key) throw new Error('key not found in response');
24
+ return key;
25
  }
26
 
27
  app.get('/key', async (req, res) => {
 
38
  try {
39
  const game = (req.query.game || 'MLBB').toUpperCase();
40
  const qty = Math.min(parseInt(req.query.qty) || 10, 1000);
 
41
  const keys = [];
42
+ for (let i = 0; i < qty; i++) keys.push(await fetchKey(game));
 
 
 
43
  const file = `${path.tmpdir()}/${game}-${Date.now()}.txt`;
44
  fs.writeFileSync(file, keys.join('\n'));
45
  res.download(file, `${game}-keys.txt`, () => fs.unlinkSync(file));