-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
70 lines (64 loc) · 2.24 KB
/
Copy pathindex.js
File metadata and controls
70 lines (64 loc) · 2.24 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const ejs = require('ejs');
const db = require('old-wio.db');
const fs = require('fs');
const axios = require('axios');
////////////////////////////////////////
const domain = 'localhost.com';
const trlinkapi_key = "your_trlinkapi_key";
////////////////////////////////////////
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', './views');
app.get('/', (req, res) => {
res.render('index');
});
app.post('/generate', async (req, res) => {
let {
type
} = req.body;
if (!type) return res.send('Please enter a type!');
let acs = JSON.parse(fs.readFileSync('./acs.json', 'utf8'));
let acsSearch = acs.find(x => x.name === type);
if (!acsSearch) return res.send('Please enter a valid type!');
function randomString(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
let id = randomString(10);
let random = acsSearch.acs[Math.floor(Math.random() * acsSearch.acs.length)];
db.set(`data_${id}`, {
status: 'alinmadi',
platform: type,
mail: random.mail,
pass: random.password
});
await axios.get(`https://ay.live/api/?api=${trlinkapi_key}&url=${domain}/gen/${id}&alias=&format=text&ct=1`).then(response => {
res.redirect(response.data);
}).catch(err => {
console.log(err);
res.send('An error occurred while creating the link!');
});
});
app.get("/gen/:id", (req, res) => {
let id = req.params.id;
let data = db.fetch(`data_${id}`);
if (!data) return res.send('This id is not valid!');
if (data.status === 'alindi') return res.send('This id is already used!');
db.set(`data_${id}`, {
status: 'alindi',
platform: data.platform,
mail: data.mail,
pass: data.pass
});
res.send(`Mail: ${data.mail} <br> Password: ${data.pass}`);
});
app.listen(80);