|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using OpenQA.Selenium; |
| 7 | +using OpenQA.Selenium.Chrome; |
| 8 | +using System.Threading; |
| 9 | +using OpenQA.Selenium.Support.UI; |
| 10 | +using Leaf.xNet; |
| 11 | +using System.Text.RegularExpressions; |
| 12 | +using System.Net; |
| 13 | +using System.Security.Cryptography; |
| 14 | +using System.IO; |
| 15 | + |
| 16 | +namespace MS365_Creator |
| 17 | +{ |
| 18 | + class Program |
| 19 | + { |
| 20 | + static string cMail = ""; |
| 21 | + static int toWait = 0; |
| 22 | + static void Main(string[] args) |
| 23 | + { |
| 24 | + restart: |
| 25 | + Console.Clear(); |
| 26 | + Console.Title = "MS 365 Account Creator"; |
| 27 | + Console.Write("Waiting time for email (in s) (leave null for default): "); |
| 28 | + string tempAmount = Console.ReadLine(); |
| 29 | + if (tempAmount != "") toWait = int.Parse(tempAmount) * 1000; |
| 30 | + else toWait = 20000; |
| 31 | + Console.Write("Do you want to use custom details? (Yes/No): "); |
| 32 | + string useCustom = Console.ReadLine().ToLower(); |
| 33 | + if (useCustom == "") useCustom = "no"; |
| 34 | + try |
| 35 | + { |
| 36 | + if (useCustom == "yes") |
| 37 | + { |
| 38 | + Console.Title = "MS 365 Account Creator | Custom Mode"; |
| 39 | + bool usingCustom = true; |
| 40 | + Console.Write("First Name: "); |
| 41 | + string fName = Console.ReadLine(); |
| 42 | + Console.Write("Last Name: "); |
| 43 | + string lName = Console.ReadLine(); |
| 44 | + Console.Write("Custom email (no special chars): "); |
| 45 | + cMail = Console.ReadLine(); |
| 46 | + if (cMail == "") usingCustom = false; |
| 47 | + if (lName == "") lName = ""; |
| 48 | + string finalFolder = $"Accounts/{DateTime.Now.ToString("MM.dd H.mm")} - {fName} {lName}.txt"; |
| 49 | + File.AppendAllText(finalFolder, CreateAccount(fName, lName,usingCustom)); |
| 50 | + Colorful.Console.WriteLine($"Generating of custom account ({fName} | {lName} | {cMail}) done...",System.Drawing.Color.Yellow); |
| 51 | + } |
| 52 | + else |
| 53 | + { |
| 54 | + Console.Title = "MS 365 Account Creator | Mass Creation"; |
| 55 | + Console.Write("How many accounts should I prepare?: "); |
| 56 | + int toMake = int.Parse(Console.ReadLine()); |
| 57 | + string finalFolder = $"Accounts/{DateTime.Now.ToString("MM.dd H.mm")} - {toMake} accounts.txt"; |
| 58 | + int aGenerated = 0; |
| 59 | + Console.Clear(); |
| 60 | + Colorful.Console.WriteAscii(" Generating"); |
| 61 | + Colorful.Console.WriteLine($" Generated [{aGenerated}/{toMake}]", System.Drawing.Color.Yellow); |
| 62 | + for (int i = 0; i < toMake; i++) |
| 63 | + { |
| 64 | + File.AppendAllText(finalFolder, CreateAccount(GetName(), "",false)); |
| 65 | + ++aGenerated; |
| 66 | + Console.Clear(); |
| 67 | + Colorful.Console.WriteAscii(" Generating"); |
| 68 | + Colorful.Console.WriteLine($" Generated [{aGenerated}/{toMake}]", System.Drawing.Color.Yellow); |
| 69 | + |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + catch(Exception e) |
| 74 | + { |
| 75 | + Console.Clear(); |
| 76 | + Colorful.Console.Write("ERROR OCCURRED! Error message:", System.Drawing.Color.Red); Colorful.Console.Write($" {e.Message}", System.Drawing.Color.White); |
| 77 | + Console.ReadKey(); |
| 78 | + } |
| 79 | + Console.Clear(); |
| 80 | + Colorful.Console.Write("Do you want to continue generating? (Yes/No): ",System.Drawing.Color.Yellow); |
| 81 | + string output = Console.ReadLine().ToLower(); |
| 82 | + if (output == "yes") goto restart; |
| 83 | + else |
| 84 | + { |
| 85 | + Console.Clear(); |
| 86 | + Colorful.Console.Write("Created by matt", System.Drawing.Color.Lime); Colorful.Console.Write(" | ", System.Drawing.Color.Gray); Colorful.Console.Write("Press any key to exit", System.Drawing.Color.Yellow); |
| 87 | + Console.ReadKey(); |
| 88 | + } |
| 89 | + } |
| 90 | + static string CreateAccount(string fName, string lName,bool customMail) |
| 91 | + { |
| 92 | + ChromeOptions options = new ChromeOptions(); |
| 93 | + options.AddArgument("--window-size=380,700"); |
| 94 | + ChromeDriverService service = ChromeDriverService.CreateDefaultService(); |
| 95 | + service.HideCommandPromptWindow = true; //Disable the logging feature |
| 96 | + IWebDriver driver = new ChromeDriver(service,options); |
| 97 | + driver.Navigate().GoToUrl("https://xkx.me"); |
| 98 | + Thread.Sleep(2500); |
| 99 | + string email = ""; |
| 100 | + IWebElement element = driver.FindElement(By.ClassName("copyable")); |
| 101 | + if(!customMail) email = element.GetAttribute("data-clipboard-text"); |
| 102 | + else |
| 103 | + { |
| 104 | + element = driver.FindElement(By.Id("customShortid")); |
| 105 | + IJavaScriptExecutor executor = driver as IJavaScriptExecutor; |
| 106 | + executor.ExecuteScript("arguments[0].click();", element); |
| 107 | + element = driver.FindElement(By.Id("shortid")); |
| 108 | + element.SendKeys(cMail); |
| 109 | + element = driver.FindElement(By.Id("customShortid")); |
| 110 | + executor.ExecuteScript("arguments[0].click();", element); |
| 111 | + email = cMail + "@xkx.me"; |
| 112 | + } |
| 113 | + ((IJavaScriptExecutor)driver).ExecuteScript("window.open();"); |
| 114 | + driver.SwitchTo().Window(driver.WindowHandles.Last()); |
| 115 | + driver.Navigate().GoToUrl("https://signup.microsoft.com/signup?sku=student"); |
| 116 | + Thread.Sleep(2500); |
| 117 | + element = driver.FindElement(By.Id("StepsData_Email")); |
| 118 | + element.SendKeys(email); |
| 119 | + element = driver.FindElement(By.ClassName("mpl-button-next-text")); |
| 120 | + element.Click(); |
| 121 | + driver.SwitchTo().Window(driver.WindowHandles.First()); |
| 122 | + Thread.Sleep(toWait); |
| 123 | + element = driver.FindElement(By.Id("emaillist")); |
| 124 | + Match verCode = Regex.Match(element.Text, "([0-9]{6})", RegexOptions.IgnoreCase); |
| 125 | + driver.SwitchTo().Window(driver.WindowHandles.Last()); |
| 126 | + element = driver.FindElement(By.Id("FirstName")); |
| 127 | + element.SendKeys(fName); |
| 128 | + element = driver.FindElement(By.Id("LastName")); |
| 129 | + element.SendKeys(lName); |
| 130 | + element = driver.FindElement(By.Id("Password")); |
| 131 | + string password = GeneratePassword(10); |
| 132 | + element.SendKeys(password); |
| 133 | + element = driver.FindElement(By.Id("RePassword")); |
| 134 | + element.SendKeys(password); |
| 135 | + element = driver.FindElement(By.Id("SignupCode")); |
| 136 | + element.SendKeys(verCode.Value); |
| 137 | + element = driver.FindElement(By.ClassName("mpl-button-next-text")); |
| 138 | + element.Click(); |
| 139 | + driver.Quit(); |
| 140 | + return $"Username : {email}\nPassword : {password}\n************************************\n"; |
| 141 | + } |
| 142 | + static string GetName() |
| 143 | + { |
| 144 | + string[] names = { "Jennifer", "Patrick", "Carola", "Frank", "Aaron", "Willie", "Joseph" }; |
| 145 | + Random random = new Random(); |
| 146 | + int num = random.Next(0, names.Length-1); |
| 147 | + return names[num]; |
| 148 | + } |
| 149 | + static string GeneratePassword(int length) |
| 150 | + { |
| 151 | + const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
| 152 | + StringBuilder res = new StringBuilder(); |
| 153 | + Random rnd = new Random(); |
| 154 | + while (0 < length--) |
| 155 | + { |
| 156 | + res.Append(valid[rnd.Next(valid.Length)]); |
| 157 | + } |
| 158 | + return res.ToString(); |
| 159 | + } |
| 160 | + } |
| 161 | +} |
0 commit comments