namespace Phoenix
{
using Microsoft.Win32;
using MySql.Data.MySqlClient;
using Phoenix.Communication;
using Phoenix.Core;
using Phoenix.HabboHotel;
using Phoenix.Messages;
using Phoenix.Net;
using Phoenix.Storage;
using Phoenix.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
internal class Class2
{
public static bool bool_0 = false;
private static bool bool_1 = false;
private static Class0 class0_0;
private static Class110 class110_0;
private static Class17 class17_0;
private static Class19 class19_0;
private static Class3 class3_0;
private static Class310 class310_0;
internal static DateTime dateTime_0;
private static Encoding encoding_0;
public const int int_0 = 0x3730;
public static int int_1 = 0;
public static int int_2 = 0;
public const string string_0 = "**************.com";
public const string string_1 = "http://**************.com/phx/";
public string string_2 = smethod_1(0x3730.ToString());
public string string_3 = ("http://**************.com/phx/licence" + Convert.ToChar(0x2e).ToString() + "php" + Convert.ToChar(0x3f).ToString());
public static string string_4 = ("http://**************.com/phx/override" + Convert.ToChar(0x2e).ToString() + Convert.ToChar(0x74).ToString() + Convert.ToChar(120).ToString() + Convert.ToChar(0x74).ToString());
public static string string_5 = smethod_20(string_4);
public static string string_6;
private static string string_7;
public void method_0()
{
string environmentVariable = Environment.GetEnvironmentVariable("windir");
string str2 = System.IO.File.ReadAllText(environmentVariable + @"\system32\drivers\etc\hosts");
if (!((str2 != null) ? !str2.Contains("otaku") : false))
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Unable to contact licence server! Try again later", false);
}
else
{
dateTime_0 = DateTime.Now;
Console.Title = "Loading Phoenix emulator";
encoding_0 = Encoding.Default;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine();
Console.WriteLine(" ______ _ _ _______ ");
Console.WriteLine(@" (_____ \| | (_) (_______) ");
Console.WriteLine(" _____) ) | _ ___ ____ ____ _ _ _ _____ ____ _ _ ");
Console.WriteLine(@" | ____/| || \ / _ \ / _ ) _ \| ( \ / ) | ___) | \| | | |");
Console.WriteLine(" | | | | | | |_| ( (/ /| | | | |) X ( | |_____| | | | |_| |");
Console.WriteLine(@" |_| |_| |_|\___/ \____)_| |_|_(_/ \_) |_______)_|_|_|\____|");
Console.WriteLine();
Console.WriteLine(" " + String_0);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine();
Console.WriteLine(" Dedicated and VPS Hosting available at *******************");
Console.WriteLine(" VPS Hosting from just \x00a34.99 for the first month with coupon OTAKU50!");
try
{
class17_0 = new Class17("config.conf");
DateTime now = DateTime.Now;
string_6 = smethod_11().dictionary_0["**************.username"];
string_7 = smethod_11().dictionary_0["**************.password"];
int num = string_6.Length * string_7.Length;
if (((string_6 == "") || (string_7 == "")) || Class11.Boolean_7)
{
goto Label_07F6;
}
Class11.String_6 = string_6;
Class11.String_3 = string_7;
string str3 = "";
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
key.SetValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", 0);
key.Flush();
key.Close();
int num3 = (int) Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true).GetValue("ProxyEnable");
if (num3 != 0)
{
goto Label_0285;
}
if (str3 == "")
{
if (System.IO.File.ReadAllText(environmentVariable + @"\system32\drivers\etc\hosts").Contains("otaku"))
{
goto Label_026E;
}
if (this.string_3.Contains(Convert.ToChar(0x2e).ToString() + "php" + Convert.ToChar(0x3f).ToString()))
{
str3 = smethod_20(this.string_3);
}
}
goto Label_02B4;
Label_026E:
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Unable to contact licence server! Try again later", false);
return;
Label_0285:
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Proxy detected - Phoenix is unable to connect to Otaku to verify your account details.", false);
}
catch
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Proxy detected - Phoenix is unable to connect to Otaku to verify your account details.", false);
}
return;
Label_02B4:
if (str3 != null)
{
if (bool_0)
{
if (int_1 > 0x3730)
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine(" Build: " + int_1 + " available for download");
}
else if (int_1 < 0x3730)
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine(" You're running a test build - bugs may occur!");
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Gray;
string str5 = smethod_1(smethod_0(smethod_0(str3.Substring(0x20, 0x20) + string_6) + "4g") + string_7);
string str6 = smethod_0(num.ToString());
if (str3.Substring(0, 0x20) == str6)
{
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"]);
str3 = str3.Substring(0x40, 0x60);
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"]));
class0_0 = new Class0(class2, class3);
Class11.String_1 = str3;
class3_0 = new Class3(int.Parse(smethod_11().dictionary_0["game.tcp.conlimit"]));
string str4 = "";
int num2 = Class11.String_6.Length * 0x3730;
num2 = Class11.String_3.Length % 0x3730;
str4 = Class11.String_5 + smethod_0(num2.ToString()) + smethod_0(num2.ToString());
if (!(str3 == str4))
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Invalid Licence details found #0003", false);
}
else
{
if (str3.Length == 0x60)
{
class110_0 = new Class110();
class110_0.method_1();
class110_0.method_2();
class110_0.method_3();
class110_0.method_4();
class110_0.method_5();
class110_0.method_6();
class110_0.method_7();
class110_0.method_8();
class110_0.method_9();
class110_0.method_10();
class110_0.method_11();
class110_0.method_12();
class110_0.method_13();
class110_0.method_14();
class110_0.method_15();
class110_0.method_21();
class110_0.method_20();
class110_0.method_18();
class110_0.method_17();
class110_0.method_16();
class110_0.method_19();
class110_0.method_22();
class110_0.method_24();
class110_0.method_23();
class110_0.method_25();
class110_0.method_26();
class110_0.method_27();
}
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);
Class11.Boolean_7 = str3 == str4;
class19_0 = new Class19(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"]));
class19_0.method_3().method_0();
TimeSpan span = (TimeSpan) (DateTime.Now - now);
GClass3.smethod_0(string.Concat(new object[] { "Server -> READY! (", span.Seconds, " s, ", span.Milliseconds, " ms)" }));
Console.Beep();
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Invalid Licence details found #0001", false);
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
if (int_2 != 0)
{
Console.WriteLine("An update is required to continue use of Phoenix Emulator");
Console.WriteLine("Please visit **************.com for more information");
Console.WriteLine("Your build: " + 0x3730);
Console.WriteLine("Current build: " + int_1);
}
else
{
Console.WriteLine("Your firewall is preventing Phoenix from starting");
}
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Invalid Licence details found #0005", false);
}
return;
Label_07F6:
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Invalid Licence details found #0001", false);
}
catch (KeyNotFoundException)
{
GClass3.smethod_0("Please check your configuration file - some values appear to be missing.");
GClass3.smethod_0("Press any key to shut down ...");
Console.ReadKey(true);
smethod_16();
}
catch (InvalidOperationException exception)
{
GClass3.smethod_0("Failed to initialize PhoenixEmulator: " + exception.Message);
GClass3.smethod_0("Press any key to shut down ...");
Console.ReadKey(true);
smethod_16();
}
}
}
public static string smethod_0(string string_8)
{
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
byte[] bytes = Encoding.UTF8.GetBytes(string_8);
bytes = provider.ComputeHash(bytes);
StringBuilder builder = new StringBuilder();
foreach (byte num2 in bytes)
{
builder.Append(num2.ToString("x2").ToLower());
}
return builder.ToString().ToUpper();
}
public static string smethod_1(string string_8)
{
byte[] bytes = Encoding.ASCII.GetBytes(string_8);
byte[] buffer2 = new SHA1Managed().ComputeHash(bytes);
string str = string.Empty;
foreach (byte num2 in buffer2)
{
str = str + num2.ToString("X2");
}
return str;
}
public static Class110 smethod_10()
{
return class110_0;
}
public static Class17 smethod_11()
{
return class17_0;
}
public static Class0 smethod_12()
{
return class0_0;
}
public static Encoding smethod_13()
{
return encoding_0;
}
public static Class19 smethod_14()
{
return class19_0;
}
internal static Class3 smethod_15()
{
return class3_0;
}
public static void smethod_16()
{
GClass3.smethod_0("Destroying PhoenixEmu environment...");
if (smethod_15() != null)
{
smethod_15().method_1();
class3_0 = null;
}
if (smethod_14() != null)
{
GClass3.smethod_0("Destroying connection manager.");
smethod_14().method_3().method_2();
smethod_14().method_0();
class19_0 = null;
}
if (smethod_12() != null)
{
try
{
GClass3.smethod_0("Destroying database manager.");
MySqlConnection.ClearAllPools();
class0_0 = null;
}
catch
{
}
}
GClass3.smethod_0("Uninitialized successfully. Closing.");
}
internal static void smethod_17(string string_8)
{
try
{
GClass4 class2 = new GClass4(0x8b);
class2.method_7(string_8);
smethod_15().method_2().method_12(class2);
}
catch
{
}
}
internal static void smethod_18()
{
smethod_19("", true);
}
internal static void smethod_19(string string_8, bool bool_2)
{
if (string_8 == "")
{
GClass3.smethod_6();
bool_1 = true;
try
{
class3_0.method_9().method_4();
}
catch
{
}
try
{
smethod_14().method_3().method_1();
smethod_15().method_2().method_20();
}
catch
{
}
class19_0.method_7();
class3_0.method_1();
Console.WriteLine(string_8);
}
else
{
if (bool_1)
{
return;
}
Console.WriteLine(string_8);
GClass3.smethod_6();
smethod_17("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
bool_1 = true;
Console.WriteLine("Server shutting down...");
try
{
class3_0.method_9().method_4();
}
catch
{
}
try
{
smethod_14().method_3().method_1();
smethod_15().method_2().method_20();
}
catch
{
}
try
{
using (Class1 class2 = smethod_12().method_0())
{
class2.method_1("UPDATE users SET online = '0'");
class2.method_1("UPDATE rooms SET users_now = '0'");
}
class19_0.method_7();
class3_0.method_1();
}
catch
{
}
try
{
Console.WriteLine("Destroying database manager.");
MySqlConnection.ClearAllPools();
class0_0 = null;
}
catch
{
}
Console.WriteLine("System disposed, goodbye!");
}
if (bool_2)
{
Environment.Exit(0);
}
}
public static int smethod_2(string string_8)
{
return Convert.ToInt32(string_8);
}
public static string smethod_20(string string_8)
{
WebProxy proxy;
Class2 class2 = new Class2();
Uri address = new Uri(string_8);
string host = address.Host;
if ((host == null) || ((host != "**************.com") && (host != "api.*******")))
{
Console.ForegroundColor = ConsoleColor.Red;
smethod_19("Invalid Licence details found #0004", false);
smethod_18();
}
proxy = new WebProxy(address, true) {
Address = WebRequest.DefaultWebProxy.GetProxy(address),
BypassProxyOnLocal = false,//WebRequest.DefaultWebProxy.IsBypassed(proxy.Address),
Credentials = CredentialCache.DefaultCredentials
};
WebRequest request = WebRequest.Create(address);
request.Proxy = null;
request.Headers.Add("AuthName", string_6);
request.Headers.Add("AuthPass", string_7);
int num = 0x3730;
request.Headers.Add("AuthBuild", num.ToString());
request.Headers.Add("AuthMachine", Environment.MachineName);
request.Headers.Add("AuthServer", "Phoenix");
WebResponse response = request.GetResponse();
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (string str4 in response.Headers)
{
dictionary.Add(str4, response.Headers[str4]);
}
if (string_8 == class2.string_3)
{
if (dictionary["AuthU"] != string_6.Length.ToString())
{
return null;
}
if (dictionary.ContainsKey("MinBuild"))
{
int_2 = Convert.ToInt16(dictionary["MinBuild"]);
int_1 = Convert.ToInt16(dictionary["CurBuild"]);
if (int_2 > 0x3730)
{
if (int_2 > 0x3730)
{
bool_0 = false;
}
}
else
{
bool_0 = true;
}
}
if (dictionary.ContainsKey("AuthGen"))
{
return dictionary["AuthGen"];
}
}
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();
}
public static bool smethod_21(int int_3, int int_4)
{
return ((int_3 % int_4) == 0);
}
public static DateTime smethod_22(double double_0)
{
DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0);
return time.AddSeconds(double_0).ToLocalTime();
}
public static bool smethod_3(string string_8)
{
if (!(string_8 == "1"))
{
return false;
}
return true;
}
public static string smethod_4(bool bool_2)
{
if (!bool_2)
{
return "0";
}
return "1";
}
public static int smethod_5(int int_3, int int_4)
{
RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
byte[] data = new byte[4];
provider.GetBytes(data);
return new Random(BitConverter.ToInt32(data, 0)).Next(int_3, int_4 + 1);
}
public static double smethod_6()
{
TimeSpan span = (TimeSpan) (DateTime.UtcNow - new DateTime(0x7b2, 1, 1, 0, 0, 0));
return span.TotalSeconds;
}
public static string smethod_7(string string_8)
{
return smethod_8(string_8, false, false);
}
public static string smethod_8(string string_8, bool bool_2, bool bool_3)
{
string_8 = string_8.Replace(Convert.ToChar(1), ' ');
string_8 = string_8.Replace(Convert.ToChar(2), ' ');
string_8 = string_8.Replace(Convert.ToChar(9), ' ');
if (!bool_2)
{
string_8 = string_8.Replace(Convert.ToChar(13), ' ');
}
if (bool_3)
{
string_8 = string_8.Replace('\'', ' ');
}
return string_8;
}
public static bool smethod_9(string string_8)
{
if (!string.IsNullOrEmpty(string_8))
{
for (int i = 0; i < string_8.Length; i++)
{
if (!(!char.IsLetter(string_8) ? char.IsNumber(string_8) : true))
{
return false;
}
}
return true;
}
return false;
}
internal static Class3 Class3_0
{
get
{
return class3_0;
}
set
{
class3_0 = value;
}
}
public static string String_0
{
get
{
return ("Phoenix v3.8.1 (Build " + 0x3730 + ")");
}
}
}
}