Guest User

Class4.cs Phoenix 3.8.0 - Licence C

a guest
Jun 26th, 2012
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 23.56 KB | None | 0 0
  1. namespace Phoenix
  2. {
  3.     using Microsoft.Win32;
  4.     using MySql.Data.MySqlClient;
  5.     using Phoenix.Communication;
  6.     using Phoenix.Core;
  7.     using Phoenix.HabboHotel;
  8.     using Phoenix.Messages;
  9.     using Phoenix.Net;
  10.     using Phoenix.Storage;
  11.     using Phoenix.Util;
  12.     using System;
  13.     using System.Collections.Generic;
  14.     using System.IO;
  15.     using System.Net;
  16.     using System.Security.Cryptography;
  17.     using System.Text;
  18.  
  19.     internal class Class4
  20.     {
  21.         public static bool bool_0 = false;
  22.         private static bool bool_1 = false;
  23.         private static Class110 class110_0;
  24.         private static Class14 class14_0;
  25.         private static Class16 class16_0;
  26.         private static Class2 class2_0;
  27.         private static Class310 class310_0;
  28.         private static Class5 class5_0;
  29.         internal static DateTime dateTime_0;
  30.         private static Encoding encoding_0;
  31.         public const int int_0 = 0x3722;
  32.         public static int int_1 = 0;
  33.         public const string string_0 = "otaku-studios.com";
  34.         public const string string_1 = "http://otaku-studios.com/phx/";
  35.         public string string_2 = smethod_1(0x3722.ToString());
  36.         public string string_3 = ("http://otaku-studios.com/phx/licence" + Convert.ToChar(0x2e).ToString() + "php" + Convert.ToChar(0x3f).ToString());
  37.         public static string string_4 = ("http://otaku-studios.com/phx/override" + Convert.ToChar(0x2e).ToString() + Convert.ToChar(0x74).ToString() + Convert.ToChar(120).ToString() + Convert.ToChar(0x74).ToString());
  38.         public static string string_5 = smethod_20(string_4);
  39.         public static string string_6;
  40.         private static string string_7;
  41.  
  42.         public void method_0()
  43.         {
  44.             string environmentVariable = Environment.GetEnvironmentVariable("windir");
  45.             string str2 = System.IO.File.ReadAllText(environmentVariable + @"\system32\drivers\etc\hosts");
  46.             if (!((str2 != null) ? !str2.Contains("otaku") : false))
  47.             {
  48.                 Console.ForegroundColor = ConsoleColor.Red;
  49.                 smethod_19("Unable to contact licence server! Try again later", false);
  50.             }
  51.             else
  52.             {
  53.                 dateTime_0 = DateTime.Now;
  54.                 Console.Title = "Loading Phoenix emulator";
  55.                 encoding_0 = Encoding.Default;
  56.                 Console.ForegroundColor = ConsoleColor.Green;
  57.                 Console.WriteLine();
  58.                 Console.WriteLine("        ______  _                       _          _______             ");
  59.                 Console.WriteLine(@"       (_____ \| |                     (_)        (_______)            ");
  60.                 Console.WriteLine("        _____) ) | _   ___   ____ ____  _ _   _    _____   ____  _   _ ");
  61.                 Console.WriteLine(@"       |  ____/| || \ / _ \ / _  )  _ \| ( \ / )  |  ___) |    \| | | |");
  62.                 Console.WriteLine("       | |     | | | | |_| ( (/ /| | | | |) X (   | |_____| | | | |_| |");
  63.                 Console.WriteLine(@"       |_|     |_| |_|\___/ \____)_| |_|_(_/ \_)  |_______)_|_|_|\____|");
  64.                 Console.WriteLine();
  65.                 Console.WriteLine("                                       " + String_0);
  66.                 if (int_1 > 0x3722)
  67.                 {
  68.                     Console.ForegroundColor = ConsoleColor.DarkGreen;
  69.                     Console.WriteLine("                                       Build: " + int_1 + " available for download");
  70.                 }
  71.                 Console.ForegroundColor = ConsoleColor.Green;
  72.                 Console.WriteLine();
  73.                 Console.WriteLine("          Dedicated and VPS Hosting available at Otaku-Hosting.com");
  74.                 Console.WriteLine("    VPS Hosting from just \x00a34.99 for the first month with coupon OTAKU50!");
  75.                 Console.WriteLine();
  76.                 try
  77.                 {
  78.                     Console.ForegroundColor = ConsoleColor.Gray;
  79.                     class14_0 = new Class14("config.conf");
  80.                     DateTime now = DateTime.Now;
  81.                     string_6 = smethod_11().dictionary_0["Otaku-Studios.username"];
  82.                     string_7 = smethod_11().dictionary_0["Otaku-Studios.password"];
  83.                     int num = string_6.Length * string_7.Length;
  84.                     if (((string_6 != "") && (string_7 != "")) && !Class19.Boolean_7)
  85.                     {
  86.                         Class19.String_6 = string_6;
  87.                         Class19.String_3 = string_7;
  88.                         string str3 = "";
  89.                         try
  90.                         {
  91.                             RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
  92.                             key.SetValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", 0);
  93.                             key.Flush();
  94.                             key.Close();
  95.                             int num3 = (int) Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true).GetValue("ProxyEnable");
  96.                             if (num3 != 0)
  97.                             {
  98.                                 Console.ForegroundColor = ConsoleColor.Red;
  99.                                 smethod_19("Proxy detected - Phoenix is unable to connect to Otaku to verify your account details.", false);
  100.                                 return;
  101.                             }
  102.                             if (str3 == "")
  103.                             {
  104.                                 if (System.IO.File.ReadAllText(environmentVariable + @"\system32\drivers\etc\hosts").Contains("otaku"))
  105.                                 {
  106.                                     Console.ForegroundColor = ConsoleColor.Red;
  107.                                     smethod_19("Unable to contact licence server! Try again later", false);
  108.                                     return;
  109.                                 }
  110.                                 if (this.string_3.Contains(Convert.ToChar(0x2e).ToString() + "php" + Convert.ToChar(0x3f).ToString()))
  111.                                 {
  112.                                     str3 = smethod_20(this.string_3);
  113.                                 }
  114.                             }
  115.                         }
  116.                         catch
  117.                         {
  118.                             Console.ForegroundColor = ConsoleColor.Red;
  119.                             smethod_19("Proxy detected - Phoenix is unable to connect to Otaku to verify your account details.", false);
  120.                             return;
  121.                         }
  122.                         if (bool_0)
  123.                         {
  124.                             string str5 = smethod_1(smethod_0(smethod_0(str3.Substring(0x20, 0x20) + string_6) + "4g") + string_7);
  125.                             string str6 = smethod_0(num.ToString());
  126.                             if (str3.Substring(0, 0x20) == str6)
  127.                             {
  128.                                 GClass2 class2 = new GClass2(smethod_11().dictionary_0["db.hostname"], uint.Parse(smethod_11().dictionary_0["db.port"]), smethod_11().dictionary_0["db.username"], smethod_11().dictionary_0["db.password"]);
  129.                                 str3 = str3.Substring(0x40, 0x60);
  130.                                 GClass1 class3 = new GClass1(smethod_11().dictionary_0["db.name"], uint.Parse(smethod_11().dictionary_0["db.pool.minsize"]), uint.Parse(smethod_11().dictionary_0["db.pool.maxsize"]));
  131.                                 class2_0 = new Class2(class2, class3);
  132.                                 Class19.String_1 = str3;
  133.                                 class5_0 = new Class5(int.Parse(smethod_11().dictionary_0["game.tcp.conlimit"]));
  134.                                 string str4 = "";
  135.                                 int num2 = Class19.String_6.Length * 0x3722;
  136.                                 num2 = Class19.String_3.Length % 0x3722;
  137.                                 str4 = Class19.String_5 + smethod_0(num2.ToString()) + smethod_0(num2.ToString());
  138.                                 if (!(str3 == str4))
  139.                                 {
  140.                                     Console.ForegroundColor = ConsoleColor.Red;
  141.                                     smethod_19("Invalid Licence details found #0003", false);
  142.                                 }
  143.                                 else
  144.                                 {
  145.                                     if (str3.Length == 0x60)
  146.                                     {
  147.                                         class110_0 = new Class110();
  148.                                         class110_0.method_1();
  149.                                         class110_0.method_2();
  150.                                         class110_0.method_3();
  151.                                         class110_0.method_4();
  152.                                         class110_0.method_5();
  153.                                         class110_0.method_6();
  154.                                         class110_0.method_7();
  155.                                         class110_0.method_8();
  156.                                         class110_0.method_9();
  157.                                         class110_0.method_10();
  158.                                         class110_0.method_11();
  159.                                         class110_0.method_12();
  160.                                         class110_0.method_13();
  161.                                         class110_0.method_14();
  162.                                         class110_0.method_15();
  163.                                         class110_0.method_21();
  164.                                         class110_0.method_20();
  165.                                         class110_0.method_18();
  166.                                         class110_0.method_17();
  167.                                         class110_0.method_16();
  168.                                         class110_0.method_19();
  169.                                         class110_0.method_22();
  170.                                         class110_0.method_24();
  171.                                         class110_0.method_23();
  172.                                         class110_0.method_25();
  173.                                         class110_0.method_26();
  174.                                         class110_0.method_27();
  175.                                     }
  176.                                     class310_0 = new Class310(smethod_11().dictionary_0["mus.tcp.bindip"], int.Parse(smethod_11().dictionary_0["mus.tcp.port"]), smethod_11().dictionary_0["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
  177.                                     Class19.Boolean_7 = str3 == str4;
  178.                                     class16_0 = new Class16(smethod_11().dictionary_0["game.tcp.bindip"], int.Parse(smethod_11().dictionary_0["game.tcp.port"]), int.Parse(smethod_11().dictionary_0["game.tcp.conlimit"]));
  179.                                     class16_0.method_3().method_0();
  180.                                     TimeSpan span = (TimeSpan) (DateTime.Now - now);
  181.                                     GClass3.smethod_0(string.Concat(new object[] { "Server -> READY! (", span.Seconds, " s, ", span.Milliseconds, " ms)" }));
  182.                                     Console.Beep();
  183.                                 }
  184.                             }
  185.                             else
  186.                             {
  187.                                 Console.ForegroundColor = ConsoleColor.Red;
  188.                                 smethod_19("Invalid Licence details found #0001", false);
  189.                             }
  190.                         }
  191.                         else
  192.                         {
  193.                             Console.ForegroundColor = ConsoleColor.Red;
  194.                             if (int_1 != 0)
  195.                             {
  196.                                 Console.WriteLine("An update is required to continue use of Phoenix Emulator");
  197.                                 Console.WriteLine("Please visit Otaku-Studios.com for more information");
  198.                                 Console.WriteLine("Your build: " + 0x3722);
  199.                                 Console.WriteLine("Current build: " + int_1);
  200.                             }
  201.                             else
  202.                             {
  203.                                 Console.WriteLine("Your firewall is preventing Phoenix from starting");
  204.                             }
  205.                         }
  206.                     }
  207.                     else
  208.                     {
  209.                         Console.ForegroundColor = ConsoleColor.Red;
  210.                         smethod_19("Invalid Licence details found #0001", false);
  211.                     }
  212.                 }
  213.                 catch (KeyNotFoundException)
  214.                 {
  215.                     GClass3.smethod_0("Please check your configuration file - some values appear to be missing.");
  216.                     GClass3.smethod_0("Press any key to shut down ...");
  217.                     Console.ReadKey(true);
  218.                     smethod_16();
  219.                 }
  220.                 catch (InvalidOperationException exception)
  221.                 {
  222.                     GClass3.smethod_0("Failed to initialize PhoenixEmulator: " + exception.Message);
  223.                     GClass3.smethod_0("Press any key to shut down ...");
  224.                     Console.ReadKey(true);
  225.                     smethod_16();
  226.                 }
  227.             }
  228.         }
  229.  
  230.         public static string smethod_0(string text1)
  231.         {
  232.             MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
  233.             byte[] bytes = Encoding.UTF8.GetBytes(text1);
  234.             bytes = provider.ComputeHash(bytes);
  235.             StringBuilder builder = new StringBuilder();
  236.             foreach (byte num2 in bytes)
  237.             {
  238.                 builder.Append(num2.ToString("x2").ToLower());
  239.             }
  240.             return builder.ToString().ToUpper();
  241.         }
  242.  
  243.         public static string smethod_1(string text1)
  244.         {
  245.             byte[] bytes = Encoding.ASCII.GetBytes(text1);
  246.             byte[] buffer2 = new SHA1Managed().ComputeHash(bytes);
  247.             string str = string.Empty;
  248.             foreach (byte num2 in buffer2)
  249.             {
  250.                 str = str + num2.ToString("X2");
  251.             }
  252.             return str;
  253.         }
  254.  
  255.         public static Class110 smethod_10()
  256.         {
  257.             return class110_0;
  258.         }
  259.  
  260.         public static Class14 smethod_11()
  261.         {
  262.             return class14_0;
  263.         }
  264.  
  265.         public static Class2 smethod_12()
  266.         {
  267.             return class2_0;
  268.         }
  269.  
  270.         public static Encoding smethod_13()
  271.         {
  272.             return encoding_0;
  273.         }
  274.  
  275.         public static Class16 smethod_14()
  276.         {
  277.             return class16_0;
  278.         }
  279.  
  280.         internal static Class5 smethod_15()
  281.         {
  282.             return class5_0;
  283.         }
  284.  
  285.         public static void smethod_16()
  286.         {
  287.             GClass3.smethod_0("Destroying PhoenixEmu environment...");
  288.             if (smethod_15() != null)
  289.             {
  290.                 smethod_15().method_1();
  291.                 class5_0 = null;
  292.             }
  293.             if (smethod_14() != null)
  294.             {
  295.                 GClass3.smethod_0("Destroying connection manager.");
  296.                 smethod_14().method_3().method_2();
  297.                 smethod_14().method_0();
  298.                 class16_0 = null;
  299.             }
  300.             if (smethod_12() != null)
  301.             {
  302.                 try
  303.                 {
  304.                     GClass3.smethod_0("Destroying database manager.");
  305.                     MySqlConnection.ClearAllPools();
  306.                     class2_0 = null;
  307.                 }
  308.                 catch
  309.                 {
  310.                 }
  311.             }
  312.             GClass3.smethod_0("Uninitialized successfully. Closing.");
  313.         }
  314.  
  315.         internal static void smethod_17(string text1)
  316.         {
  317.             try
  318.             {
  319.                 GClass4 class2 = new GClass4(0x8b);
  320.                 class2.method_7(text1);
  321.                 smethod_15().method_2().method_12(class2);
  322.             }
  323.             catch
  324.             {
  325.             }
  326.         }
  327.  
  328.         internal static void smethod_18()
  329.         {
  330.             smethod_19("", true);
  331.         }
  332.  
  333.         internal static void smethod_19(string text1, bool flag1)
  334.         {
  335.             if (text1 != "")
  336.             {
  337.                 if (bool_1)
  338.                 {
  339.                     return;
  340.                 }
  341.                 GClass3.smethod_6();
  342.                 smethod_17("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
  343.                 bool_1 = true;
  344.                 Console.WriteLine("Server shutting down...");
  345.                 try
  346.                 {
  347.                     class5_0.method_9().method_4();
  348.                 }
  349.                 catch
  350.                 {
  351.                 }
  352.                 try
  353.                 {
  354.                     smethod_14().method_3().method_1();
  355.                     smethod_15().method_2().method_20();
  356.                 }
  357.                 catch
  358.                 {
  359.                 }
  360.                 try
  361.                 {
  362.                     using (Class1 class2 = smethod_12().method_0())
  363.                     {
  364.                         class2.method_1("UPDATE users SET online = '0'");
  365.                         class2.method_1("UPDATE rooms SET users_now = '0'");
  366.                     }
  367.                     class16_0.method_7();
  368.                     class5_0.method_1();
  369.                 }
  370.                 catch
  371.                 {
  372.                 }
  373.                 try
  374.                 {
  375.                     Console.WriteLine("Destroying database manager.");
  376.                     MySqlConnection.ClearAllPools();
  377.                     class2_0 = null;
  378.                 }
  379.                 catch
  380.                 {
  381.                 }
  382.                 Console.WriteLine("System disposed, goodbye!");
  383.             }
  384.             else
  385.             {
  386.                 GClass3.smethod_6();
  387.                 bool_1 = true;
  388.                 try
  389.                 {
  390.                     class5_0.method_9().method_4();
  391.                 }
  392.                 catch
  393.                 {
  394.                 }
  395.                 try
  396.                 {
  397.                     smethod_14().method_3().method_1();
  398.                     smethod_15().method_2().method_20();
  399.                 }
  400.                 catch
  401.                 {
  402.                 }
  403.                 class16_0.method_7();
  404.                 class5_0.method_1();
  405.                 Console.WriteLine(text1);
  406.             }
  407.             if (flag1)
  408.             {
  409.                 Environment.Exit(1);
  410.             }
  411.         }
  412.  
  413.         public static int smethod_2(string text1)
  414.         {
  415.             return Convert.ToInt32(text1);
  416.         }
  417.  
  418.         public static string smethod_20(string text1)
  419.         {
  420.             WebProxy proxy;
  421.             Class4 class2 = new Class4();
  422.             Uri address = new Uri(text1);
  423.             string host = address.Host;
  424.             if ((host == null) || ((host != "otaku-studios.com") && (host != "api.adf.ly")))
  425.             {
  426.                 Console.ForegroundColor = ConsoleColor.Red;
  427.                 smethod_19("Invalid Licence details found #0004", false);
  428.                 smethod_18();
  429.             }
  430.             proxy = new WebProxy(address, true) {
  431.                 Address = WebRequest.DefaultWebProxy.GetProxy(address),
  432.                 BypassProxyOnLocal = WebRequest.DefaultWebProxy.IsBypassed(proxy.Address),
  433.                 Credentials = CredentialCache.DefaultCredentials
  434.             };
  435.             WebRequest request = WebRequest.Create(address);
  436.             request.Proxy = null;
  437.             request.Headers.Add("AuthName", string_6);
  438.             request.Headers.Add("AuthPass", string_7);
  439.             int num = 0x3722;
  440.             request.Headers.Add("AuthBuild", num.ToString());
  441.             request.Headers.Add("AuthMachine", Environment.MachineName);
  442.             request.Headers.Add("AuthServer", "Phoenix");
  443.             WebResponse response = request.GetResponse();
  444.             Dictionary<string, string> dictionary = new Dictionary<string, string>();
  445.             foreach (string str4 in response.Headers)
  446.             {
  447.                 dictionary.Add(str4, response.Headers[str4]);
  448.             }
  449.             if (text1 == class2.string_3)
  450.             {
  451.                 if (dictionary["AuthU"] != string_6.Length.ToString())
  452.                 {
  453.                     return null;
  454.                 }
  455.                 if (dictionary.ContainsKey("MinBuild"))
  456.                 {
  457.                     int_1 = Convert.ToInt16(dictionary["MinBuild"]);
  458.                     if (int_1 <= 0x3722)
  459.                     {
  460.                         bool_0 = true;
  461.                     }
  462.                     else if (int_1 > 0x3722)
  463.                     {
  464.                         bool_0 = false;
  465.                     }
  466.                 }
  467.                 if (dictionary.ContainsKey("AuthGen"))
  468.                 {
  469.                     return dictionary["AuthGen"];
  470.                 }
  471.             }
  472.             StreamReader reader = new StreamReader(response.GetResponseStream());
  473.             return reader.ReadToEnd();
  474.         }
  475.  
  476.         public static bool smethod_21(int num1, int num2)
  477.         {
  478.             return ((num1 % num2) == 0);
  479.         }
  480.  
  481.         public static bool smethod_3(string text1)
  482.         {
  483.             return (text1 == "1");
  484.         }
  485.  
  486.         public static string smethod_4(bool flag1)
  487.         {
  488.             if (!flag1)
  489.             {
  490.                 return "0";
  491.             }
  492.             return "1";
  493.         }
  494.  
  495.         public static int smethod_5(int num1, int num3)
  496.         {
  497.             RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
  498.             byte[] data = new byte[4];
  499.             provider.GetBytes(data);
  500.             return new Random(BitConverter.ToInt32(data, 0)).Next(num1, num3 + 1);
  501.         }
  502.  
  503.         public static double smethod_6()
  504.         {
  505.             TimeSpan span = (TimeSpan) (DateTime.UtcNow - new DateTime(0x7b2, 1, 1, 0, 0, 0));
  506.             return span.TotalSeconds;
  507.         }
  508.  
  509.         public static string smethod_7(string text1)
  510.         {
  511.             return smethod_8(text1, false, false);
  512.         }
  513.  
  514.         public static string smethod_8(string text1, bool flag1, bool flag2)
  515.         {
  516.             text1 = text1.Replace(Convert.ToChar(1), ' ');
  517.             text1 = text1.Replace(Convert.ToChar(2), ' ');
  518.             text1 = text1.Replace(Convert.ToChar(9), ' ');
  519.             if (!flag1)
  520.             {
  521.                 text1 = text1.Replace(Convert.ToChar(13), ' ');
  522.             }
  523.             if (flag2)
  524.             {
  525.                 text1 = text1.Replace('\'', ' ');
  526.             }
  527.             return text1;
  528.         }
  529.  
  530.         public static bool smethod_9(string text1)
  531.         {
  532.             if (string.IsNullOrEmpty(text1))
  533.             {
  534.                 return false;
  535.             }
  536.             for (int i = 0; i < text1.Length; i++)
  537.             {
  538.                 if (!(char.IsLetter(text1[i]) || char.IsNumber(text1[i])))
  539.                 {
  540.                     return false;
  541.                 }
  542.             }
  543.             return true;
  544.         }
  545.  
  546.         internal static Class5 Class5_0
  547.         {
  548.             get
  549.             {
  550.                 return class5_0;
  551.             }
  552.             set
  553.             {
  554.                 class5_0 = value;
  555.             }
  556.         }
  557.  
  558.         public static string String_0
  559.         {
  560.             get
  561.             {
  562.                 return ("Phoenix v3.8.0 (Build " + 0x3722 + ")");
  563.             }
  564.         }
  565.     }
  566. }
Add Comment
Please, Sign In to add comment