Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: Replacement_Launcher.Form1
- // Assembly: Replacement Launcher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: C076B7EB-FF47-4A35-99E6-90CB4ED145F4
- // Assembly location: C:\Users\Michele\Downloads\Replacement_Launcher_1\Replacement_Launcher (1).exe
- using Microsoft.Win32;
- using Mono.Math;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Configuration;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Net;
- using System.Net.Sockets;
- using System.Security.Cryptography;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Web.Security;
- using System.Windows.Forms;
- using System.Xml;
- namespace Replacement_Launcher
- {
- public class Form1 : Form
- {
- public static BigInteger N = new BigInteger("E306EBC02F1DC69F5B437683FE3851FD9AAA6E97F4CBD42FC06C72053CBCED68EC570E6666F529C58518CF7B299B5582495DB169ADF48ECEB6D65461B4D7C75DD1DA89601D5C498EE48BB950E2D8D5E0E0C692D613483B38D381EA9674DF74D67665259C4C31A29E0B3CFF7587617260E8C58FFA0AF8339CD68DB3ADB90AAFEE");
- public static BigInteger P = new BigInteger("7A39FF57BCBFAA521DCE9C7DEFAB520640AC493E1B6024B95A28390E8F05787D");
- public static byte[] staticKey = Conversions.HexStr2Bytes("AC34F3070DC0E52302C2E8DA0E3F7B3E63223697555DF54E7122A14DBC99A3E8");
- public static BigInteger Two = new BigInteger(2U);
- private string args = "/launchbylauncher /sesskey -lang:english /CompanyID:\"12\" /ChannelGroupIndex:\"-1\" /AuthnToken:\"{0}\" /AuthProviderCode:\"np\" -lang:English -lite:2 -region:{1}{2}{3}{4}";
- private string Protect = "Basic Enc";
- private List<Form1.region> regions = new List<Form1.region>();
- private BigInteger exchangeKey = Form1.Two;
- private SHA256 sha = SHA256.Create();
- private bool Debugging;
- private BackgroundWorker worker;
- private string username;
- private string password;
- private string epoch;
- private string pid;
- private string localIP;
- private string token;
- private string clientPath;
- private string LoginIp;
- private string LoginProgramid;
- private int LoginPort;
- private int counter;
- private Form1.BNSXorEncryption xor;
- private string currentAppId;
- private string currentValue;
- private BigInteger privateKey;
- private BigInteger exchangeKeyServer;
- private BigInteger session;
- private BigInteger validate;
- private byte[] key;
- private TcpClient LoginServer;
- private IContainer components;
- private TextBox usernameTB;
- private TextBox passwordTB;
- private Button button1;
- private Label label1;
- private Label label2;
- private Button button2;
- private Label label3;
- private ComboBox RegionCB;
- private CheckBox use64;
- private CheckBox disableText;
- private CheckBox unattended;
- private CheckBox allCpu;
- public Form1()
- {
- this.InitializeComponent();
- }
- private BigInteger GetKeyExchange()
- {
- if (BigInteger.op_Equality(this.exchangeKey, Form1.Two))
- this.exchangeKey = Form1.Two.modPow(this.privateKey, Form1.N);
- return this.exchangeKey;
- }
- private BigInteger SHA256Hash2ArrayInverse(byte[] tmp1, byte[] tmp2)
- {
- byte[] buffer = new byte[tmp1.Length + tmp2.Length];
- tmp1.CopyTo((Array) buffer, 0);
- tmp2.CopyTo((Array) buffer, tmp1.Length);
- return new BigInteger(this.IntegerReverse(this.sha.ComputeHash(buffer)));
- }
- private unsafe byte[] IntegerReverse(byte[] buf)
- {
- byte[] numArray = new byte[buf.Length];
- for (int index = 0; index < numArray.Length / 4; ++index)
- {
- fixed (byte* numPtr1 = buf)
- fixed (byte* numPtr2 = numArray)
- {
- int* numPtr3 = (int*) numPtr1;
- *(int*) (numPtr2 + ((IntPtr) index * 4).ToInt64()) = numPtr3[numArray.Length / 4 - 1 - index];
- }
- }
- return numArray;
- }
- private byte[] GenerateEncryptionKeyRoot(byte[] src)
- {
- int length = src.Length;
- int index1 = 0;
- byte[] numArray = new byte[64];
- if (src.Length > 4)
- {
- while (src[index1] != (byte) 0)
- {
- --length;
- ++index1;
- if (length <= 4)
- break;
- }
- }
- int count = length >> 1;
- byte[] buffer = new byte[count];
- if (count > 0)
- {
- int index2 = index1 + length - 1;
- for (int index3 = 0; index3 < count; ++index3)
- {
- buffer[index3] = src[index2];
- index2 -= 2;
- }
- }
- byte[] hash1 = this.sha.ComputeHash(buffer, 0, count);
- for (int index2 = 0; index2 < 32; ++index2)
- numArray[2 * index2] = hash1[index2];
- if (count > 0)
- {
- int index2 = index1 + length - 2;
- for (int index3 = 0; index3 < count; ++index3)
- {
- buffer[index3] = src[index2];
- index2 -= 2;
- }
- }
- byte[] hash2 = this.sha.ComputeHash(buffer, 0, count);
- for (int index2 = 0; index2 < 32; ++index2)
- numArray[2 * index2 + 1] = hash2[index2];
- return numArray;
- }
- private byte[] CombineBuffers(params byte[][] buffers)
- {
- int length = 0;
- foreach (byte[] buffer in buffers)
- length += buffer.Length;
- byte[] numArray = new byte[length];
- int index = 0;
- foreach (byte[] buffer in buffers)
- {
- buffer.CopyTo((Array) numArray, index);
- index += buffer.Length;
- }
- return numArray;
- }
- private byte[] Generate256BytesKey(byte[] src)
- {
- int index1 = 1;
- byte[] numArray = new byte[256];
- for (int index2 = 0; index2 < 256; ++index2)
- numArray[index2] = (byte) index2;
- int index3 = 0;
- int index4 = 0;
- for (int index2 = 64; index2 > 0; --index2)
- {
- int index5 = index3 + (int) src[index4] + (int) numArray[index1 - 1] & (int) byte.MaxValue;
- int num1 = (int) numArray[index1 - 1];
- numArray[index1 - 1] = numArray[index5];
- int index6 = index4 + 1;
- numArray[index5] = (byte) num1;
- if (index6 == src.Length)
- index6 = 0;
- int num2 = index5 + (int) src[index6];
- int index7 = index6 + 1;
- int num3 = num2 + (int) numArray[index1];
- int num4 = (int) numArray[index1];
- int index8 = (int) (byte) num3;
- numArray[index1] = numArray[index8];
- numArray[index8] = (byte) num4;
- if (index7 == src.Length)
- index7 = 0;
- int index9 = index8 + (int) src[index7] + (int) numArray[index1 + 1] & (int) byte.MaxValue;
- int num5 = (int) numArray[index1 + 1];
- numArray[index1 + 1] = numArray[index9];
- int index10 = index7 + 1;
- numArray[index9] = (byte) num5;
- if (index10 == src.Length)
- index10 = 0;
- int num6 = index9 + (int) src[index10];
- int num7 = (int) numArray[index1 + 2];
- index3 = num6 + (int) numArray[index1 + 2] & (int) byte.MaxValue;
- index4 = index10 + 1;
- numArray[index1 + 2] = numArray[index3];
- numArray[index3] = (byte) num7;
- if (index4 == src.Length)
- index4 = 0;
- index1 += 4;
- }
- return numArray;
- }
- public byte[][] GenerateKeyClient(BigInteger exchangeKey)
- {
- byte[] hash1 = this.sha.ComputeHash(Encoding.UTF8.GetBytes(this.username + ":" + this.password));
- BigInteger bigInteger1 = this.SHA256Hash2ArrayInverse(this.GetKeyExchange().getBytes(), exchangeKey.getBytes());
- BigInteger bigInteger2 = this.SHA256Hash2ArrayInverse(this.session.getBytes(), hash1);
- BigInteger bigInteger3 = new BigInteger(exchangeKey.getBytes());
- BigInteger bigInteger4 = BigInteger.op_Modulus(BigInteger.op_Multiply(Form1.Two.modPow(bigInteger2, Form1.N), Form1.P), Form1.N);
- while (BigInteger.op_LessThan(bigInteger3, bigInteger4))
- bigInteger3 = BigInteger.op_Addition(bigInteger3, Form1.N);
- this.key = this.GenerateEncryptionKeyRoot(BigInteger.op_Subtraction(bigInteger3, bigInteger4).modPow(BigInteger.op_Modulus(BigInteger.op_Addition(BigInteger.op_Multiply(bigInteger1, bigInteger2), this.privateKey), Form1.N), Form1.N).getBytes());
- byte[] hash2 = this.sha.ComputeHash(this.CombineBuffers(Form1.staticKey, this.sha.ComputeHash(Encoding.ASCII.GetBytes(this.username)), this.session.getBytes(), this.GetKeyExchange().getBytes(), exchangeKey.getBytes(), this.key));
- byte[] hash3 = this.sha.ComputeHash(this.CombineBuffers(this.GetKeyExchange().getBytes(), hash2, this.key));
- this.key = this.Generate256BytesKey(this.key);
- return new byte[2][]{ hash2, hash3 };
- }
- private bool LauncherInfo()
- {
- try
- {
- string hostname = "updater.nclauncher.ncsoft.com";
- string s = "BnS";
- int port = 27500;
- MemoryStream memoryStream1 = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter((Stream) memoryStream1);
- binaryWriter.Write((short) 0);
- binaryWriter.Write((short) 4);
- binaryWriter.Write((byte) 10);
- binaryWriter.Write((byte) s.Length);
- binaryWriter.Write(Encoding.ASCII.GetBytes(s));
- binaryWriter.BaseStream.Position = 0L;
- binaryWriter.Write((short) memoryStream1.Length);
- NetworkStream stream = new TcpClient(hostname, port).GetStream();
- stream.Write(memoryStream1.ToArray(), 0, (int) memoryStream1.Length);
- binaryWriter.Close();
- memoryStream1.Close();
- MemoryStream memoryStream2 = new MemoryStream();
- BinaryReader binaryReader = new BinaryReader((Stream) memoryStream2);
- byte[] buffer = new byte[1024];
- int count;
- do
- {
- count = stream.Read(buffer, 0, buffer.Length);
- if (count > 0)
- memoryStream2.Write(buffer, 0, count);
- }
- while (count == buffer.Length);
- memoryStream2.Position = 9L;
- binaryReader.ReadBytes((int) binaryReader.ReadByte() + 1);
- bool flag = binaryReader.ReadBoolean();
- stream.Close();
- binaryReader.Close();
- memoryStream2.Close();
- if (!flag)
- {
- if (!this.Debugging)
- {
- int num = (int) MessageBox.Show("The Game Server is currently in Maintentance, please try again later.");
- return false;
- }
- }
- }
- catch
- {
- int num = (int) MessageBox.Show("There was an error connecting to the Login Server, please make sure there isn't a maintenance.");
- return false;
- }
- try
- {
- string hostname = "updater.nclauncher.ncsoft.com";
- string s = "BnS";
- int port = 27500;
- MemoryStream memoryStream1 = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter((Stream) memoryStream1);
- binaryWriter.Write((short) 0);
- binaryWriter.Write((short) 8);
- binaryWriter.Write((byte) 10);
- binaryWriter.Write((byte) s.Length);
- binaryWriter.Write(Encoding.ASCII.GetBytes(s));
- binaryWriter.BaseStream.Position = 0L;
- binaryWriter.Write((short) memoryStream1.Length);
- TcpClient tcpClient = new TcpClient(hostname, port);
- this.localIP = ((IPEndPoint) tcpClient.Client.LocalEndPoint).Address.ToString();
- NetworkStream stream = tcpClient.GetStream();
- stream.Write(memoryStream1.ToArray(), 0, (int) memoryStream1.Length);
- binaryWriter.Close();
- memoryStream1.Close();
- MemoryStream memoryStream2 = new MemoryStream();
- BinaryReader binaryReader = new BinaryReader((Stream) memoryStream2);
- byte[] buffer = new byte[1024];
- int count;
- do
- {
- count = stream.Read(buffer, 0, buffer.Length);
- if (count > 0)
- memoryStream2.Write(buffer, 0, count);
- }
- while (count == buffer.Length);
- memoryStream2.Position = 9L;
- binaryReader.ReadBytes((int) binaryReader.ReadByte() + 1);
- string str1 = Encoding.UTF8.GetString(binaryReader.ReadBytes((int) binaryReader.ReadByte() + 128 * ((int) binaryReader.ReadByte() - 1)));
- stream.Close();
- binaryReader.Close();
- memoryStream2.Close();
- string str2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Settings>" + str1.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace(" ", "\r\n") + "\r\n</Settings>";
- this.LoginIp = Regex.Match(str2, "ip=\"([^\"]*)\"", RegexOptions.IgnoreCase).Groups[1].Value;
- this.LoginPort = int.Parse(Regex.Match(str2, "port=\"([^\"]*)\"", RegexOptions.IgnoreCase).Groups[1].Value);
- this.LoginProgramid = Regex.Match(str2, "programid=\"([^\"]*)\"", RegexOptions.IgnoreCase).Groups[1].Value;
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml(str2);
- foreach (XmlElement selectNode in xmlDocument.SelectNodes("//region"))
- this.regions.Add(new Form1.region(selectNode.Attributes["name"].Value, selectNode.Attributes["value"].Value, selectNode.Attributes["appid"].Value));
- }
- catch (Exception ex)
- {
- int num1 = (int) MessageBox.Show("There was an error connecting to the Login Server, please make sure there isn't a maintenance.");
- if (this.Debugging)
- {
- int num2 = (int) MessageBox.Show(ex.ToString());
- }
- return false;
- }
- return true;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.button2.Enabled = false;
- if (this.worker != null && this.worker.IsBusy)
- {
- this.LoginServer.Close();
- this.worker.CancelAsync();
- }
- this.currentAppId = ((Form1.region) this.RegionCB.SelectedValue).appId;
- this.currentValue = ((Form1.region) this.RegionCB.SelectedValue).value;
- this.epoch = ((long) (DateTime.UtcNow - new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds).ToString();
- this.username = this.usernameTB.Text.ToLower();
- this.password = this.passwordTB.Text;
- this.pid = Process.GetCurrentProcess().Id.ToString();
- this.privateKey = new BigInteger(this.sha.ComputeHash(BigInteger.genRandom(6).getBytes()));
- this.exchangeKey = Form1.Two;
- this.counter = 0;
- this.worker = new BackgroundWorker();
- this.worker.WorkerSupportsCancellation = true;
- this.worker.DoWork += new DoWorkEventHandler(this.Try_Connection);
- this.worker.RunWorkerAsync();
- }
- private string Builder(string nameSpace, string function)
- {
- ++this.counter;
- switch (nameSpace)
- {
- case "Sts":
- switch (function)
- {
- case "Connect":
- string str1 = string.Format("<Connect>\n<ConnType>400</ConnType>\n<Address>{0}</Address>\n<ProductType>0</ProductType>\n<AppIndex>1</AppIndex>\n<Epoch>{1}</Epoch>\n<Program>{2}</Program>\n<Build>1001</Build>\n<Process>{3}</Process>\n</Connect>\n", (object) this.localIP, (object) this.epoch, (object) this.LoginProgramid, (object) this.pid);
- return string.Format("POST /Sts/Connect STS/1.0\r\nl:{0}\r\n\r\n{1}", (object) str1.Length, (object) str1);
- case "Ping":
- return "POST /Sts/Ping STS/1.0\r\nl:0\r\n\r\n";
- }
- case "Auth":
- switch (function)
- {
- case "LoginStart":
- string str2 = string.Format("<Request>\n<LoginName>{0}</LoginName>\n</Request>\n", (object) this.username);
- return string.Format("POST /Auth/LoginStart STS/1.0\r\ns:{4}\r\np:*{0} 0 1 0 {1}\r\nl:{2}\r\n\r\n{3}", (object) this.localIP, (object) this.epoch, (object) str2.Length, (object) str2, (object) this.counter);
- case "KeyData":
- byte[][] keyClient = this.GenerateKeyClient(this.exchangeKeyServer);
- MemoryStream memoryStream = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter((Stream) memoryStream);
- binaryWriter.Write(this.exchangeKey.getBytes().Length);
- binaryWriter.Write(this.exchangeKey.getBytes());
- binaryWriter.Write(keyClient[0].Length);
- binaryWriter.Write(keyClient[0]);
- this.validate = new BigInteger(keyClient[1]);
- string str3 = string.Format("<Request>\n<KeyData>{0}</KeyData>\n</Request>\n", (object) Convert.ToBase64String(memoryStream.ToArray()));
- binaryWriter.Close();
- memoryStream.Close();
- return string.Format("POST /Auth/KeyData STS/1.0\r\ns:{4}\r\np:*{0} 0 1 0 {1}\r\nl:{2}\r\n\r\n{3}", (object) this.localIP, (object) this.epoch, (object) str3.Length, (object) str3, (object) this.counter);
- case "LoginFinish":
- string str4 = "<Request>\n<Language>1</Language>\n</Request>\n";
- return string.Format("POST /Auth/LoginFinish STS/1.0\r\ns:{2}\r\nl:{0}\r\n\r\n{1}", (object) str4.Length, (object) str4, (object) this.counter);
- case "RequestToken":
- string str5 = string.Format("<Request>\n<AppId>{0}</AppId>\n</Request>\n", (object) this.currentAppId);
- return string.Format("POST /Auth/RequestToken STS/1.0\r\ns:{2}\r\nl:{0}\r\n\r\n{1}", (object) str5.Length, (object) str5, (object) this.counter);
- }
- }
- return (string) null;
- }
- private void Try_Connection(object sender, DoWorkEventArgs e)
- {
- try
- {
- this.LoginServer = new TcpClient(this.LoginIp, this.LoginPort);
- this.LoginServer.ReceiveBufferSize = 1024;
- NetworkStream stream = this.LoginServer.GetStream();
- stream.ReadTimeout = 60000;
- stream.ReadTimeout = 60000;
- DateTime now = DateTime.Now;
- int num1 = 30;
- string s1 = this.Builder("Sts", "Connect");
- stream.Write(Encoding.ASCII.GetBytes(s1), 0, s1.Length);
- string s2 = this.Builder("Auth", "LoginStart");
- stream.Write(Encoding.ASCII.GetBytes(s2), 0, s2.Length);
- MemoryStream memoryStream1 = new MemoryStream();
- byte[] buffer1 = new byte[1024];
- int count1;
- do
- {
- count1 = stream.Read(buffer1, 0, buffer1.Length);
- if (count1 > 0)
- memoryStream1.Write(buffer1, 0, count1);
- }
- while (count1 == buffer1.Length);
- switch (Encoding.ASCII.GetString(memoryStream1.ToArray()).Split('\r')[0].Split(' ')[2])
- {
- case "OK":
- memoryStream1.Close();
- MemoryStream memoryStream2 = new MemoryStream();
- int count2;
- do
- {
- count2 = stream.Read(buffer1, 0, buffer1.Length);
- if (count2 > 0)
- memoryStream2.Write(buffer1, 0, count2);
- }
- while (count2 == buffer1.Length);
- string input1 = Encoding.ASCII.GetString(memoryStream2.ToArray());
- memoryStream2.Close();
- MemoryStream memoryStream3 = new MemoryStream(Convert.FromBase64String(Regex.Match(input1, "<KeyData>([^<]*)</KeyData>", RegexOptions.IgnoreCase).Groups[1].Value));
- BinaryReader binaryReader1 = new BinaryReader((Stream) memoryStream3);
- this.session = new BigInteger(binaryReader1.ReadBytes(binaryReader1.ReadInt32()));
- this.exchangeKeyServer = new BigInteger(binaryReader1.ReadBytes(binaryReader1.ReadInt32()));
- binaryReader1.Close();
- memoryStream3.Close();
- string s3 = this.Builder("Auth", "KeyData");
- stream.Write(Encoding.ASCII.GetBytes(s3), 0, s3.Length);
- MemoryStream memoryStream4 = new MemoryStream();
- int count3;
- do
- {
- count3 = stream.Read(buffer1, 0, buffer1.Length);
- if (count3 > 0)
- memoryStream4.Write(buffer1, 0, count3);
- }
- while (count3 == buffer1.Length);
- string str = Encoding.ASCII.GetString(memoryStream4.ToArray()).Split('\r')[0].Split(' ')[2];
- switch (str)
- {
- case "OK":
- memoryStream4.Close();
- MemoryStream memoryStream5 = new MemoryStream();
- int count4;
- do
- {
- count4 = stream.Read(buffer1, 0, buffer1.Length);
- if (count4 > 0)
- memoryStream5.Write(buffer1, 0, count4);
- }
- while (count4 == buffer1.Length);
- string input2 = Encoding.ASCII.GetString(memoryStream5.ToArray());
- memoryStream5.Close();
- BinaryReader binaryReader2 = new BinaryReader((Stream) new MemoryStream(Convert.FromBase64String(Regex.Match(input2, "<KeyData>([^<]*)</KeyData>", RegexOptions.IgnoreCase).Groups[1].Value)));
- if (BigInteger.op_Equality(new BigInteger(binaryReader2.ReadBytes(binaryReader2.ReadInt32())), this.validate))
- {
- this.xor = new Form1.BNSXorEncryption(this.key);
- byte[] bytes1 = Encoding.ASCII.GetBytes(this.Builder("Auth", "LoginFinish"));
- byte[] buffer2 = this.xor.Encrypt(bytes1, 0, bytes1.Length);
- stream.Write(buffer2, 0, buffer2.Length);
- byte[] buffer3 = new byte[1024];
- MemoryStream memoryStream6 = new MemoryStream();
- int count5;
- do
- {
- count5 = stream.Read(buffer3, 0, buffer3.Length);
- if (count5 > 0)
- memoryStream6.Write(buffer3, 0, count5);
- }
- while (count5 == buffer3.Length);
- byte[] array1 = memoryStream6.ToArray();
- string text = Encoding.ASCII.GetString(this.xor.Decrypt(array1, 0, array1.Length));
- if (this.Debugging)
- {
- int num2 = (int) MessageBox.Show(text);
- }
- if (text.Contains("<AuthType>8</AuthType>"))
- {
- int num3 = (int) MessageBox.Show("This launcher doesn't support IP Verification, please do so on the website or official launcher then try again");
- return;
- }
- memoryStream6.Close();
- byte[] buffer4 = new byte[1024];
- MemoryStream memoryStream7 = new MemoryStream();
- int count6;
- do
- {
- count6 = stream.Read(buffer4, 0, buffer4.Length);
- if (count6 > 0)
- memoryStream7.Write(buffer4, 0, count6);
- }
- while (count6 == buffer4.Length);
- byte[] array2 = memoryStream7.ToArray();
- byte[] bytes2 = this.xor.Decrypt(array2, 0, array2.Length);
- if (this.Debugging)
- {
- int num4 = (int) MessageBox.Show(Encoding.ASCII.GetString(bytes2));
- }
- memoryStream7.Close();
- byte[] bytes3 = Encoding.ASCII.GetBytes(this.Builder("Auth", "RequestToken"));
- byte[] buffer5 = this.xor.Encrypt(bytes3, 0, bytes3.Length);
- stream.Write(buffer5, 0, buffer5.Length);
- byte[] buffer6 = new byte[1024];
- MemoryStream memoryStream8 = new MemoryStream();
- int count7;
- do
- {
- count7 = stream.Read(buffer6, 0, buffer6.Length);
- if (count7 > 0)
- memoryStream8.Write(buffer6, 0, count7);
- }
- while (count7 == buffer6.Length);
- byte[] array3 = memoryStream8.ToArray();
- byte[] bytes4 = this.xor.Decrypt(array3, 0, array3.Length);
- memoryStream8.Close();
- this.token = Regex.Match(Encoding.ASCII.GetString(bytes4), "<AuthnToken>([^<]*)</AuthnToken>", RegexOptions.IgnoreCase).Groups[1].Value;
- this.Invoke((Delegate) new Action<bool>(this.login_enable), (object) true);
- }
- else
- {
- int num2 = (int) MessageBox.Show("Negotiation Failed, please try again.");
- this.key = (byte[]) null;
- }
- while (this.LoginServer.Connected)
- {
- if (DateTime.Now >= now.AddSeconds((double) num1))
- {
- byte[] numArray = Encoding.ASCII.GetBytes(this.Builder("Sts", "Ping"));
- if (this.key != null)
- numArray = this.xor.Encrypt(numArray, 0, numArray.Length);
- stream.Write(numArray, 0, numArray.Length);
- now = DateTime.Now;
- }
- }
- return;
- case "ErrBadPasswd":
- int num5 = (int) MessageBox.Show("Wrong Password");
- return;
- case "ErrRiskMgmtDeclined":
- int num6 = (int) MessageBox.Show("You have exceeded the number of attempts allowed.\r\nFor security reasons, login is temporarily disabled.\r\nPlease try again later.");
- return;
- default:
- int num7 = (int) MessageBox.Show("Unknown Error: " + str);
- return;
- }
- case "ErrAccountNotFound":
- int num8 = (int) MessageBox.Show("The provided email address wasn't found");
- break;
- default:
- int num9 = (int) MessageBox.Show("Invalidly formated email");
- break;
- }
- }
- catch (Exception ex)
- {
- int num1 = (int) MessageBox.Show("Unknown Network Error");
- if (!this.Debugging)
- return;
- int num2 = (int) MessageBox.Show(ex.ToString());
- }
- }
- private void login_enable(bool yes)
- {
- this.button2.Enabled = yes;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- string fileName = this.clientPath + (this.use64.Checked ? "\\bin64\\client.exe" : "\\bin\\client.exe");
- new Process()
- {
- StartInfo = new ProcessStartInfo()
- {
- FileName = fileName,
- WorkingDirectory = new FileInfo(fileName).Directory.ToString(),
- Arguments = string.Format(this.args, (object) this.token, (object) this.currentValue, this.disableText.Checked ? (object) " -NOTEXTURESTREAMING" : (object) "", this.allCpu.Checked ? (object) " -USEALLAVAILABLECORES " : (object) "", this.unattended.Checked ? (object) " -UNATTENDED " : (object) "")
- }
- }.Start();
- if (this.worker != null && this.worker.IsBusy)
- {
- this.LoginServer.Close();
- this.worker.CancelAsync();
- }
- this.button2.Enabled = false;
- }
- private bool findInstall()
- {
- this.clientPath = (string) Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\NCWest\\BnS", "BaseDir", (object) "");
- return !string.IsNullOrWhiteSpace(this.clientPath);
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- try
- {
- if (ConfigurationManager.AppSettings["Username"] != null)
- this.usernameTB.Text = this.Dec(ConfigurationManager.AppSettings["Username"]);
- if (ConfigurationManager.AppSettings["Password"] != null)
- this.passwordTB.Text = this.Dec(ConfigurationManager.AppSettings["Password"]);
- }
- catch
- {
- }
- if (ConfigurationManager.AppSettings["Use64Bit"] != null)
- this.use64.Checked = ConfigurationManager.AppSettings["Use64Bit"].Equals("1");
- if (ConfigurationManager.AppSettings["DisableTextureStreaming"] != null)
- this.disableText.Checked = ConfigurationManager.AppSettings["DisableTextureStreaming"].Equals("1");
- if (ConfigurationManager.AppSettings["UseAllCPU"] != null)
- this.allCpu.Checked = ConfigurationManager.AppSettings["UseAllCPU"].Equals("1");
- if (ConfigurationManager.AppSettings["DisablePopUps"] != null)
- this.unattended.Checked = ConfigurationManager.AppSettings["DisablePopUps"].Equals("1");
- if (ConfigurationManager.AppSettings["Debug"] != null)
- this.Debugging = ConfigurationManager.AppSettings["Debug"].Equals("1");
- if (!this.LauncherInfo())
- this.Close();
- if (!this.findInstall())
- this.Close();
- this.RegionCB.DataSource = (object) this.regions;
- }
- private string Enc(string s)
- {
- return Convert.ToBase64String(MachineKey.Protect(Encoding.UTF8.GetBytes(s), this.Protect));
- }
- private string Dec(string s)
- {
- return Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(s), this.Protect));
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
- if (configuration.AppSettings.Settings["Username"] != null)
- configuration.AppSettings.Settings["Username"].Value = this.Enc(this.usernameTB.Text);
- else
- configuration.AppSettings.Settings.Add("Username", this.Enc(this.usernameTB.Text));
- if (configuration.AppSettings.Settings["Password"] != null)
- configuration.AppSettings.Settings["Password"].Value = this.Enc(this.passwordTB.Text);
- else
- configuration.AppSettings.Settings.Add("Password", this.Enc(this.passwordTB.Text));
- if (configuration.AppSettings.Settings["Use64Bit"] != null)
- configuration.AppSettings.Settings["Use64Bit"].Value = this.use64.Checked ? "1" : "0";
- else
- configuration.AppSettings.Settings.Add("Use64Bit", this.use64.Checked ? "1" : "0");
- if (configuration.AppSettings.Settings["DisableTextureStreaming"] != null)
- configuration.AppSettings.Settings["DisableTextureStreaming"].Value = this.disableText.Checked ? "1" : "0";
- else
- configuration.AppSettings.Settings.Add("DisableTextureStreaming", this.disableText.Checked ? "1" : "0");
- if (configuration.AppSettings.Settings["UseAllCPU"] != null)
- configuration.AppSettings.Settings["UseAllCPU"].Value = this.allCpu.Checked ? "1" : "0";
- else
- configuration.AppSettings.Settings.Add("UseAllCPU", this.allCpu.Checked ? "1" : "0");
- if (configuration.AppSettings.Settings["DisablePopUps"] != null)
- configuration.AppSettings.Settings["DisablePopUps"].Value = this.unattended.Checked ? "1" : "0";
- else
- configuration.AppSettings.Settings.Add("DisablePopUps", this.unattended.Checked ? "1" : "0");
- if (configuration.AppSettings.Settings["Debug"] != null)
- configuration.AppSettings.Settings["Debug"].Value = this.Debugging ? "1" : "0";
- else
- configuration.AppSettings.Settings.Add("Debug", this.Debugging ? "1" : "0");
- configuration.Save();
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing && this.components != null)
- this.components.Dispose();
- base.Dispose(disposing);
- }
- private void InitializeComponent()
- {
- this.usernameTB = new TextBox();
- this.passwordTB = new TextBox();
- this.button1 = new Button();
- this.label1 = new Label();
- this.label2 = new Label();
- this.button2 = new Button();
- this.label3 = new Label();
- this.RegionCB = new ComboBox();
- this.use64 = new CheckBox();
- this.disableText = new CheckBox();
- this.unattended = new CheckBox();
- this.allCpu = new CheckBox();
- this.SuspendLayout();
- this.usernameTB.Location = new Point(76, 16);
- this.usernameTB.Name = "usernameTB";
- this.usernameTB.Size = new Size(274, 20);
- this.usernameTB.TabIndex = 0;
- this.passwordTB.Location = new Point(76, 57);
- this.passwordTB.MaxLength = 16;
- this.passwordTB.Name = "passwordTB";
- this.passwordTB.PasswordChar = '♠';
- this.passwordTB.Size = new Size(274, 20);
- this.passwordTB.TabIndex = 1;
- this.button1.Location = new Point(17, 200);
- this.button1.Name = "button1";
- this.button1.Size = new Size(75, 23);
- this.button1.TabIndex = 2;
- this.button1.Text = "Login";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new EventHandler(this.button1_Click);
- this.label1.AutoSize = true;
- this.label1.Location = new Point(12, 19);
- this.label1.Name = "label1";
- this.label1.Size = new Size(58, 13);
- this.label1.TabIndex = 3;
- this.label1.Text = "Username:";
- this.label2.AutoSize = true;
- this.label2.Location = new Point(14, 60);
- this.label2.Name = "label2";
- this.label2.Size = new Size(56, 13);
- this.label2.TabIndex = 4;
- this.label2.Text = "Password:";
- this.button2.Enabled = false;
- this.button2.Location = new Point(197, 200);
- this.button2.Name = "button2";
- this.button2.Size = new Size(75, 23);
- this.button2.TabIndex = 5;
- this.button2.Text = "Launch";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new EventHandler(this.button2_Click);
- this.label3.AutoSize = true;
- this.label3.Location = new Point(14, 101);
- this.label3.Name = "label3";
- this.label3.Size = new Size(44, 13);
- this.label3.TabIndex = 6;
- this.label3.Text = "Region:";
- this.RegionCB.DropDownStyle = ComboBoxStyle.DropDownList;
- this.RegionCB.FormattingEnabled = true;
- this.RegionCB.Location = new Point(76, 98);
- this.RegionCB.Name = "RegionCB";
- this.RegionCB.Size = new Size(274, 21);
- this.RegionCB.TabIndex = 7;
- this.use64.AutoSize = true;
- this.use64.Location = new Point(17, 134);
- this.use64.Name = "use64";
- this.use64.Size = new Size(103, 17);
- this.use64.TabIndex = 8;
- this.use64.Text = "Use 64-bit Client";
- this.use64.UseVisualStyleBackColor = true;
- this.disableText.AutoSize = true;
- this.disableText.Location = new Point(17, 166);
- this.disableText.Name = "disableText";
- this.disableText.Size = new Size(144, 17);
- this.disableText.TabIndex = 9;
- this.disableText.Text = "Disable texture streaming";
- this.disableText.UseVisualStyleBackColor = true;
- this.unattended.AutoSize = true;
- this.unattended.Location = new Point(197, 134);
- this.unattended.Name = "unattended";
- this.unattended.Size = new Size(137, 17);
- this.unattended.TabIndex = 10;
- this.unattended.Text = "Disable message boxes";
- this.unattended.UseVisualStyleBackColor = true;
- this.allCpu.AutoSize = true;
- this.allCpu.Location = new Point(197, 166);
- this.allCpu.Name = "allCpu";
- this.allCpu.Size = new Size(153, 17);
- this.allCpu.TabIndex = 11;
- this.allCpu.Text = "Use all available cpu cores";
- this.allCpu.UseVisualStyleBackColor = true;
- this.AutoScaleDimensions = new SizeF(6f, 13f);
- this.AutoScaleMode = AutoScaleMode.Font;
- this.ClientSize = new Size(380, 254);
- this.Controls.Add((Control) this.allCpu);
- this.Controls.Add((Control) this.unattended);
- this.Controls.Add((Control) this.disableText);
- this.Controls.Add((Control) this.use64);
- this.Controls.Add((Control) this.RegionCB);
- this.Controls.Add((Control) this.label3);
- this.Controls.Add((Control) this.button2);
- this.Controls.Add((Control) this.label2);
- this.Controls.Add((Control) this.label1);
- this.Controls.Add((Control) this.button1);
- this.Controls.Add((Control) this.passwordTB);
- this.Controls.Add((Control) this.usernameTB);
- this.Name = nameof (Form1);
- this.Text = "Replacement Launcher";
- this.FormClosing += new FormClosingEventHandler(this.Form1_FormClosing);
- this.Load += new EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- private class region
- {
- public string name;
- public string value;
- public string appId;
- public region(string n, string v, string a)
- {
- this.name = n;
- this.value = v;
- this.appId = a;
- }
- public override string ToString()
- {
- return this.name;
- }
- }
- public class BNSXorEncryption
- {
- private byte[] encKey;
- private byte[] decKey;
- private int encCounter;
- private int decCounter;
- private int encSum;
- private int decSum;
- private byte[] key;
- public BNSXorEncryption(byte[] keyInt)
- {
- this.key = keyInt;
- }
- public byte[] Encrypt(byte[] src, int offset, int len)
- {
- if (this.encKey == null)
- {
- if (this.key == null)
- return (byte[]) null;
- this.encKey = new byte[this.key.Length];
- this.key.CopyTo((Array) this.encKey, 0);
- this.encCounter = 0;
- }
- return this.BlockEncrypt(src, this.encKey, ref this.encCounter, ref this.encSum);
- }
- public byte[] Decrypt(byte[] src, int offset, int len)
- {
- if (this.decKey == null)
- {
- if (this.key == null)
- return (byte[]) null;
- this.decKey = new byte[this.key.Length];
- this.key.CopyTo((Array) this.decKey, 0);
- this.decCounter = 0;
- }
- return this.BlockEncrypt(src, this.decKey, ref this.decCounter, ref this.decSum);
- }
- private byte[] BlockEncrypt(byte[] src, byte[] key, ref int counter, ref int sum)
- {
- for (int index1 = 0; index1 < src.Length; ++index1)
- {
- int index2 = counter + 1 & (int) byte.MaxValue;
- counter = index2;
- int index3 = sum + (int) key[index2] & (int) byte.MaxValue;
- sum = index3;
- int num = (int) key[index2];
- key[index2] = key[index3];
- key[index3] = (byte) num;
- src[index1] = (byte) ((uint) src[index1] ^ (uint) key[(int) key[sum] + (int) key[counter] & (int) byte.MaxValue]);
- }
- return src;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement