Advertisement
Guest User

AccountCreator

a guest
Apr 19th, 2019
2,668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 20.79 KB | None | 0 0
  1. using HtmlAgilityPack;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using OpenQA.Selenium;
  5. using OpenQA.Selenium.Chrome;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Net;
  14. using System.Text;
  15. using System.Text.RegularExpressions;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. using System.Windows.Forms;
  19.  
  20. namespace TwitchAccountManager
  21. {
  22.     public partial class frmAccountCreate : Form
  23.     {
  24.         delegate void StringArgReturningVoidDelegate(string text);
  25.         List<BackgroundWorker> workers = new List<BackgroundWorker>();
  26.         List<string> proxies = new List<string>(File.ReadAllLines("proxies.txt"));
  27.         string[] adjectives = File.ReadAllLines("adjectives.txt");
  28.         string[] nouns = File.ReadAllLines("nouns.txt");
  29.         Queue<string> proxy_list = null;
  30.         List<string> avaliable_usernames = new List<string>();
  31.         bool generating_usernames = false;
  32.         bool running = false;
  33.         string api_key = "";
  34.         Random rand = new Random();
  35.         public frmAccountCreate()
  36.         {
  37.             InitializeComponent();
  38.         }
  39.  
  40.         private void frmAccountCreate_Load(object sender, EventArgs e)
  41.         {
  42.            
  43.         }
  44.  
  45.         private void btnStart_Click(object sender, EventArgs e)
  46.         {
  47.             running = true;
  48.             txtStatus.Text = "Running";
  49.             txtStatus.ForeColor = Color.Green;
  50.             api_key = inputApiKey.Text;
  51.             for (int i = 0; i < numThreads.Value; i++)
  52.             {
  53.                 CreateWorker(0, "");
  54.             }
  55.         }
  56.  
  57.         private void CreateWorker(int delay, string name)
  58.         {
  59.             BackgroundWorker worker = new BackgroundWorker();
  60.             worker.DoWork += (obj, e) => BackgroundWorker_DoWork(delay, name);
  61.             worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker_RunWorkerCompleted);
  62.             worker.ProgressChanged += new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);
  63.             worker.WorkerReportsProgress = true;
  64.             worker.RunWorkerAsync();
  65.  
  66.             txtThreadCount.Text = (Int32.Parse(txtThreadCount.Text) + 1).ToString();
  67.         }
  68.  
  69.         private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
  70.         {
  71.             txtLog.Text = e.UserState as string + "\n";
  72.         }
  73.  
  74.         private void btnStop_Click(object sender, EventArgs e)
  75.         {
  76.             running = false;
  77.             txtStatus.Text = "Not Running";
  78.             txtStatus.ForeColor = Color.Red;
  79.         }
  80.  
  81.         private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  82.         {
  83.             txtThreadCount.Text = (Int32.Parse(txtThreadCount.Text) - 1).ToString();
  84.             if (e.Error != null)
  85.             {
  86.                 txtErrorCount.Text = (Int32.Parse(txtErrorCount.Text)+1).ToString();
  87.             }
  88.             else
  89.             {
  90.                 txtAccountCount.Text = (Int32.Parse(txtAccountCount.Text) + 1).ToString();
  91.             }
  92.  
  93.             if (running)
  94.                 CreateWorker(0, "");
  95.         }
  96.  
  97.         private void BackgroundWorker_DoWork(int delay, string name)
  98.         {
  99.             //Stagger for CPU
  100.             Thread.Sleep(delay);
  101.             string username = "";
  102.  
  103.             if (name == "")
  104.                 username = GenerateUsername();
  105.             else
  106.                 username = name;
  107.             string password = GeneratePassword();
  108.             int index = rand.Next(0, proxies.Count);
  109.             if (proxy_list == null || proxy_list.Count == 0)
  110.                 proxy_list = new Queue<string>(proxies);
  111.             string proxy_url = proxy_list.Dequeue();
  112.             string key = "6Lcjjl8UAAAAAMCzOHbJj-yb2MBElPKqZmlE5bbL";
  113.  
  114.             string request1 = String.Format("http://2captcha.com/in.php?key={0}&method=userrecaptcha&googlekey={1}&pageurl={2}&json=1", api_key, key, "https://www.twitch.tv/signup");
  115.             NoKeepAlivesWebClient client = new NoKeepAlivesWebClient();
  116.             BetterWebClient email_client = new BetterWebClient();
  117.  
  118.             JObject result = JObject.Parse(client.DownloadString(request1));
  119.  
  120.             Thread.Sleep(25000);
  121.  
  122.             string id = result["request"].ToString();
  123.             bool ready = false;
  124.             string result_key = "";
  125.  
  126.             while (!ready)
  127.             {
  128.                 string request2 = String.Format("http://2captcha.com/res.php?key={0}&action=get&id={1}&json=1", api_key, id);
  129.                 JObject result2 = JObject.Parse(client.DownloadString(request2));
  130.                 Console.WriteLine(result2);
  131.  
  132.                 if (result2["request"].ToString() != "CAPCHA_NOT_READY")
  133.                 {
  134.                     ready = true;
  135.                     result_key = result2["request"].ToString();
  136.                 }
  137.                 Thread.Sleep(500);
  138.             }      
  139.  
  140.             //Dunno if all of these headers are needed, but doesn't hurt
  141.             client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
  142.             client.Headers.Add("origin", "https://www.twitch.tv");
  143.             client.Headers.Add("referer", "https://www.twitch.tv/directory");
  144.             client.Headers.Add("accept", "*/*");
  145.             client.Headers.Add("accept-encoding", "gzip, deflate, br");
  146.             client.Headers.Add("accept-language", "en-US,en;q=0.9");
  147.             WebProxy wp = new WebProxy(proxy_url.Split(':')[0], int.Parse(proxy_url.Split(':')[1]));
  148.             client.Proxy = wp;
  149.             email_client.Proxy = wp;
  150.             string email_id = RandomString(10);
  151.  
  152.             JObject mail_details = JObject.Parse(email_client.DownloadString("http://api.guerrillamail.com/ajax.php?f=set_email_user&ip=127.0.0.1&agent=Mozilla_foo_bar&email_user=" + email_id));
  153.  
  154.             Payload payload = new Payload(username, password, mail_details["alias"].ToString() + "@pokemail.net", "kimne78kx3ncx6brgo4mv6wki5h1ko", new Birthday(rand.Next(1, 13), rand.Next(1, 20), rand.Next(1980,1995)), new Captcha(key, result_key));
  155.             string json = JsonConvert.SerializeObject(payload, Formatting.None);
  156.  
  157.             try
  158.             {
  159.                 string res = client.UploadString("https://passport.twitch.tv/register", json);
  160.                 JObject response = JObject.Parse(res);
  161.                 client.Headers.Add("Client-Id", "kimne78kx3ncx6brgo4mv6wki5h1ko");
  162.                 client.Headers.Add("Authorization", "OAuth " + response["access_token"].ToString());
  163.                 client.UploadString("https://gql.twitch.tv/gql", "[{\"operationName\":\"FollowButton_FollowUser\",\"variables\":{\"input\":{\"disableNotifications\":false,\"targetID\":\"71092938\"}},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"51956f0c469f54e60211ea4e6a34b597d45c1c37b9664d4b62096a1ac03be9e6\"}}}]");
  164.                 client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json");
  165.                 JObject channel_info = JObject.Parse(client.DownloadString("https://api.twitch.tv/kraken/users?login=" + username));
  166.                 client.Headers.Remove("Accept");
  167.                 string channel_id = channel_info["users"][0]["_id"].ToString();
  168.                 File.AppendAllText("accounts.txt", username + "," + response["access_token"].ToString() + "," + password  + "," + channel_id + "," + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + Environment.NewLine);
  169.                 AppendLog("Created Account " + username);
  170.  
  171.                 try
  172.                 {
  173.                     using (NoKeepAlivesWebClient client2 = new NoKeepAlivesWebClient())
  174.                     {
  175.                         client2.Proxy = wp;
  176.                         client2.Headers.Add("accept", "application/vnd.twitchtv.v5+json; charset=UTF-8");
  177.                         client2.Headers.Add("accept-encoding", "gzip, deflate, br");
  178.                         client2.Headers.Add("accept-language", "en-us");
  179.                         client2.Headers.Add("authorization", "OAuth " + response["access_token"].ToString());
  180.                         client2.Headers.Add("client-id", "kimne78kx3ncx6brgo4mv6wki5h1ko");
  181.                         client2.Headers.Add("content-type", "application/json; charset=UTF-8");
  182.                         client2.Headers.Add("origin", "https://www.twitch.tv");
  183.                         client2.Headers.Add("referer", "https://www.twitch.tv/settings/profile");
  184.                         client2.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
  185.                         client2.Headers.Add("x-requested-with", "XMLHttpRequest");
  186.                         string responsea = client2.UploadString("https://api.twitch.tv/kraken/users/" + channel_id, "PUT", "{\"displayname\":\"" + username + "\",\"description\":\"\",\"on_site\":1}");
  187.                     }
  188.                 }
  189.                 catch
  190.                 {
  191.  
  192.                 }
  193.  
  194.                 bool found_email = false;
  195.  
  196.                 int counter = 0;
  197.                 while (!found_email && counter < 14)
  198.                 {
  199.                     JObject emails = JObject.Parse(email_client.DownloadString("http://api.guerrillamail.com/ajax.php?f=check_email&ip=127.0.0.1&agent=Mozilla_foo_bar&seq=0"));
  200.                     foreach (JToken email in emails["list"])
  201.                     {
  202.                         if (email["mail_from"].ToString().Contains("twitch.tv") && email["mail_subject"].ToString() == "Please verify your email address")
  203.                         {
  204.                             JObject email_content = JObject.Parse(email_client.DownloadString("http://api.guerrillamail.com/ajax.php?f=fetch_email&ip=127.0.0.1&agent=Mozilla_foo_bar&email_id=" + email["mail_id"].ToString()));
  205.                             HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
  206.                             htmlDocument.LoadHtml(email_content["mail_body"].ToString());
  207.                             foreach (HtmlNode link in htmlDocument.DocumentNode.SelectNodes("//a[@href]"))
  208.                             {
  209.                                 HtmlAttribute att = link.Attributes["href"];
  210.                                 if (att.Value.Contains("tt_content=email_verifier") && att.Value.Contains("email-verification"))
  211.                                 {
  212.                                     email_client.DownloadString(att.Value);
  213.                                     int firstIndex = att.Value.IndexOf("email-verification/") + "email-verification/".Length;
  214.                                     string token = att.Value.Substring(firstIndex, 32);
  215.                                     client = new NoKeepAlivesWebClient();
  216.                                     client.Proxy = wp;
  217.                                     client.Headers.Add("accept", "application/vnd.twitchtv.v5+json; charset=UTF-8");
  218.                                     client.Headers.Add("authorization", "OAuth " + response["access_token"].ToString());
  219.                                     client.Headers.Add("client-id", "jzkbprff40iqj646a697cyrvl0zt2m6");
  220.                                     client.Headers.Add("origin", "https://www.twitch.tv");
  221.                                     client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
  222.                                     client.Headers.Add("x-requested-with", "XMLHttpRequest");
  223.                                     client.UploadString("https://api.twitch.tv/v5/emailvalidator/" + token, "");
  224.                                     AppendLog(username + " verified email");
  225.  
  226.  
  227.                                     found_email = true;
  228.                                     break;
  229.                                 }
  230.                             }
  231.                             if (found_email)
  232.                                 break;
  233.                         }
  234.                     }
  235.                     if (!found_email)
  236.                         Thread.Sleep(10000);
  237.                     counter++;
  238.                 }
  239.  
  240.                 if (counter == 8 && !found_email)
  241.                 {
  242.                     File.AppendAllText("failed_emails.txt", username + Environment.NewLine);
  243.                     AppendLog(username + " failed to verify email");
  244.                 }
  245.             }
  246.             catch (WebException ex)
  247.             {
  248.                 if (ex.Response != null)
  249.                 {
  250.                     var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
  251.                     AppendLog("ERROR! " + resp);
  252.  
  253.                     if (resp.ToLower().Contains("blacklist") || resp.ToLower().Contains("throttle"))
  254.                     {
  255.                         proxies.RemoveAt(index);
  256.                     }
  257.                 }
  258.                 else
  259.                 {
  260.                     AppendLog("ERROR creating account");
  261.                 }
  262.                 throw new Exception("RIP");
  263.             }
  264.         }
  265.  
  266.         public bool isUsernameAvaliable(string username)
  267.         {
  268.             bool good_username = false;
  269.             using (NoKeepAlivesWebClient username_client = new NoKeepAlivesWebClient())
  270.             {
  271.                 username_client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
  272.                 username_client.Headers.Add("origin", "https://www.twitch.tv");
  273.                 username_client.Headers.Add("referer", "https://www.twitch.tv/directory");
  274.                 username_client.Headers.Add("client-id", "kimne78kx3ncx6brgo4mv6wki5h1ko");
  275.                 username_client.Headers.Add("accept", "*/*");
  276.                 username_client.Headers.Add("accept-encoding", "gzip, deflate, br");
  277.                 username_client.Headers.Add("accept-language", "en-US,en;q=0.9");
  278.  
  279.                 try
  280.                 {
  281.                     JObject response = JObject.Parse(username_client.UploadString("https://gql.twitch.tv/gql", "[{\"operationName\":\"UsernameValidator_User\",\"variables\":{\"username\":\"" + username + "\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"fd1085cf8350e309b725cf8ca91cd90cac03909a3edeeedbd0872ac912f3d660\"}}}]"));
  282.                     if (response["data"]["isUsernameAvailable"].ToString() == "true")
  283.                     {
  284.                         good_username = true;
  285.                     }
  286.                 }
  287.                 catch
  288.                 {
  289.                     //If fails just assume username is fine
  290.                     good_username = true;
  291.                 }
  292.             }
  293.             return good_username;
  294.         }
  295.  
  296.         private string GenerateUsername()
  297.         {
  298.             if (avaliable_usernames.Count == 0)
  299.             {
  300.                 if (generating_usernames)
  301.                 {
  302.                     Thread.Sleep(5000);
  303.                     return GenerateUsername();
  304.                 }
  305.                 //Let's get more usernames!
  306.                 generating_usernames = true;
  307.                 HtmlWeb web = new HtmlWeb();
  308.                 HtmlAgilityPack.HtmlDocument doc = web.Load("https://jimpix.co.uk/words/random-username-list.asp");
  309.  
  310.                 foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//ul[@class='list-unstyled']/li"))
  311.                 {
  312.                     string username = node.GetAttributeValue("id", "error");
  313.                     if (username != "error")
  314.                         avaliable_usernames.Add(username);
  315.                 }
  316.                 generating_usernames = false;
  317.             }
  318.  
  319.             string output = "";
  320.             string seperator = "";
  321.             string end = "";
  322.             string beginning = "";
  323.             int index = rand.Next(0, avaliable_usernames.Count);
  324.             string first_part = avaliable_usernames[index].Split('.')[0];
  325.             if (rand.Next(1, 3) == 2)
  326.                 first_part = Char.ToUpper(first_part[0]) + first_part.Substring(1);
  327.             string second_part = avaliable_usernames[index].Split('.')[1];
  328.             if (rand.Next(1,3) == 2 && Char.IsUpper(first_part[0]))
  329.                 second_part = Char.ToUpper(second_part[0]) + second_part.Substring(1);
  330.             avaliable_usernames.RemoveAt(index);
  331.  
  332.             //Randomized pattern of usernames
  333.             int choice = rand.Next(1, 12);
  334.             if (choice == 1)
  335.                 seperator = "_";
  336.             else if (choice > 1)
  337.                 seperator = "";
  338.  
  339.             choice = rand.Next(1, 9);
  340.             if (choice == 1)
  341.                 beginning += (char)('a' + rand.Next(0,26));
  342.             else if (choice > 1)
  343.             {
  344.                 if (rand.Next(1, 30) == 1)
  345.                     beginning = "x";
  346.                 else
  347.                     beginning = "";
  348.             }
  349.                    
  350.             choice = rand.Next(1, 12);
  351.             if (choice == 1)
  352.                 end = "_";
  353.             else if (choice == 2)
  354.                 end += (char)('a' + rand.Next(0, 26));
  355.             if (choice == 3)
  356.                 end = rand.Next(1,10).ToString();
  357.             else if (choice > 3)
  358.             {
  359.                 if (rand.Next(1, 20) == 1)
  360.                     end = "x";
  361.                 else
  362.                     end = "";
  363.             }
  364.             if (rand.Next(1, 30) == 29)
  365.                 second_part = second_part.ToUpper();
  366.  
  367.             output = beginning + first_part + seperator + second_part + end;
  368.  
  369.             var match = Regex.Match(output, @"^[a-zA-Z0-9_]{4,25}$", RegexOptions.IgnoreCase);
  370.             if (!match.Success || !isUsernameAvaliable(output))
  371.                 return GenerateUsername();
  372.             else
  373.             {
  374.                 return output;
  375.             }
  376.                
  377.         }
  378.  
  379.         private string GeneratePassword()
  380.         {
  381.             if (checkPassword.Checked && inputPassword.Text.Trim() != "")
  382.                 return inputPassword.Text.Trim();
  383.             else
  384.                 return (adjectives[rand.Next(0, adjectives.Length)] + nouns[rand.Next(0, nouns.Length)] + rand.Next(0, 10) + rand.Next(0, 10)).Replace(" ", "");
  385.         }
  386.  
  387.         public string RandomString(int length)
  388.         {
  389.             var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  390.             var stringChars = new char[8];
  391.  
  392.             for (int i = 0; i < stringChars.Length; i++)
  393.             {
  394.                 stringChars[i] = chars[rand.Next(chars.Length)];
  395.             }
  396.             return new String(stringChars);
  397.         }
  398.  
  399.         private void AppendLog(string text)
  400.         {
  401.             if (txtLog.InvokeRequired)
  402.             {
  403.                 StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(AppendLog);
  404.                 Invoke(d, new object[] { text });
  405.             }
  406.             else
  407.             {
  408.                 txtLog.Text = txtLog.Text + text + "\n";
  409.             }
  410.         }
  411.  
  412.         private void txtLog_TextChanged(object sender, EventArgs e)
  413.         {
  414.             txtLog.ScrollToCaret();
  415.         }
  416.  
  417.         private void button1_Click(object sender, EventArgs e)
  418.         {
  419.             for (int i = 0; i < 10; i++)
  420.             {
  421.                 AppendLog(GenerateUsername());
  422.             }
  423.         }
  424.  
  425.         private void button2_Click(object sender, EventArgs e)
  426.         {
  427.             string name = Microsoft.VisualBasic.Interaction.InputBox("Prompt", "Name of account?", "", 100, 200).Trim();
  428.  
  429.             CreateWorker(0, name);
  430.         }
  431.     }
  432.  
  433.     public class Birthday
  434.     {
  435.         public Birthday(int Day, int Month, int Year)
  436.         {
  437.             day = Day;
  438.             month = Month;
  439.             year = Year;
  440.         }
  441.         public int day { get; set; }
  442.         public int month { get; set; }
  443.         public int year { get; set; }
  444.     }
  445.  
  446.     public class Captcha
  447.     {
  448.         public Captcha(string Key, string Value)
  449.         {
  450.             key = Key;
  451.             value = Value;
  452.         }
  453.         public string key { get; set; }
  454.         public string value { get; set; }
  455.     }
  456.  
  457.     public class Payload
  458.     {
  459.         public Payload(string Username, string Password, string Email, string Client_id, Birthday bd, Captcha cp)
  460.         {
  461.             username = Username;
  462.             password = Password;
  463.             email = Email;
  464.             client_id = Client_id;
  465.             birthday = bd;
  466.             captcha = cp;
  467.         }
  468.  
  469.         public string username { get; set; }
  470.         public string password { get; set; }
  471.         public string email { get; set; }
  472.         public Birthday birthday { get; set; }
  473.         public string client_id { get; set; }
  474.         public Captcha captcha { get; set; }
  475.     }
  476. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement