dodd869 commited on
Commit
0c0bd21
·
verified ·
1 Parent(s): e240661

Update srv.js

Browse files
Files changed (1) hide show
  1. srv.js +53 -11
srv.js CHANGED
@@ -1,12 +1,54 @@
1
- const express=require('express'),fs=require('fs'),path=require('path'),os=require('os');
2
- const app=express(),port=7860;
3
- const allow=['MLBB','BS','PUBG'];
4
- async function pull(g){
5
- if(!allow.includes(g)) throw 0;
6
- const s=(await(await fetch('https://aamod.site/genkey/index.php')).text()).match(/sessionToken\s*=\s*["']([^"']+)/)[1];
7
- const d=Buffer.from(`game=${g}&token=${s}`).toString('base64');
8
- return (await(await fetch(`https://aamod.site/genkey/genkey.php?data=${d}`)).text()).match(/gameKey[^>]*>([^<]+)/)[1].trim();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
- app.get('/key',async(q,r)=>{try{r.json({key:await pull(q.query.game||'MLBB')})}catch{r.status(500).json({e:1})}});
11
- app.get('/key/bulk',async(q,r)=>{try{const g=q.query.game||'MLBB',n=Math.min(parseInt(q.query.qty)||10,1000),k=await Promise.all([...Array(n)].map(()=>pull(g))),f=path.join(os.tmpdir(),`${g}-${Date.now()}.txt`);fs.writeFileSync(f,k.join('\n'));r.download(f,()=>fs.unlinkSync(f))}catch{r.status(500).json({e:1})}});
12
- app.listen(port,()=>console.log(port));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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}`));