├── Console Example ├── Auth.GG Example.sln └── Auth.GG Example │ ├── API.cs │ ├── App.config │ ├── Auth.GG Example.csproj │ ├── Program.cs │ └── Properties │ └── AssemblyInfo.cs └── README.md /Console Example/Auth.GG Example.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29806.167 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Auth.GG Example", "Auth.GG Example\Auth.GG Example.csproj", "{139B021F-DFD8-4CDF-B282-040A0A5F9903}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {139B021F-DFD8-4CDF-B282-040A0A5F9903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {139B021F-DFD8-4CDF-B282-040A0A5F9903}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {139B021F-DFD8-4CDF-B282-040A0A5F9903}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {139B021F-DFD8-4CDF-B282-040A0A5F9903}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5FA81C43-014F-4990-A430-B3DA1EAF59FF} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Console Example/Auth.GG Example/API.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Management; 8 | using System.Net; 9 | using System.Net.NetworkInformation; 10 | using System.Net.Security; 11 | using System.Security.Cryptography; 12 | using System.Security.Cryptography.X509Certificates; 13 | using System.Security.Principal; 14 | using System.Text; 15 | using System.Text.RegularExpressions; 16 | using System.Threading; 17 | using System.Windows; 18 | 19 | namespace AuthGG 20 | { 21 | internal class App 22 | { 23 | public static string GrabVariable(string name) 24 | { 25 | try 26 | { 27 | if (User.ID != null || User.HWID != null || User.IP != null || !Constants.Breached) 28 | { 29 | return Variables[name]; 30 | } 31 | else 32 | { 33 | Constants.Breached = true; 34 | return "User is not logged in, possible breach detected!"; 35 | } 36 | } 37 | catch 38 | { 39 | return "N/A"; 40 | } 41 | } 42 | public static string Error = null; 43 | public static Dictionary Variables = new Dictionary(); 44 | } 45 | internal class Constants 46 | { 47 | public static string Token { get; set; } 48 | 49 | public static string Date { get; set; } 50 | 51 | public static string APIENCRYPTKEY { get; set; } 52 | 53 | public static string APIENCRYPTSALT { get; set; } 54 | 55 | public static bool Breached = false; 56 | 57 | public static bool Started = false; 58 | 59 | public static string IV = null; 60 | 61 | public static string Key = null; 62 | 63 | public static string ApiUrl = "https://api.auth.gg/csharp/"; 64 | 65 | public static bool Initialized = false; 66 | 67 | public static Random random = new Random(); 68 | 69 | public static string RandomString(int length) 70 | { 71 | return new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", length).Select(s => s[random.Next(s.Length)]).ToArray()); 72 | } 73 | 74 | public static string HWID() 75 | { 76 | return WindowsIdentity.GetCurrent().User.Value; 77 | } 78 | } 79 | internal class User 80 | { 81 | public static string ID { get; set; } 82 | 83 | public static string Username { get; set; } 84 | 85 | public static string Password { get; set; } 86 | 87 | public static string Email { get; set; } 88 | 89 | public static string HWID { get; set; } 90 | 91 | public static string IP { get; set; } 92 | 93 | public static string UserVariable { get; set; } 94 | 95 | public static string Rank { get; set; } 96 | 97 | public static string Expiry { get; set; } 98 | 99 | public static string LastLogin { get; set; } 100 | 101 | public static string RegisterDate { get; set; } 102 | 103 | public static string ProfilePicture { get; set; } 104 | } 105 | internal class ApplicationSettings 106 | { 107 | public static bool Status { get; set; } 108 | 109 | public static bool DeveloperMode { get; set; } 110 | 111 | public static string Hash { get; set; } 112 | 113 | public static string Version { get; set; } 114 | 115 | public static string Update_Link { get; set; } 116 | 117 | public static bool Freemode { get; set; } 118 | 119 | public static bool Login { get; set; } 120 | 121 | public static string Name { get; set; } 122 | 123 | public static bool Register { get; set; } 124 | 125 | public static string TotalUsers { get; set; } 126 | } 127 | 128 | internal class OnProgramStart 129 | { 130 | public static string AID = null; 131 | 132 | public static string Secret = null; 133 | 134 | public static string Version = null; 135 | 136 | public static string Name = null; 137 | 138 | public static string Salt = null; 139 | 140 | public static void Initialize(string name, string aid, string secret, string version) 141 | { 142 | if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(aid) || string.IsNullOrWhiteSpace(secret) || string.IsNullOrWhiteSpace(version) || name.Contains("APPNAME")) 143 | { 144 | MessageBox.Show("Failed to initialize your application correctly in Program.cs!", Name, MessageBoxButton.OK, MessageBoxImage.Error); 145 | Process.GetCurrentProcess().Kill(); 146 | } 147 | AID = aid; 148 | Secret = secret; 149 | Version = version; 150 | Name = name; 151 | string[] response = new string[] { }; 152 | using (WebClient wc = new WebClient()) 153 | { 154 | 155 | try 156 | { 157 | wc.Proxy = null; 158 | Security.Start(); 159 | response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 160 | { 161 | ["token"] = Encryption.EncryptService(Constants.Token), 162 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 163 | ["aid"] = Encryption.APIService(AID), 164 | ["session_id"] = Constants.IV, 165 | ["api_id"] = Constants.APIENCRYPTSALT, 166 | ["api_key"] = Constants.APIENCRYPTKEY, 167 | ["session_key"] = Constants.Key, 168 | ["secret"] = Encryption.APIService(Secret), 169 | ["type"] = Encryption.APIService("start") 170 | 171 | }))).Split("|".ToCharArray())); 172 | if (Security.MaliciousCheck(response[1])) 173 | { 174 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 175 | Process.GetCurrentProcess().Kill(); 176 | } 177 | if (Constants.Breached) 178 | { 179 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 180 | Process.GetCurrentProcess().Kill(); 181 | } 182 | if (response[0] != Constants.Token) 183 | { 184 | MessageBox.Show("Security error has been triggered!", Name, MessageBoxButton.OK, MessageBoxImage.Error); 185 | Process.GetCurrentProcess().Kill(); 186 | } 187 | switch (response[2]) 188 | { 189 | case "success": 190 | Constants.Initialized = true; 191 | if (response[3] == "Enabled") 192 | ApplicationSettings.Status = true; 193 | if (response[4] == "Enabled") 194 | ApplicationSettings.DeveloperMode = true; 195 | ApplicationSettings.Hash = response[5]; 196 | ApplicationSettings.Version = response[6]; 197 | ApplicationSettings.Update_Link = response[7]; 198 | if (response[8] == "Enabled") 199 | ApplicationSettings.Freemode = true; 200 | if (response[9] == "Enabled") 201 | ApplicationSettings.Login = true; 202 | ApplicationSettings.Name = response[10]; 203 | if (response[11] == "Enabled") 204 | ApplicationSettings.Register = true; 205 | ApplicationSettings.TotalUsers = response[13]; 206 | if (ApplicationSettings.DeveloperMode) 207 | { 208 | MessageBox.Show("Application is in Developer Mode, bypassing integrity and update check!", Name, MessageBoxButton.OK, MessageBoxImage.Warning); 209 | File.Create(Environment.CurrentDirectory + "/integrity.log").Close(); 210 | string hash = Security.Integrity(Process.GetCurrentProcess().MainModule.FileName); 211 | File.WriteAllText(Environment.CurrentDirectory + "/integrity.log", hash); 212 | MessageBox.Show("Your applications hash has been saved to integrity.txt, please refer to this when your application is ready for release!", Name, MessageBoxButton.OK, MessageBoxImage.Information); 213 | } 214 | else 215 | { 216 | if (ApplicationSettings.Version != Version) 217 | { 218 | MessageBox.Show($"Update {ApplicationSettings.Version} available, redirecting to update!", Name, MessageBoxButton.OK, MessageBoxImage.Error); 219 | Process.Start(ApplicationSettings.Update_Link); 220 | Process.GetCurrentProcess().Kill(); 221 | } 222 | if (response[12] == "Enabled") 223 | { 224 | if (ApplicationSettings.Hash != Security.Integrity(Process.GetCurrentProcess().MainModule.FileName)) 225 | { 226 | MessageBox.Show($"File has been tampered with, couldn't verify integrity!", Name, MessageBoxButton.OK, MessageBoxImage.Error); 227 | Process.GetCurrentProcess().Kill(); 228 | } 229 | } 230 | } 231 | if (ApplicationSettings.Status == false) 232 | { 233 | MessageBox.Show("Looks like this application is disabled, please try again later!", Name, MessageBoxButton.OK, MessageBoxImage.Error); 234 | Process.GetCurrentProcess().Kill(); 235 | } 236 | break; 237 | case "binderror": 238 | MessageBox.Show(Encryption.Decode("RmFpbGVkIHRvIGJpbmQgdG8gc2VydmVyLCBjaGVjayB5b3VyIEFJRCAmIFNlY3JldCBpbiB5b3VyIGNvZGUh"), Name, MessageBoxButton.OK, MessageBoxImage.Error); 239 | Process.GetCurrentProcess().Kill(); 240 | return; 241 | case "banned": 242 | MessageBox.Show("This application has been banned for violating the TOS" + Environment.NewLine + "Contact us at support@auth.gg", Name, MessageBoxButton.OK, MessageBoxImage.Error); 243 | Process.GetCurrentProcess().Kill(); 244 | return; 245 | } 246 | Security.End(); 247 | } 248 | catch (Exception ex) 249 | { 250 | MessageBox.Show(ex.Message, Name, MessageBoxButton.OK, MessageBoxImage.Error); 251 | Process.GetCurrentProcess().Kill(); 252 | } 253 | } 254 | } 255 | } 256 | 257 | internal class API 258 | { 259 | public static void Log(string username, string action) 260 | { 261 | if (!Constants.Initialized) 262 | { 263 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 264 | Process.GetCurrentProcess().Kill(); 265 | } 266 | if (string.IsNullOrWhiteSpace(action)) 267 | { 268 | MessageBox.Show("Missing log information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 269 | Process.GetCurrentProcess().Kill(); 270 | } 271 | string[] response = new string[] { }; 272 | using (WebClient wc = new WebClient()) 273 | { 274 | try 275 | { 276 | Security.Start(); 277 | wc.Proxy = null; 278 | response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 279 | { 280 | ["token"] = Encryption.EncryptService(Constants.Token), 281 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 282 | ["username"] = Encryption.APIService(username), 283 | ["pcuser"] = Encryption.APIService(Environment.UserName), 284 | ["session_id"] = Constants.IV, 285 | ["api_id"] = Constants.APIENCRYPTSALT, 286 | ["api_key"] = Constants.APIENCRYPTKEY, 287 | ["data"] = Encryption.APIService(action), 288 | ["session_key"] = Constants.Key, 289 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 290 | ["type"] = Encryption.APIService("log") 291 | }))).Split("|".ToCharArray())); 292 | Security.End(); 293 | } 294 | catch (Exception ex) 295 | { 296 | MessageBox.Show(ex.Message, OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 297 | Process.GetCurrentProcess().Kill(); 298 | } 299 | } 300 | } 301 | public static void UploadPic(string username, string path) 302 | { 303 | if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(path)) 304 | { 305 | MessageBox.Show("Invalid Picture information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 306 | Process.GetCurrentProcess().Kill(); 307 | } 308 | string[] response = new string[] { }; 309 | using (WebClient wc = new WebClient()) 310 | { 311 | 312 | try 313 | { 314 | wc.Proxy = null; 315 | Security.Start(); 316 | response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 317 | { 318 | ["token"] = Encryption.EncryptService(Constants.Token), 319 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 320 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 321 | ["username"] = Encryption.APIService(username), 322 | ["picbytes"] = Encryption.APIService(path), 323 | ["session_id"] = Constants.IV, 324 | ["api_id"] = Constants.APIENCRYPTSALT, 325 | ["api_key"] = Constants.APIENCRYPTKEY, 326 | ["session_key"] = Constants.Key, 327 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 328 | ["type"] = Encryption.APIService("uploadpic") 329 | 330 | }))).Split("|".ToCharArray())); 331 | switch (response[0]) 332 | { 333 | case "success": 334 | MessageBox.Show("Successfully updated profile picture!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 335 | Security.End(); 336 | return; 337 | case "permissions": 338 | MessageBox.Show("Please upgrade your plan to use this feature!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 339 | Security.End(); 340 | return; 341 | case "failed": 342 | MessageBox.Show("Failed to upload profile picture!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 343 | Security.End(); 344 | return; 345 | } 346 | } 347 | catch (Exception ex) 348 | { 349 | MessageBox.Show(ex.Message, OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 350 | Process.GetCurrentProcess().Kill(); 351 | } 352 | } 353 | } 354 | public static bool AIO(string AIO) 355 | { 356 | if (AIOLogin(AIO)) 357 | { 358 | return true; 359 | } 360 | else 361 | { 362 | if (AIORegister(AIO)) 363 | { 364 | return true; 365 | } 366 | else 367 | { 368 | return false; 369 | } 370 | } 371 | } 372 | public static bool AIOLogin(string AIO) 373 | { 374 | if (!Constants.Initialized) 375 | { 376 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 377 | Process.GetCurrentProcess().Kill(); 378 | } 379 | if (string.IsNullOrWhiteSpace(AIO)) 380 | { 381 | MessageBox.Show("Missing user login information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 382 | Process.GetCurrentProcess().Kill(); 383 | } 384 | string[] response = new string[] { }; 385 | using (WebClient wc = new WebClient()) 386 | { 387 | try 388 | { 389 | Security.Start(); 390 | wc.Proxy = null; 391 | response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 392 | { 393 | ["token"] = Encryption.EncryptService(Constants.Token), 394 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 395 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 396 | ["session_id"] = Constants.IV, 397 | ["api_id"] = Constants.APIENCRYPTSALT, 398 | ["api_key"] = Constants.APIENCRYPTKEY, 399 | ["username"] = Encryption.APIService(AIO), 400 | ["password"] = Encryption.APIService(AIO), 401 | ["hwid"] = Encryption.APIService(Constants.HWID()), 402 | ["session_key"] = Constants.Key, 403 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 404 | ["type"] = Encryption.APIService("login") 405 | 406 | }))).Split("|".ToCharArray())); 407 | if (response[0] != Constants.Token) 408 | { 409 | MessageBox.Show("Security error has been triggered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 410 | Process.GetCurrentProcess().Kill(); 411 | } 412 | if (Security.MaliciousCheck(response[1])) 413 | { 414 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 415 | Process.GetCurrentProcess().Kill(); 416 | } 417 | if (Constants.Breached) 418 | { 419 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 420 | Process.GetCurrentProcess().Kill(); 421 | } 422 | switch (response[2]) 423 | { 424 | case "success": 425 | Security.End(); 426 | User.ID = response[3]; 427 | User.Username = response[4]; 428 | User.Password = response[5]; 429 | User.Email = response[6]; 430 | User.HWID = response[7]; 431 | User.UserVariable = response[8]; 432 | User.Rank = response[9]; 433 | User.IP = response[10]; 434 | User.Expiry = response[11]; 435 | User.LastLogin = response[12]; 436 | User.RegisterDate = response[13]; 437 | string Variables = response[14]; 438 | foreach (string var in Variables.Split('~')) 439 | { 440 | string[] items = var.Split('^'); 441 | try 442 | { 443 | App.Variables.Add(items[0], items[1]); 444 | } 445 | catch 446 | { 447 | //If some are null or not loaded, just ignore. 448 | //Error will be shown when loading the variable anyways 449 | } 450 | } 451 | return true; 452 | case "invalid_details": 453 | Security.End(); 454 | return false; 455 | case "time_expired": 456 | MessageBox.Show("Your subscription has expired!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 457 | Security.End(); 458 | Process.GetCurrentProcess().Kill(); 459 | return false; 460 | case "hwid_updated": 461 | MessageBox.Show("New machine has been binded, re-open the application!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Information); 462 | Security.End(); 463 | Process.GetCurrentProcess().Kill(); 464 | return false; 465 | case "invalid_hwid": 466 | MessageBox.Show("This user is binded to another computer, please contact support!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 467 | Security.End(); 468 | Process.GetCurrentProcess().Kill(); 469 | return false; 470 | } 471 | } 472 | catch (Exception ex) 473 | { 474 | MessageBox.Show(ex.Message, ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 475 | Security.End(); 476 | Process.GetCurrentProcess().Kill(); 477 | } 478 | return false; 479 | 480 | } 481 | } 482 | public static bool AIORegister(string AIO) 483 | { 484 | if (!Constants.Initialized) 485 | { 486 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 487 | Security.End(); 488 | Process.GetCurrentProcess().Kill(); 489 | } 490 | if (string.IsNullOrWhiteSpace(AIO)) 491 | { 492 | MessageBox.Show("Invalid registrar information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 493 | Process.GetCurrentProcess().Kill(); 494 | } 495 | string[] response = new string[] { }; 496 | using (WebClient wc = new WebClient()) 497 | { 498 | try 499 | { 500 | Security.Start(); 501 | wc.Proxy = null; 502 | 503 | response = Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 504 | { 505 | ["token"] = Encryption.EncryptService(Constants.Token), 506 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 507 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 508 | ["session_id"] = Constants.IV, 509 | ["api_id"] = Constants.APIENCRYPTSALT, 510 | ["api_key"] = Constants.APIENCRYPTKEY, 511 | ["session_key"] = Constants.Key, 512 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 513 | ["type"] = Encryption.APIService("register"), 514 | ["username"] = Encryption.APIService(AIO), 515 | ["password"] = Encryption.APIService(AIO), 516 | ["email"] = Encryption.APIService(AIO), 517 | ["license"] = Encryption.APIService(AIO), 518 | ["hwid"] = Encryption.APIService(Constants.HWID()), 519 | 520 | }))).Split("|".ToCharArray()); 521 | if (response[0] != Constants.Token) 522 | { 523 | MessageBox.Show("Security error has been triggered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 524 | Security.End(); 525 | Process.GetCurrentProcess().Kill(); 526 | } 527 | if (Security.MaliciousCheck(response[1])) 528 | { 529 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 530 | Process.GetCurrentProcess().Kill(); 531 | } 532 | if (Constants.Breached) 533 | { 534 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 535 | Process.GetCurrentProcess().Kill(); 536 | } 537 | Security.End(); 538 | switch (response[2]) 539 | { 540 | case "success": 541 | return true; 542 | case "error": 543 | return false; 544 | 545 | } 546 | } 547 | catch (Exception ex) 548 | { 549 | MessageBox.Show(ex.Message, ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 550 | Process.GetCurrentProcess().Kill(); 551 | } 552 | return false; 553 | } 554 | } 555 | public static bool Login(string username, string password) 556 | { 557 | if (!Constants.Initialized) 558 | { 559 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 560 | Process.GetCurrentProcess().Kill(); 561 | } 562 | if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) 563 | { 564 | MessageBox.Show("Missing user login information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 565 | Process.GetCurrentProcess().Kill(); 566 | } 567 | string[] response = new string[] { }; 568 | using (WebClient wc = new WebClient()) 569 | { 570 | try 571 | { 572 | Security.Start(); 573 | wc.Proxy = null; 574 | response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 575 | { 576 | ["token"] = Encryption.EncryptService(Constants.Token), 577 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 578 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 579 | ["session_id"] = Constants.IV, 580 | ["api_id"] = Constants.APIENCRYPTSALT, 581 | ["api_key"] = Constants.APIENCRYPTKEY, 582 | ["username"] = Encryption.APIService(username), 583 | ["password"] = Encryption.APIService(password), 584 | ["hwid"] = Encryption.APIService(Constants.HWID()), 585 | ["session_key"] = Constants.Key, 586 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 587 | ["type"] = Encryption.APIService("login") 588 | 589 | }))).Split("|".ToCharArray())); 590 | if (response[0] != Constants.Token) 591 | { 592 | MessageBox.Show("Security error has been triggered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 593 | Process.GetCurrentProcess().Kill(); 594 | } 595 | if (Security.MaliciousCheck(response[1])) 596 | { 597 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 598 | Process.GetCurrentProcess().Kill(); 599 | } 600 | if (Constants.Breached) 601 | { 602 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 603 | Process.GetCurrentProcess().Kill(); 604 | } 605 | switch (response[2]) 606 | { 607 | case "success": 608 | User.ID = response[3]; 609 | User.Username = response[4]; 610 | User.Password = response[5]; 611 | User.Email = response[6]; 612 | User.HWID = response[7]; 613 | User.UserVariable = response[8]; 614 | User.Rank = response[9]; 615 | User.IP = response[10]; 616 | User.Expiry = response[11]; 617 | User.LastLogin = response[12]; 618 | User.RegisterDate = response[13]; 619 | string Variables = response[14]; 620 | foreach (string var in Variables.Split('~')) 621 | { 622 | string[] items = var.Split('^'); 623 | try 624 | { 625 | App.Variables.Add(items[0], items[1]); 626 | } 627 | catch 628 | { 629 | //If some are null or not loaded, just ignore. 630 | //Error will be shown when loading the variable anyways 631 | } 632 | } 633 | Security.End(); 634 | return true; 635 | case "invalid_details": 636 | MessageBox.Show("Sorry, your username/password does not match!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 637 | Security.End(); 638 | Process.GetCurrentProcess().Kill(); 639 | return false; 640 | case "time_expired": 641 | MessageBox.Show("Your subscription has expired!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 642 | Security.End(); 643 | Process.GetCurrentProcess().Kill(); 644 | return false; 645 | case "hwid_updated": 646 | MessageBox.Show("New machine has been binded, re-open the application!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Information); 647 | Security.End(); 648 | Process.GetCurrentProcess().Kill(); 649 | return false; 650 | case "invalid_hwid": 651 | MessageBox.Show("This user is binded to another computer, please contact support!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 652 | Security.End(); 653 | Process.GetCurrentProcess().Kill(); 654 | return false; 655 | } 656 | } 657 | catch (Exception ex) 658 | { 659 | MessageBox.Show(ex.Message, ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 660 | Security.End(); 661 | Process.GetCurrentProcess().Kill(); 662 | } 663 | return false; 664 | 665 | } 666 | } 667 | public static bool Register(string username, string password, string email, string license) 668 | { 669 | if (!Constants.Initialized) 670 | { 671 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 672 | Security.End(); 673 | Process.GetCurrentProcess().Kill(); 674 | } 675 | if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(license)) 676 | { 677 | MessageBox.Show("Invalid registrar information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 678 | Process.GetCurrentProcess().Kill(); 679 | } 680 | string[] response = new string[] { }; 681 | using (WebClient wc = new WebClient()) 682 | { 683 | try 684 | { 685 | Security.Start(); 686 | wc.Proxy = null; 687 | 688 | response = Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 689 | { 690 | ["token"] = Encryption.EncryptService(Constants.Token), 691 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 692 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 693 | ["session_id"] = Constants.IV, 694 | ["api_id"] = Constants.APIENCRYPTSALT, 695 | ["api_key"] = Constants.APIENCRYPTKEY, 696 | ["session_key"] = Constants.Key, 697 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 698 | ["type"] = Encryption.APIService("register"), 699 | ["username"] = Encryption.APIService(username), 700 | ["password"] = Encryption.APIService(password), 701 | ["email"] = Encryption.APIService(email), 702 | ["license"] = Encryption.APIService(license), 703 | ["hwid"] = Encryption.APIService(Constants.HWID()), 704 | 705 | }))).Split("|".ToCharArray()); 706 | if (response[0] != Constants.Token) 707 | { 708 | MessageBox.Show("Security error has been triggered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 709 | Security.End(); 710 | Process.GetCurrentProcess().Kill(); 711 | } 712 | if (Security.MaliciousCheck(response[1])) 713 | { 714 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 715 | Process.GetCurrentProcess().Kill(); 716 | } 717 | if (Constants.Breached) 718 | { 719 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 720 | Process.GetCurrentProcess().Kill(); 721 | } 722 | switch (response[2]) 723 | { 724 | case "success": 725 | Security.End(); 726 | return true; 727 | case "invalid_license": 728 | MessageBox.Show("License does not exist!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 729 | Security.End(); 730 | Process.GetCurrentProcess().Kill(); 731 | return false; 732 | case "email_used": 733 | MessageBox.Show("Email has already been used!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 734 | Security.End(); 735 | Process.GetCurrentProcess().Kill(); 736 | return false; 737 | case "invalid_username": 738 | MessageBox.Show("You entered an invalid/used username!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 739 | Security.End(); 740 | Process.GetCurrentProcess().Kill(); 741 | return false; 742 | } 743 | } 744 | catch (Exception ex) 745 | { 746 | MessageBox.Show(ex.Message, ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 747 | Process.GetCurrentProcess().Kill(); 748 | } 749 | return false; 750 | } 751 | } 752 | public static bool ExtendSubscription(string username, string password, string license) 753 | { 754 | if (!Constants.Initialized) 755 | { 756 | MessageBox.Show("Please initialize your application first!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 757 | Security.End(); 758 | Process.GetCurrentProcess().Kill(); 759 | } 760 | if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(license)) 761 | { 762 | MessageBox.Show("Invalid registrar information!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 763 | Process.GetCurrentProcess().Kill(); 764 | } 765 | string[] response = new string[] { }; 766 | using (WebClient wc = new WebClient()) 767 | { 768 | try 769 | { 770 | Security.Start(); 771 | wc.Proxy = null; 772 | response = Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection 773 | { 774 | ["token"] = Encryption.EncryptService(Constants.Token), 775 | ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()), 776 | ["aid"] = Encryption.APIService(OnProgramStart.AID), 777 | ["session_id"] = Constants.IV, 778 | ["api_id"] = Constants.APIENCRYPTSALT, 779 | ["api_key"] = Constants.APIENCRYPTKEY, 780 | ["session_key"] = Constants.Key, 781 | ["secret"] = Encryption.APIService(OnProgramStart.Secret), 782 | ["type"] = Encryption.APIService("extend"), 783 | ["username"] = Encryption.APIService(username), 784 | ["password"] = Encryption.APIService(password), 785 | ["license"] = Encryption.APIService(license), 786 | 787 | }))).Split("|".ToCharArray()); 788 | if (response[0] != Constants.Token) 789 | { 790 | MessageBox.Show("Security error has been triggered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 791 | Security.End(); 792 | Process.GetCurrentProcess().Kill(); 793 | } 794 | if (Security.MaliciousCheck(response[1])) 795 | { 796 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 797 | Process.GetCurrentProcess().Kill(); 798 | } 799 | if (Constants.Breached) 800 | { 801 | MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 802 | Process.GetCurrentProcess().Kill(); 803 | } 804 | switch (response[2]) 805 | { 806 | case "success": 807 | Security.End(); 808 | return true; 809 | case "invalid_token": 810 | MessageBox.Show("Token does not exist!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 811 | Security.End(); 812 | Process.GetCurrentProcess().Kill(); 813 | return false; 814 | case "invalid_details": 815 | MessageBox.Show("Your user details are invalid!", ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 816 | Security.End(); 817 | Process.GetCurrentProcess().Kill(); 818 | return false; 819 | } 820 | } 821 | catch (Exception ex) 822 | { 823 | MessageBox.Show(ex.Message, ApplicationSettings.Name, MessageBoxButton.OK, MessageBoxImage.Error); 824 | Process.GetCurrentProcess().Kill(); 825 | } 826 | return false; 827 | } 828 | } 829 | } 830 | internal class Security 831 | { 832 | public static string Signature(string value) 833 | { 834 | using (MD5 md5 = MD5.Create()) 835 | { 836 | byte[] input = Encoding.UTF8.GetBytes(value); 837 | byte[] hash = md5.ComputeHash(input); 838 | return BitConverter.ToString(hash).Replace("-", ""); 839 | } 840 | } 841 | private static string Session(int length) 842 | { 843 | Random random = new Random(); 844 | const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; 845 | return new string(Enumerable.Repeat(chars, length) 846 | .Select(s => s[random.Next(s.Length)]).ToArray()); 847 | } 848 | public static string Obfuscate(int length) 849 | { 850 | Random random = new Random(); 851 | const string chars = "gd8JQ57nxXzLLMPrLylVhxoGnWGCFjO4knKTfRE6mVvdjug2NF/4aptAsZcdIGbAPmcx0O+ftU/KvMIjcfUnH3j+IMdhAW5OpoX3MrjQdf5AAP97tTB5g1wdDSAqKpq9gw06t3VaqMWZHKtPSuAXy0kkZRsc+DicpcY8E9+vWMHXa3jMdbPx4YES0p66GzhqLd/heA2zMvX8iWv4wK7S3QKIW/a9dD4ALZJpmcr9OOE="; 852 | return new string(Enumerable.Repeat(chars, length) 853 | .Select(s => s[random.Next(s.Length)]).ToArray()); 854 | } 855 | public static void Start() 856 | { 857 | string drive = Path.GetPathRoot(Environment.SystemDirectory); 858 | if (Constants.Started) 859 | { 860 | MessageBox.Show("A session has already been started, please end the previous one!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 861 | Process.GetCurrentProcess().Kill(); 862 | } 863 | else 864 | { 865 | using (StreamReader sr = new StreamReader($@"{drive}Windows\System32\drivers\etc\hosts")) 866 | { 867 | string contents = sr.ReadToEnd(); 868 | if (contents.Contains("api.auth.gg")) 869 | { 870 | Constants.Breached = true; 871 | MessageBox.Show("DNS redirecting has been detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 872 | Process.GetCurrentProcess().Kill(); 873 | } 874 | } 875 | InfoManager infoManager = new InfoManager(); 876 | infoManager.StartListener(); 877 | Constants.Token = Guid.NewGuid().ToString(); 878 | ServicePointManager.ServerCertificateValidationCallback += PinPublicKey; 879 | Constants.APIENCRYPTKEY = Convert.ToBase64String(Encoding.Default.GetBytes(Session(32))); 880 | Constants.APIENCRYPTSALT = Convert.ToBase64String(Encoding.Default.GetBytes(Session(16))); 881 | Constants.IV = Convert.ToBase64String(Encoding.Default.GetBytes(Constants.RandomString(16))); 882 | Constants.Key = Convert.ToBase64String(Encoding.Default.GetBytes(Constants.RandomString(32))); 883 | Constants.Started = true; 884 | } 885 | } 886 | public static void End() 887 | { 888 | if (!Constants.Started) 889 | { 890 | MessageBox.Show("No session has been started, closing for security reasons!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Warning); 891 | Process.GetCurrentProcess().Kill(); 892 | } 893 | else 894 | { 895 | Constants.Token = null; 896 | ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 897 | Constants.APIENCRYPTKEY = null; 898 | Constants.APIENCRYPTSALT = null; 899 | Constants.IV = null; 900 | Constants.Key = null; 901 | Constants.Started = false; 902 | } 903 | } 904 | private static bool PinPublicKey(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 905 | { 906 | return certificate != null && certificate.GetPublicKeyString() == _key; 907 | } 908 | //SSL Key, needs update once a year 909 | private const string _key = "3082010A0282010100D0A2FCAC2861DF72F05EE166613656F27D3C037B985FECFCB5D943BC28B40DD9C035FFE44E16C57772312A9457E54973E15D40DF91660E2914ACE0AC3705562F32F023EBF32BC218423AE9DA1C752FD843EC0176307E1EE97EFCA50510DBBC88C4A253A9A06C7646BFB30CE86B773708D4240AB72919898387C60FB2F0B1B4E579BB5BC9DA286C348DD81A1205C1C43BF522032C0CA4226E08C2108E847670363B292E8E90D8B541C03CB11B03A13A88BCCC209D899994F8EADDF43AE8BBE63214EC4817922EC9496855D47E00CA21B533950C5401C6E31A727BC1A14F025D7F94B3DB2D4EE749B05C83A68A3EB17A4E375CD5CE16904F0CB1F8B7B8E75A86D30203010001"; 910 | public static string Integrity(string filename) 911 | { 912 | string result; 913 | using (MD5 md = MD5.Create()) 914 | { 915 | using (FileStream fileStream = File.OpenRead(filename)) 916 | { 917 | byte[] value = md.ComputeHash(fileStream); 918 | result = BitConverter.ToString(value).Replace("-", "").ToLowerInvariant(); 919 | } 920 | } 921 | return result; 922 | } 923 | public static bool MaliciousCheck(string date) 924 | { 925 | DateTime dt1 = DateTime.Parse(date); //time sent 926 | DateTime dt2 = DateTime.Now; //time received 927 | TimeSpan d3 = dt1 - dt2; 928 | if (Convert.ToInt32(d3.Seconds.ToString().Replace("-", "")) >= 5 || Convert.ToInt32(d3.Minutes.ToString().Replace("-", "")) >= 1) 929 | { 930 | Constants.Breached = true; 931 | return true; 932 | } 933 | else 934 | { 935 | return false; 936 | } 937 | } 938 | } 939 | internal class Encryption 940 | { 941 | public static string APIService(string value) 942 | { 943 | string message = value; 944 | string password = Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTKEY)); 945 | SHA256 mySHA256 = SHA256Managed.Create(); 946 | byte[] key = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(password)); 947 | byte[] iv = Encoding.ASCII.GetBytes(Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTSALT))); 948 | string encrypted = EncryptString(message, key, iv); 949 | return encrypted; 950 | } 951 | public static string EncryptService(string value) 952 | { 953 | string message = value; 954 | string password = Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTKEY)); 955 | SHA256 mySHA256 = SHA256Managed.Create(); 956 | byte[] key = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(password)); 957 | byte[] iv = Encoding.ASCII.GetBytes(Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTSALT))); 958 | string encrypted = EncryptString(message, key, iv); 959 | int property = Int32.Parse((OnProgramStart.AID.Substring(0, 2))); 960 | string final = encrypted + Security.Obfuscate(property); 961 | return final; 962 | } 963 | public static string DecryptService(string value) 964 | { 965 | string message = value; 966 | string password = Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTKEY)); 967 | SHA256 mySHA256 = SHA256Managed.Create(); 968 | byte[] key = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(password)); 969 | byte[] iv = Encoding.ASCII.GetBytes(Encoding.Default.GetString(Convert.FromBase64String(Constants.APIENCRYPTSALT))); 970 | string decrypted = DecryptString(message, key, iv); 971 | return decrypted; 972 | } 973 | public static string EncryptString(string plainText, byte[] key, byte[] iv) 974 | { 975 | Aes encryptor = Aes.Create(); 976 | encryptor.Mode = CipherMode.CBC; 977 | encryptor.Key = key; 978 | encryptor.IV = iv; 979 | MemoryStream memoryStream = new MemoryStream(); 980 | ICryptoTransform aesEncryptor = encryptor.CreateEncryptor(); 981 | CryptoStream cryptoStream = new CryptoStream(memoryStream, aesEncryptor, CryptoStreamMode.Write); 982 | byte[] plainBytes = Encoding.ASCII.GetBytes(plainText); 983 | cryptoStream.Write(plainBytes, 0, plainBytes.Length); 984 | cryptoStream.FlushFinalBlock(); 985 | byte[] cipherBytes = memoryStream.ToArray(); 986 | memoryStream.Close(); 987 | cryptoStream.Close(); 988 | string cipherText = Convert.ToBase64String(cipherBytes, 0, cipherBytes.Length); 989 | return cipherText; 990 | } 991 | 992 | public static string DecryptString(string cipherText, byte[] key, byte[] iv) 993 | { 994 | Aes encryptor = Aes.Create(); 995 | encryptor.Mode = CipherMode.CBC; 996 | encryptor.Key = key; 997 | encryptor.IV = iv; 998 | MemoryStream memoryStream = new MemoryStream(); 999 | ICryptoTransform aesDecryptor = encryptor.CreateDecryptor(); 1000 | CryptoStream cryptoStream = new CryptoStream(memoryStream, aesDecryptor, CryptoStreamMode.Write); 1001 | string plainText = String.Empty; 1002 | try 1003 | { 1004 | byte[] cipherBytes = Convert.FromBase64String(cipherText); 1005 | cryptoStream.Write(cipherBytes, 0, cipherBytes.Length); 1006 | cryptoStream.FlushFinalBlock(); 1007 | byte[] plainBytes = memoryStream.ToArray(); 1008 | plainText = Encoding.ASCII.GetString(plainBytes, 0, plainBytes.Length); 1009 | } 1010 | finally 1011 | { 1012 | memoryStream.Close(); 1013 | cryptoStream.Close(); 1014 | } 1015 | return plainText; 1016 | } 1017 | public static string Decode(string text) 1018 | { 1019 | text = text.Replace('_', '/').Replace('-', '+'); 1020 | switch (text.Length % 4) 1021 | { 1022 | case 2: 1023 | text += "=="; 1024 | break; 1025 | case 3: 1026 | text += "="; 1027 | break; 1028 | } 1029 | return Encoding.UTF8.GetString(Convert.FromBase64String(text)); 1030 | } 1031 | 1032 | } 1033 | class InfoManager 1034 | { 1035 | private System.Threading.Timer timer; 1036 | private string lastGateway; 1037 | 1038 | public InfoManager() 1039 | { 1040 | lastGateway = GetGatewayMAC(); 1041 | } 1042 | 1043 | public void StartListener() 1044 | { 1045 | timer = new System.Threading.Timer(_ => OnCallBack(), null, 5000, Timeout.Infinite); 1046 | } 1047 | 1048 | private void OnCallBack() 1049 | { 1050 | timer.Dispose(); 1051 | if (!(GetGatewayMAC() == lastGateway)) 1052 | { 1053 | Constants.Breached = true; 1054 | MessageBox.Show("ARP Cache poisoning has been detected!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 1055 | Process.GetCurrentProcess().Kill(); 1056 | } 1057 | else 1058 | { 1059 | lastGateway = GetGatewayMAC(); 1060 | } 1061 | timer = new Timer(_ => OnCallBack(), null, 5000, Timeout.Infinite); 1062 | } 1063 | 1064 | public static IPAddress GetDefaultGateway() 1065 | { 1066 | return NetworkInterface 1067 | .GetAllNetworkInterfaces() 1068 | .Where(n => n.OperationalStatus == OperationalStatus.Up) 1069 | .Where(n => n.NetworkInterfaceType != NetworkInterfaceType.Loopback) 1070 | .SelectMany(n => n.GetIPProperties()?.GatewayAddresses) 1071 | .Select(g => g?.Address) 1072 | .Where(a => a != null) 1073 | .FirstOrDefault(); 1074 | } 1075 | 1076 | private string GetArpTable() 1077 | { 1078 | string drive = Path.GetPathRoot(Environment.SystemDirectory); 1079 | ProcessStartInfo start = new ProcessStartInfo(); 1080 | start.FileName = $@"{drive}Windows\System32\arp.exe"; 1081 | start.Arguments = "-a"; 1082 | start.UseShellExecute = false; 1083 | start.RedirectStandardOutput = true; 1084 | 1085 | using (Process process = Process.Start(start)) 1086 | { 1087 | using (StreamReader reader = process.StandardOutput) 1088 | { 1089 | return reader.ReadToEnd(); 1090 | } 1091 | } 1092 | } 1093 | 1094 | private string GetGatewayMAC() 1095 | { 1096 | string routerIP = GetDefaultGateway().ToString(); 1097 | string regx = String.Format(@"({0} [\W]*) ([a-z0-9-]*)", routerIP); 1098 | Regex regex = new Regex(@regx); 1099 | Match matches = regex.Match(GetArpTable()); 1100 | return matches.Groups[2].ToString(); 1101 | } 1102 | } 1103 | } 1104 | -------------------------------------------------------------------------------- /Console Example/Auth.GG Example/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Console Example/Auth.GG Example/Auth.GG Example.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {139B021F-DFD8-4CDF-B282-040A0A5F9903} 8 | Exe 9 | Auth.GG_Example 10 | Auth.GG Example 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Console Example/Auth.GG Example/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace AuthGG 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | //Update this with your program information found in dashboard 16 | //APPNAME = Name of your application 17 | //AIDHERE = AID found in your settings page > Upper right corner > Settings 18 | //APPSECRET = Secret in applications table 19 | //1.0 = indicates your application version located in your application settings 20 | //YOUTUBE TUTORIAL | https://www.youtube.com/watch?v=VjPz21Va9wU 21 | 22 | //This connects your file to the Auth.GG API, and sends back your application settings and such 23 | OnProgramStart.Initialize("APPNAME", "AIDHERE", "APPSECRET", "1.0"); 24 | if(ApplicationSettings.Freemode) 25 | { 26 | //Usually when your application doesn't need a login and has freemode enabled you put the code here you want to do 27 | MessageBox.Show("Freemode is active, bypassing login!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 28 | } 29 | if (!ApplicationSettings.Status) 30 | { 31 | //If application is disabled in your web-panel settings this action will occur 32 | MessageBox.Show("Application is disabled!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 33 | Process.GetCurrentProcess().Kill(); // closes the application 34 | } 35 | PrintLogo(); 36 | Console.WriteLine("[1] Register"); 37 | Console.WriteLine("[2] Login"); 38 | Console.WriteLine("[3] All in one"); 39 | Console.WriteLine("[4] Extend Subscription"); 40 | string option = Console.ReadLine(); 41 | if (option == "1") 42 | { 43 | if (!ApplicationSettings.Register) 44 | { 45 | //Register is disabled in application settings, will show a messagebox that it is not enabled 46 | MessageBox.Show("Register is not enabled, please try again later!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 47 | Process.GetCurrentProcess().Kill(); //closes the application 48 | } 49 | else 50 | { 51 | Console.Clear(); 52 | PrintLogo(); 53 | Console.WriteLine(); 54 | Console.WriteLine("Username:"); 55 | string username = Console.ReadLine(); 56 | Console.WriteLine("Password:"); 57 | string password = Console.ReadLine(); 58 | Console.WriteLine("Email:"); 59 | string email = Console.ReadLine(); 60 | Console.WriteLine("License:"); 61 | string license = Console.ReadLine(); 62 | if (API.Register(username, password, email, license)) 63 | { 64 | MessageBox.Show("You have successfully registered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 65 | // Do code of what you want after successful register here! 66 | } 67 | } 68 | } 69 | else if(option == "2") 70 | { 71 | if (!ApplicationSettings.Login) 72 | { 73 | //Register is disabled in application settings, will show a messagebox that it is not enabled 74 | MessageBox.Show("Login is not enabled, please try again later!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 75 | Process.GetCurrentProcess().Kill(); //closes the application 76 | } 77 | else 78 | { 79 | Console.Clear(); 80 | PrintLogo(); 81 | Console.WriteLine(); 82 | Console.WriteLine("Username:"); 83 | string username = Console.ReadLine(); 84 | Console.WriteLine("Password:"); 85 | string password = Console.ReadLine(); 86 | if (API.Login(username, password)) 87 | { 88 | MessageBox.Show("You have successfully logged in!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 89 | Console.Clear(); 90 | PrintLogo(); 91 | // Success login stuff goes here 92 | Console.ForegroundColor = ConsoleColor.White; 93 | API.Log(username, "Logged in!"); //Logs this action to your web-panel, you can do this anywhere and for anything! 94 | Console.WriteLine("***************************************************"); 95 | Console.WriteLine("All user information:"); 96 | Console.WriteLine("***************************************************"); 97 | Console.ForegroundColor = ConsoleColor.Cyan; 98 | Console.WriteLine($"User ID -> {User.ID}"); 99 | Console.WriteLine($"Username -> {User.Username}"); 100 | Console.WriteLine($"Password -> {User.Password}"); 101 | Console.WriteLine($"Email -> {User.Email}"); 102 | Console.WriteLine($"HWID -> {User.HWID}"); 103 | Console.WriteLine($"User Variable -> {User.UserVariable}"); 104 | Console.WriteLine($"User Rank -> {User.Rank}"); 105 | Console.WriteLine($"User IP -> {User.IP}"); 106 | Console.WriteLine($"Expiry -> {User.Expiry}"); 107 | Console.WriteLine($"Last Login -> {User.LastLogin}"); 108 | Console.WriteLine($"Register Date -> {User.RegisterDate}"); 109 | Console.WriteLine($"Variable -> {App.GrabVariable("PutVariableSecretHere")}"); // Replace put variable secret here with the secret of the variable in your panel - https://i.imgur.com/v3q2a6e.png 110 | } 111 | } 112 | } 113 | else if (option == "4") 114 | { 115 | Console.Clear(); 116 | PrintLogo(); 117 | Console.WriteLine(); 118 | Console.WriteLine("Username:"); 119 | string username = Console.ReadLine(); 120 | Console.WriteLine("Password:"); 121 | string password = Console.ReadLine(); 122 | Console.WriteLine("Token:"); 123 | string token = Console.ReadLine(); 124 | if (API.ExtendSubscription(username, password, token)) 125 | { 126 | MessageBox.Show("You have successfully extended your subscription!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 127 | // Do code of what you want after successful extend here! 128 | } 129 | } 130 | else if (option == "3") 131 | { 132 | Console.Clear(); 133 | PrintLogo(); 134 | Console.WriteLine(); 135 | Console.WriteLine("AIO Key:"); 136 | string KEY = Console.ReadLine(); 137 | if(API.AIO(KEY)) 138 | { 139 | //Code you want to do here on successful login 140 | MessageBox.Show("Welcome back to my application!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 141 | Process.GetCurrentProcess().Kill(); // closes the application 142 | } 143 | else 144 | { 145 | //Code you want to do here on failed login 146 | MessageBox.Show("Your key does not exist!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 147 | Process.GetCurrentProcess().Kill(); // closes the application 148 | } 149 | } 150 | Console.Read(); 151 | } 152 | public static void PrintLogo() 153 | { 154 | Console.ForegroundColor = ConsoleColor.Cyan; 155 | Console.WriteLine(); 156 | Console.WriteLine(" █████╗ ██╗ ██╗████████╗██╗ ██╗ ██████╗ ██████╗ "); 157 | Console.WriteLine(" ██╔══██╗██║ ██║╚══██╔══╝██║ ██║ ██╔════╝ ██╔════╝ "); 158 | Console.WriteLine(" ███████║██║ ██║ ██║ ███████║ ██║ ███╗██║ ███╗"); 159 | Console.WriteLine(" ██╔══██║██║ ██║ ██║ ██╔══██║ ██║ ██║██║ ██║"); 160 | Console.WriteLine(" ██║ ██║╚██████╔╝ ██║ ██║ ██║██╗╚██████╔╝╚██████╔╝"); 161 | Console.WriteLine(" ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ "); 162 | Console.ForegroundColor = ConsoleColor.White; 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /Console Example/Auth.GG Example/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Auth.GG Example")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Auth.GG Example")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("139b021f-dfd8-4cdf-b282-040a0a5f9903")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auth.GG Licensing for .NET 2 | 3 | This API serves as a layer that simplifies communication between .NET and the server 4 | 5 | > You can access the documentation of the API at https://setup.auth.gg 6 | 7 | # Getting started 8 | 9 | ### Grab API Secret 10 | 11 | * **Step 1** : Login to your panel and create your application 12 | * **Step 2** : Your application secret will be next to your application name 13 | * **Step 3** : Copy your secret and store it somewhere 14 | ### Grab AID 15 | * **Step 1** : Login to your panel hover over your avatar on the top right 16 | * **Step 2** : Click on ``Account Settings`` 17 | * **Step 3** : Copy your AID and store it somewhere 18 | 19 | ### Connecting panel to program 20 | Now that you have your ``AID`` and ``Secret`` use it to initialize and connect your application to our servers 21 | ``` 22 | OnProgramStart.Initialize("APPNAME", "AID", "PROGRAMSECRET", "VERSION"); 23 | ``` 24 | ## Example 25 | ``` 26 | OnProgramStart.Initialize("MyDemoApp", "269868", "t5d7rzzbrdAHmfWTGmuTUazjLIvWk", "1.0"); 27 | ``` 28 | > After a successful initialization, the server will send back the following information on your application based on the settings you have picked 29 | * ``ApplicationSettings.Name`` : Application name 30 | * ``ApplicationSettings.Status`` : Application Enabled/Disabled 31 | * ``ApplicationSettings.DeveloperMode`` : DeveloperMode Enabled/Disabled 32 | * ``ApplicationSettings.Hash`` : Applications md5 hash to check integrity 33 | * ``ApplicationSettings.Version`` : Applications version 34 | * ``ApplicationSettings.UpdateLink`` : Applications link that it updates from if version is updated 35 | * ``ApplicationSettings.Freemode`` : Freemode Enabled/Disabled 36 | * ``ApplicationSettings.Login`` : Login Enabled/Disabled 37 | * ``ApplicationSettings.Register`` : Login Enabled/Disabled 38 | * ``ApplicationSettings.TotalUsers`` : Total users registered for application 39 | ## Login 40 | 41 | ``` 42 | if (API.Login(username, password)) 43 | { 44 | //Code you want to do here on successful login 45 | MessageBox.Show("You have successfully logged in!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 46 | } 47 | ``` 48 | > After a successful login, the server will send back the following information on your user 49 | * ``User.Username`` : Users username 50 | * ``User.ID`` : Users ID 51 | * ``User.Email`` : Users email 52 | * ``User.HWID`` : Users hardware ID 53 | * ``User.IP`` : Users IP 54 | * ``User.UserVariable`` : Users variable 55 | * ``User.Rank`` : Users rank 56 | * ``User.Expiry`` : Users expiry 57 | * ``User.LastLogin`` : Users last login 58 | * ``User.RegisterDate`` : Users registration date 59 | * ``User.ProfilePicture`` : Users profile picture link 60 | ## Register 61 | 62 | ``` 63 | if (API.Register(username, password, email, license)) 64 | { 65 | //Code you want to do here on successful register 66 | MessageBox.Show("You have successfully registered!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 67 | } 68 | ``` 69 | ## Extend Subscription 70 | ``` 71 | if (API.ExtendSubscription(username, password, token)) 72 | { 73 | MessageBox.Show("You have successfully extended your subscription!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 74 | // Do code of what you want after successful extend here! 75 | } 76 | ``` 77 | ## All in one - strictly key based - login & register with one 78 | ``` 79 | if(API.AIO(KEY)) 80 | { 81 | //Code you want to do here on successful login 82 | MessageBox.Show("Welcome back to my application!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Information); 83 | Process.GetCurrentProcess().Kill(); // closes the application 84 | } 85 | else 86 | { 87 | //Code you want to do here on failed login 88 | MessageBox.Show("Your key does not exist!", OnProgramStart.Name, MessageBoxButton.OK, MessageBoxImage.Error); 89 | Process.GetCurrentProcess().Kill(); // closes the application 90 | } 91 | ``` 92 | ## Log Action 93 | 94 | ``` 95 | API.Log("USERNAMEHERE", "ACTION HERE"); 96 | ``` 97 | ## Update Profile Picture 98 | 99 | ``` 100 | API.UploadPic("USERNAMEHERE", @"C:\imagelocation.png"); 101 | ``` 102 | --------------------------------------------------------------------------------