Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using System.Net.Http;
  7.  
  8. namespace App
  9. {
  10.     class Program
  11.     {
  12.         private const string url = "https://carlion.com/_register";
  13.         private const int areaCodeLength = 3;
  14.         private const int maxPhoneDigit = 8;
  15.         private const int maxLocacityDigit = 743;
  16.         private const int maxClientDigit = 10000;
  17.         private const int phoneLength = 10;
  18.         private const int sleepValue = 30000;
  19.  
  20.         [MTAThread]
  21.         static void Main()
  22.         {
  23.             Task.Factory.StartNew(async() =>
  24.             {
  25.                 while(true)
  26.                 {
  27.                     using (var client = new HttpClient())
  28.                     {
  29.                         var user     = Guid.NewGuid().ToString().Replace("-", String.Empty);
  30.                         var password = Guid.NewGuid().ToString().Replace("-", String.Empty);
  31.                         var phone    = GenerateRandomPhone();
  32.                         client.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
  33.  
  34.                         var formContent = new FormUrlEncodedContent(new[]
  35.                         {
  36.                             new KeyValuePair<string, string>("phone", $"{phone}"),
  37.                             new KeyValuePair<string, string>("email", $"{user}@yandex.ru"),
  38.                             new KeyValuePair<string, string>("password", password)
  39.                         });
  40.  
  41.                         var response = await client.PostAsync(url, formContent);
  42.                         var content  = await response.Content.ReadAsByteArrayAsync();
  43.                         Console.WriteLine($"Status code: {response.StatusCode}, User: {user}, Password: {password}");
  44.                         Console.WriteLine($"Response: {Encoding.UTF8.GetString(content)}");
  45.                         Thread.Sleep(sleepValue);
  46.                     }
  47.                 }
  48.             });
  49.  
  50.             Console.ReadLine();
  51.         }
  52.  
  53.         static string GenerateRandomPhone()
  54.         {
  55.             var random = new Random();
  56.             var number = new StringBuilder(phoneLength);
  57.  
  58.             for (var i = 0; i < areaCodeLength; i++)
  59.                 number = number.Append(random.Next(0, maxPhoneDigit).ToString());
  60.  
  61.             number.Append("-");
  62.             number.Append(String.Format("{0:D3}", random.Next(0, maxLocacityDigit)));
  63.             number.Append("-");
  64.             number.Append(String.Format("{0:D4}", random.Next(0, maxClientDigit)));
  65.             return number.ToString();
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement