dodd869 commited on
Commit
bc4031b
·
verified ·
1 Parent(s): ad08e9f

Update srv.js

Browse files
Files changed (1) hide show
  1. srv.js +53 -17
srv.js CHANGED
@@ -1,20 +1,56 @@
1
- const express=require('express'),fs=require('fs'),path=require('os'),axios=require('axios'),https=require('https');
2
- const app=express(),port=7860,allowed=['MLBB','BS','PUBG'];
3
- const agent=new https.Agent({rejectUnauthorized:false});
4
- const rand=()=>[...Array(4)].map(()=>Math.floor(Math.random()*256)).join('.');
5
-
6
- async function fetchKey(g){
7
- if(!allowed.includes(g))throw'Invalid game';
8
- const i=await axios({url:'https://web.aachann.my.id/Get-key/',httpsAgent:agent,headers:{'X-Forwarded-For':rand(),'X-Real-IP':rand(),'Via':'1.1 '+Math.random().toString(36).slice(2)}});
9
- const m=i.data.match(/const sessionToken\s*=\s*["']([^"']+)["']/);
10
- if(!m)throw'No sessionToken';
11
- const t=m[1],d=Buffer.from(`game=${g}&token=${t}`).toString('base64');
12
- const r=await axios({url:`https://web.aachann.my.id/Get-key/genkey.php?data=${d}`,httpsAgent:agent,headers:{'X-Forwarded-For':rand(),'X-Real-IP':rand(),'Via':'1.1 '+Math.random().toString(36).slice(2)}});
13
- const k=r.data.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
14
- if(!k)throw'No key';
 
 
 
 
 
 
 
 
 
 
15
  return k[1].trim();
16
  }
17
 
18
- app.get('/key',async(q,p)=>{try{const g=(q.query.game||'MLBB').toUpperCase(),k=await fetchKey(g);p.json({game:g,key:k})}catch(e){p.status(500).json({error:e.message||e})}});
19
- app.get('/key/bulk',async(q,p)=>{try{const g=(q.query.game||'MLBB').toUpperCase(),n=Math.min(parseInt(q.query.qty)||10,1000),a=[];for(let i=0;i<n;i++)a.push(await fetchKey(g));const f=`${path.tmpdir()}/${g}-${Date.now()}.txt`;fs.writeFileSync(f,a.join('\n'));p.download(f,`${g}-keys.txt`,()=>fs.unlinkSync(f))}catch(e){p.status(500).json({error:e.message||e})}});
20
- app.listen(port,()=>console.log(`Running on :${port}`));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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) => {
29
+ try {
30
+ const game = (req.query.game || 'MLBB').toUpperCase();
31
+ const key = await fetchKey(game);
32
+ res.json({ game, key });
33
+ } catch (e) {
34
+ res.status(500).json({ error: e.message });
35
+ }
36
+ });
37
+
38
+ 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));
51
+ } catch (e) {
52
+ res.status(500).json({ error: e.message });
53
+ }
54
+ });
55
+
56
+ app.listen(port, () => console.log(`Running on :${port}`));