private void butRegister_Click(object sender, EventArgs e) { //try //{ // StreamReader srHwid1 = new StreamReader("C:\\details.enc"); // StreamReader srHwid2 = new StreamReader("C:\\Program Files\\Project Serenity\\details.enc"); //} //catch (Exception) //{ // MessageBox.Show("Error! You don't appear to be registered. This shouldn't happen. Tell laxai to get good at coding"); // return; //} if (File.Exists("Serenity.log")) { File.Delete("Serenity.log"); } SecureString path1 = new NetworkCredential("", "C:\\details.enc").SecurePassword; SecureString path2 = new NetworkCredential("", "C:\\Program Files\\Project Serenity\\details.enc").SecurePassword; StreamWriter log = new StreamWriter("Serenity.log"); log.WriteLine("Getting HWID"); string hwid1 = GetHwid1("C:\\").ToString(); string hwid2 = GetHwid2(); string hwid = hwid1 + hwid2; hwid = hwid.ToLower(); log.WriteLine("Got HWID"); SecureString password = new NetworkCredential("", "Hacks69").SecurePassword; SecureString username = new NetworkCredential("", "b6_22246603").SecurePassword; SecureString server = new NetworkCredential("", "ftp://ftp.byethost6.com").SecurePassword; string test = new NetworkCredential("", server).Password; log.WriteLine("Connecting to ftp"); Misc.Ftp ftp = new Misc.Ftp(new NetworkCredential("", server).Password, new NetworkCredential("", username).Password, new NetworkCredential("", password).Password); log.WriteLine("Connected"); string[] dirs = ftp.directoryListSimple("htdocs/"); log.WriteLine("Searching for user"); foreach (string dir in dirs) { if (dir == Misc.Enc.Encrypt(txtUsername.Text)) { log.WriteLine("Already Registered"); MessageBox.Show("Username in use. Contact laxai if the account is yours."); return; } } log.WriteLine("Username not in use"); Random rand = new Random(); string randKey = ""; for (int i = 0; i < 4; i++) { randKey += rand.Next(11000000, 98999999).ToString(); } string randIv = ""; for (int i = 0; i < 2; i++) { randIv += rand.Next(11000000, 98999999).ToString(); } log.WriteLine("Generated random encryption stuffs"); log.Close(); string out1 = Misc.Enc.Encrypt(randIv); string out2 = Misc.Enc.Encrypt(randKey); string out3 = Misc.Enc.Encrypt(txtUsername.Text, randIv, randKey); string out4 = Misc.Enc.Encrypt(txtPassword.Text, randIv, randKey); string out5 = Misc.Enc.Encrypt(hwid, randIv, randKey); string lengths = out1.Length.ToString() + out2.Length.ToString() + out3.Length.ToString() + out4.Length.ToString() + out5.Length.ToString(); Output output = new Output(); Output.strOutput = lengths + out1 + out2 + out3 + out4 + out5; if (!Directory.Exists("C:\\Program Files\\Project Serenity")) { Directory.CreateDirectory("C:\\Program Files\\Project Serenity"); } StreamWriter swTemp = new StreamWriter(new NetworkCredential("", path2).Password); for (int i = 0; i < 10; i++) { swTemp.WriteLine(rand.Next(0, 2000000000).ToString() + rand.Next(0, 2000000000).ToString()); } swTemp.Close(); path2.Clear(); if (File.Exists(new NetworkCredential("", path1).Password)) { File.SetAttributes(new NetworkCredential("", path1).Password, FileAttributes.Normal); File.Delete(new NetworkCredential("", path1).Password); } StreamWriter swHwid = new StreamWriter(new NetworkCredential("", path1).Password); swHwid.WriteLine(out1); swHwid.WriteLine(out2); swHwid.WriteLine(out3); swHwid.WriteLine(out4); swHwid.WriteLine(out5); swHwid.Close(); File.SetAttributes(new NetworkCredential("", path1).Password, FileAttributes.Hidden); Properties.Settings.Default.FirstLaunch = false; Properties.Settings.Default.Save(); output.Show(); this.Hide(); }
private void butLogin_Click(object sender, EventArgs e) { SecureString path1 = new NetworkCredential("", "C:\\details.enc").SecurePassword; SecureString path2 = new NetworkCredential("", "C:\\Program Files\\Project Serenity\\details.enc").SecurePassword; SecureString pathDetails = new NetworkCredential("", "details.enc").SecurePassword; StreamReader srHwid1; try { srHwid1 = new StreamReader(new NetworkCredential("", path1).Password); Thread.Sleep(5); } catch (Exception) { MessageBox.Show("Error! You don't appear to be registered. This should never happen"); return; } if (!File.Exists(new NetworkCredential("", path2).Password)) { return; } else { File.Delete(new NetworkCredential("", path2).Password); } StreamWriter swTemp = new StreamWriter(new NetworkCredential("", path2).Password); Random rand = new Random(); for (int i = 0; i < 10; i++) { swTemp.WriteLine(rand.Next(0, 2000000)); } swTemp.Close(); if (File.Exists("Serenity.log")) { File.Delete("Serenity.log"); } if (File.Exists(new NetworkCredential("", pathDetails).Password)) { File.Delete(new NetworkCredential("", pathDetails).Password); } StreamWriter log = new StreamWriter("Serenity.log"); log.WriteLine("Getting HWID"); string tempHwid1 = GetHwid1("C:\\").ToString(); string tempHwid2 = GetHwid2(); string thisHwid = tempHwid1 + tempHwid2; thisHwid = thisHwid.ToLower(); log.WriteLine("Got HWID"); SecureString ftpPass = new NetworkCredential("", "Hadsfsdfsdf9").SecurePassword; SecureString ftpUser = new NetworkCredential("", "basdasd3").SecurePassword; SecureString ftpServer = new NetworkCredential("", "urlllllllllllllllllllllllllllllllllllll f*****g kill me").SecurePassword; log.WriteLine("Connecting to ftp"); Misc.Ftp ftp = new Misc.Ftp(new NetworkCredential("", ftpServer).Password, new NetworkCredential("", ftpUser).Password, new NetworkCredential("", ftpPass).Password); log.WriteLine("Connected"); log.WriteLine("Searching for user"); string[] dirs = ftp.directoryListSimple("htdocs/"); bool foundUser = false; string iv = Misc.Enc.Decrypt(srHwid1.ReadLine()); string key = Misc.Enc.Decrypt(srHwid1.ReadLine()); string encUsername = srHwid1.ReadLine(); string username = Misc.Enc.Decrypt(encUsername, iv, key); string encPassword = srHwid1.ReadLine(); string hwid = Misc.Enc.Decrypt(srHwid1.ReadLine(), iv, key); srHwid1.Close(); string unOnServer = Regex.Replace(encUsername, "[^0-9a-zA-Z]+", ""); if (hwid != thisHwid) { log.WriteLine("HWID doesn't match"); MessageBox.Show("Incorrect HWID"); } foreach (string dir in dirs) { if (dir == unOnServer && username.ToLower() == txtUsername.Text.ToLower()) { log.WriteLine("Found User " + username); foundUser = true; } } if (!foundUser) { MessageBox.Show("We didn't recognise that username. Please note it is case sensitive"); return; } try { ftp.download("htdocs/" + unOnServer + "/details.enc", "details.enc"); Thread.Sleep(5); File.SetAttributes(new NetworkCredential("", pathDetails).Password, FileAttributes.Hidden); } catch (Exception) { } if (!File.Exists("details.enc")) { log.WriteLine("Error With Ftp Server"); return; } StreamReader srHwid2 = new StreamReader(new NetworkCredential("", pathDetails).Password); srHwid2.ReadLine(); srHwid2.ReadLine(); string encUsername2 = srHwid2.ReadLine(); log.WriteLine("Getting remote login info"); string username2 = Misc.Enc.Decrypt(encUsername, iv, key); string encPassword2 = srHwid2.ReadLine(); string hwid2 = Misc.Enc.Decrypt(srHwid2.ReadLine(), iv, key); if (hwid2 != thisHwid || hwid != hwid2) { log.WriteLine("HWID doesn't match"); MessageBox.Show("Incorrect HWID"); } if (encPassword != encPassword2) { log.WriteLine("Password doesn't match"); return; } log.WriteLine("Checking Password"); if (encPassword != Misc.Enc.Encrypt(txtPassword.Text, iv, key)) { log.WriteLine("Error password doesn't match"); MessageBox.Show("Password incorrect"); } MessageBox.Show("Login Successful!"); }