Пример #1
0
        static TelemetryMessage()
        {
            // Obtendo MachineID
            DefaultMachineID = FingerPrint.Value();

            DefaultStationName = Environment.GetEnvironmentVariable("COMPUTERNAME");
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            // Verify licensing valid
            string licensePath  = AppConfigReadingService.GetConfigSetting("metadataFileDirectory") + "\\Licensing.txt";
            string savedLicense = IOService.ReadTextFileToString(licensePath);
            string validLicense = FingerPrint.Value();

            if (savedLicense == validLicense)
            {
                StartPage startPage = new StartPage();
                mainFrame.NavigationService.Navigate(startPage);
            }
            else
            {
                string           sMessageBoxText = "程序启动失败,序列号错误";
                string           sCaption        = "程序启动失败";
                MessageBoxButton btnMessageBox   = MessageBoxButton.OK;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Error;
                MessageBoxResult rsltMessageBox  = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.OK:
                    Application.Current.Shutdown();
                    return;
                }
            }


            //Testing();
            //Testing2();
        }
Пример #3
0
        /// <summary>
        /// Init: Calculate hardwareid.
        /// </summary>
        public KeyOnline(IPluginHost host)
        {
            m_host = host;
            FingerPrint clFingerPrint = new FingerPrint();

            HardwareId = clFingerPrint.Value();
        }
Пример #4
0
 public UniversalClient()
 {
     Client                   = new TcpClient();
     Encryption               = new ClientRSA();
     clientSignature          = new Signature();
     clientSignature.clientId = FingerPrint.Value();
     clientSignature.clientIp = new WebClient().DownloadString("http://icanhazip.com");
 }
Пример #5
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain currentDomain = AppDomain.CurrentDomain;

            fingerprint = FingerPrint.Value();
            Initialize();
        }
Пример #6
0
        public static void GetPremiumScript(ScriptRequest eScriptRequest)
        {
            object ret = SendAuthData(UserData.SerialKey, FingerPrint.Value(), false);

            if (ret is Result)
            {
                Enum.TryParse(ret.ToString(), out Result result);
                if (result == Result.Success)
                {
                    object retScript = SendScriptRequest(eScriptRequest);
                }
            }
        }
Пример #7
0
 static void Main()
 {
     fingerprint = FingerPrint.Value();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (!System.Diagnostics.Debugger.IsAttached)
     {
         Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
         Application.ThreadException += Application_ThreadException;
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     }
     //loginForm _loginForm = new loginForm();
     //if (_loginForm.ShowDialog() == DialogResult.OK)
     //{
     Application.Run(new Form1());
     //}
 }
Пример #8
0
        private void mbCheckSerial_Click(object sender, EventArgs e)
        {
            object ret = TcpConnection.SendAuthData(mtbSerialKey.Text, FingerPrint.Value(), false);

            if (ret is Result)
            {
                Enum.TryParse(ret.ToString(), out Result result);
                if (result == Result.Success)
                {
                    mainForm.Text = mainForm.Tag.ToString() + $"{StaticData.Version.Major}.{StaticData.Version.Minor} ({strings.Premium}) | by TH3C0D3R";
                    StaticData.UserData.SerialKey = mtbSerialKey.Text;
                    StaticData.UserData.SaveSettings();
                    object retList = Helper.ExecuteMethod(StaticData.PremAssembly, "EntryPoint", "AddPremiumControl", null);
                    if (retList is List <UCPremium> list)
                    {
                        if (StaticData.UserData.DarkMode)
                        {
                            ((MainDark)mainForm).tlpPremium.Controls.AddRange(list.ToArray());
                            ((MainDark)mainForm).tlpPremium.Invalidate(true);
                        }
                        else
                        {
                            ((Main)mainForm).tlpPremium.Controls.AddRange(list.ToArray());
                            ((Main)mainForm).tlpPremium.Invalidate(true);
                        }
                    }
                }
                else if (result == Result.Expired)
                {
                    Invoker.SetProperty(this, () => Text, Tag.ToString() + $"{StaticData.Version.Major}.{StaticData.Version.Minor} ({strings.Expired}) | by TH3C0D3R");
                    if (!blockExpireBox)
                    {
                        MessageBox.Show(Owner, $"{strings.SubscriptionExpired}", $"{strings.SubExpiredTitle}");
                    }
                    blockExpireBox = true;
                }
                else
                {
                    mainForm.Text = mainForm.Tag.ToString() + $"{StaticData.Version.Major}.{StaticData.Version.Minor} | by TH3C0D3R";
                    MessageBox.Show(Owner, $"{strings.LicenceNotValid}", $"{strings.FailedToActivate}");
                }
            }
        }
Пример #9
0
        private void MetroButton1_Click(object sender, EventArgs e)
        {
            var hwid = FingerPrint.Value();

            var login       = api.Login(keyinput.Text, hwid, Program.appToken);
            var personsDump = ObjectDumper.Dump(login, DumpStyle.CSharp);

            Console.WriteLine(personsDump);

            if (Convert.ToBoolean(login["success"]) == false)
            {
                string message = login["message"].ToString();
                MessageBox.Show(message,
                                "something wrong!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
            }
            else if (Convert.ToBoolean(login["success"]) == true)
            {
                string message = login["message"].ToString();
                MessageBox.Show(message,
                                "Thanks!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information
                                );

                Program.syncKeyConfig(login);
                App app = new App();
                app.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Unknown Error!",
                                "Something Wrong!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
            }
        }
Пример #10
0
        public static string Decrypt(string cipherString, bool useHashing = false)
        {
            //https://www.codeproject.com/Articles/14150/Encrypt-and-Decrypt-Data-with-C
            try
            {
                byte[] keyArray;

                var toEncryptArray = Convert.FromBase64String(cipherString);

                var key = FingerPrint.Value();

                if (useHashing)
                {
                    var hashmd5 = new MD5CryptoServiceProvider();
                    keyArray = hashmd5.ComputeHash(Encoding.UTF8.GetBytes(key));

                    hashmd5.Clear();
                }
                else
                {
                    keyArray = Encoding.UTF8.GetBytes(key);
                }

                var tdes = new TripleDESCryptoServiceProvider
                {
                    Key     = keyArray,
                    Mode    = CipherMode.ECB,
                    Padding = PaddingMode.PKCS7
                };

                var cTransform  = tdes.CreateDecryptor();
                var resultArray = cTransform.TransformFinalBlock(
                    toEncryptArray, 0, toEncryptArray.Length);
                tdes.Clear();
                return(Encoding.UTF8.GetString(resultArray));
            }
            catch (Exception)
            {
                return("");
            }
        }
        private void bwDataRequest_DoWork(object sender, DoWorkEventArgs e)
        {
            // Find out the Index of the bWorker that called this DoWork (could be cleaner, I know)
            int Y;
            int Index  = default;
            var loopTo = Information.UBound(bwDataRequest);

            for (Y = 0; Y <= loopTo; Y++)
            {
                if (sender.Equals(bwDataRequest[Y]))
                {
                    Index = Y;
                    break;
                }
            }

            _queue_data_struct queue;

            queue = (_queue_data_struct)e.Argument;
            var vars = new Dictionary <string, string>();

            vars = queue.vars;

            // TODO translation need to be local
            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                e.Result = "{'error':true,'message':'" + resources.GetString("errorNoNetwork", CultureInfo.CurrentCulture) + "'}";
                return;
            }

            if (vars is null)
            {
                e.Result = "{'error':true,'message':'missconfiguration vars'}";
                return;
            }

            if (!vars.ContainsKey("id"))
            {
                vars.Add("id", state.userId);
            }

            if (!vars.ContainsKey("pid"))
            {
                var appId = new FingerPrint();
                vars.Add("pid", appId.Value());
            }

            if (!vars.ContainsKey("language"))
            {
                vars.Add("language", state.currentLang);
            }

            if (!vars.ContainsKey("origin"))
            {
                vars.Add("origin", state.customization.softwareAccessMode);
            }

            string json               = JsonConvert.SerializeObject(vars, Formatting.Indented);
            var    encryption         = new AesCipher(state);
            string encrypted          = HttpUtility.UrlEncode(encryption.encrypt(json));
            var    PostData           = "origin=" + state.customization.softwareAccessMode + "&data=" + encrypted;
            var    request            = WebRequest.Create(url);
            string responseFromServer = "";
            string decrypted          = "";

            request.Method = "POST";
            var byteArray = Encoding.UTF8.GetBytes(PostData);

            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", state.ApiHttpHeaderToken + "-" + state.customization.softwareAccessMode);
            request.ContentLength = (long)byteArray.Length;
            try
            {
                var dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                dataStream = response.GetResponseStream();
                var reader = new StreamReader(dataStream);
                responseFromServer = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();
                if (response.StatusCode == HttpStatusCode.Accepted | (int)response.StatusCode == 200)
                {
                    if (IsBase64String(responseFromServer) & !responseFromServer.Equals(""))
                    {
                        decrypted = encryption.decrypt(responseFromServer).Replace(@"\'", "'");
                    }
                    else
                    {
                        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                        decrypted = "{'error':true,'encrypted':false,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + " |" + responseFromServer + "|'}";
                    }
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                    decrypted = "{'error':true,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + " (" + ((int)response.StatusCode).ToString() + ")', 'statuscode':'" + ((int)response.StatusCode).ToString() + "'}";
                }
            }
            catch (Exception ex)
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                decrypted = "{'error':true,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + " (" + ex.Message.ToString().Replace("'", @"\'") + ")'}";
            }

            e.Result = decrypted.Replace(@"\'", "'");
        }
Пример #12
0
 public String HardwareFingerprint()
 {
     //Logger.Debug("Got HardwareDesc : " + FingerPrint.HardwareDescription());
     Logger.Debug("Got fingerprint : " + FingerPrint.Value());
     return(FingerPrint.Value());
 }
Пример #13
0
        private void bwDataRequest_DoWork(object sender, DoWorkEventArgs e)
        {
            byte[] responseBytes;

            // Find out the Index of the bWorker that called this DoWork (could be cleaner, I know)
            int Y;
            int Index  = default;
            var loopTo = Information.UBound(bwDataRequest);

            for (Y = 0; Y <= loopTo; Y++)
            {
                if (sender.Equals(bwDataRequest[Y]))
                {
                    Index = Y;
                    break;
                }
            }

            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                responseBytes = Encoding.UTF8.GetBytes("{'error':true,'message':'" + resources.GetString("errorNoNetwork", CultureInfo.CurrentCulture) + "'}");
                return;
            }

            _queue_data_struct queue;

            queue = (_queue_data_struct)e.Argument;
            var vars = new Dictionary <string, string>();

            vars = queue.vars;
            if (!vars.ContainsKey("id"))
            {
                vars.Add("id", state.userId);
            }

            if (!vars.ContainsKey("pid"))
            {
                var appId = new FingerPrint();
                vars.Add("pid", appId.Value());
            }

            if (!vars.ContainsKey("language"))
            {
                vars.Add("language", state.currentLang);
            }

            string json       = JsonConvert.SerializeObject(vars, Formatting.Indented);
            var    encryption = new AesCipher(state);
            string encrypted  = HttpUtility.UrlEncode(encryption.encrypt(json));
            var    PostData   = new Dictionary <string, string>();

            PostData.Add("origin", state.customization.softwareAccessMode);
            PostData.Add("data", encrypted);
            double         currentspeed  = -1;
            string         boundary      = "---------------------------" + DateTime.Now.Ticks.ToString("x");
            var            boundarybytes = Encoding.ASCII.GetBytes(Constants.vbCrLf + "--" + boundary + Constants.vbCrLf);
            HttpWebRequest wr            = (HttpWebRequest)WebRequest.Create(url);

            wr.ContentType = "multipart/form-data; boundary=" + boundary;
            wr.Method      = "POST";
            wr.KeepAlive   = true;
            wr.Credentials = CredentialCache.DefaultCredentials;
            var    rs = wr.GetRequestStream();
            string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"" + Constants.vbCrLf + Constants.vbCrLf + "{1}";

            for (int i = 0, loopTo1 = PostData.Count - 1; i <= loopTo1; i++)
            {
                rs.Write(boundarybytes, 0, boundarybytes.Length);
                string formitem      = string.Format(formdataTemplate, PostData.Keys.ElementAtOrDefault(i), PostData[PostData.Keys.ElementAtOrDefault(i)]);
                var    formitembytes = Encoding.UTF8.GetBytes(formitem);
                rs.Write(formitembytes, 0, formitembytes.Length);
            }

            rs.Write(boundarybytes, 0, boundarybytes.Length);
            string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + Constants.vbCrLf + "Content-Type: {2}" + Constants.vbCrLf + Constants.vbCrLf;
            string header         = string.Format(headerTemplate, "file", Path.GetFileName(queue.filenameOrSavePath), "application/octet-stream");
            var    headerbytes    = Encoding.UTF8.GetBytes(header);

            rs.Write(headerbytes, 0, headerbytes.Length);
            var              fileStream     = new FileStream(queue.filenameOrSavePath, FileMode.Open, FileAccess.Read);
            var              buffer         = new byte[4096];
            int              bytesRead      = 0;
            double           totalBytesRead = 0;
            int              readings       = 0;
            var              speedtimer     = new Stopwatch();
            _data_statistics dataStatisticsItem;

            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
            dataStatisticsItem.filesize          = Conversions.ToDouble(resources.GetString("size", CultureInfo.CurrentCulture) + ": " + Math.Round(fileStream.Length / (double)1024, 0) + " " + resources.GetString("bytes", CultureInfo.CurrentCulture));
            dataStatisticsItem.bytesSentReceived = 0;
            dataStatisticsItem.speed             = 0;
            dataStatistics[queueBWorker[Index]]  = dataStatisticsItem;
            bytesRead = fileStream.Read(buffer, 0, buffer.Length);
            while (bytesRead != 0)
            {
                rs.Write(buffer, 0, bytesRead);
                dataStatisticsItem.bytesSentReceived += bytesRead;
                dataStatistics[queueBWorker[Index]]   = dataStatisticsItem;
                readings += 1;
                if (readings >= 5)
                {
                    dataStatisticsItem.speed            = 20480 / (speedtimer.ElapsedMilliseconds / (double)1000);
                    dataStatistics[queueBWorker[Index]] = dataStatisticsItem;
                    speedtimer.Reset();
                    readings = 0;
                    updateProgressStatistics?.Invoke(this, queue.misc);
                }

                bytesRead = fileStream.Read(buffer, 0, buffer.Length);
            }

            fileStream.Close();
            var trailer = Encoding.ASCII.GetBytes(Constants.vbCrLf + "--" + boundary + "--" + Constants.vbCrLf);

            rs.Write(trailer, 0, trailer.Length);
            rs.Close();
            WebResponse wresp = null;

            try
            {
                wresp = wr.GetResponse();
                var stream2 = wresp.GetResponseStream();
                var reader2 = new StreamReader(stream2);
                responseBytes = Encoding.UTF8.GetBytes(reader2.ReadToEnd());
            }
            catch (Exception ex)
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                responseBytes = Encoding.UTF8.GetBytes("{'error':true,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + ":" + ex.Message + "'}");
                if (wresp is object)
                {
                    wresp.Close();
                    wresp = null;
                }
            }

            wr       = null;
            e.Result = responseBytes;
        }
Пример #14
0
 private void FrmRegisterLoad(object sender, EventArgs e)
 {
     TxtSerial.Text = FingerPrint.Value();
 }
Пример #15
0
        /// <summary>
        /// Contacts server for Login Check
        /// </summary>
        /// <returns></returns>
        public bool Login(out string Token)
        {
Connect:
            if (!clientSocket.Connected)
            {
                if (fails >= 3)
                {
                    fails = 0;
                    Token = "";

                    return(false);
                }

                fails++;

                Connect();

                goto Connect;
            }

            CleanStream();

            Token = "";

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=Login&Username=MaverickCheats&Password=@UrDrive337859185&HWID=" + FingerPrint.Value());

            if (Response.Split('-')[0] == "Login Found")
            {
                if (Response.Split('-')[1] != "")
                {
                    Token = Response.Split('-')[1];

                    return(true);
                }
                else
                {
                    Token = Response;

                    return(false);
                }
            }

            Console.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(false);
        }
Пример #16
0
        private void BtnReleaseClick(object sender, EventArgs e)
        {
            var result = MessageBox.Show(@"Are you sure you want to release your license?", @"License Action",
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                var server = new Server();
                server.ExecuteNonQuery("UPDATE Customers SET KeyCode ='', Active=0 WHERE KeyCode='" + FingerPrint.Value() + "'");
                Environment.Exit(0);
            }
            return;
        }
Пример #17
0
 public Splash1()
 {
     InitializeComponent();
     GetColor();
     try
     {
         SALT = FingerPrint.Value();
         SALT = StringToHex(SALT);
         RegistryKey localMachine = Registry.LocalMachine;
         if (localMachine.OpenSubKey("SOFTWARE\\BnS Buddy\\") == null)
         {
             Registry.LocalMachine.CreateSubKey("SOFTWARE\\BnS Buddy");
         }
         if (File.ReadAllText(AppPath + "\\Settings.ini").Contains("rememberme = true"))
         {
             metroComboBox1.Enabled = true;
             localMachine           = Registry.LocalMachine;
             localMachine           = localMachine.OpenSubKey("SOFTWARE\\BnS Buddy\\", writable: true);
             ReOrderTree(localMachine);
             if (metroComboBox1.Items.Count >= 1)
             {
                 metroComboBox1.SelectedIndex = 0;
                 if (localMachine != null && localMachine.GetValue("lastused") != null)
                 {
                     string empty = string.Empty;
                     empty = localMachine.GetValue("lastused").ToString();
                     if (empty != null && empty.Length > 1)
                     {
                         metroComboBox1.SelectedIndex = metroComboBox1.FindString(empty);
                         metroButton3.Visible         = true;
                     }
                 }
                 string empty2 = string.Empty;
                 string empty3 = string.Empty;
                 if (localMachine != null)
                 {
                     string name = metroComboBox1.SelectedItem.ToString();
                     empty2 = localMachine.OpenSubKey(name).GetValue("username").ToString();
                     empty3 = localMachine.OpenSubKey(name).GetValue("password").ToString();
                     empty2 = Dec(empty2);
                     empty3 = Dec(empty3);
                     if (empty2.Length > 0 && empty3.Length > 0)
                     {
                         metroTextBox1.Text        = empty2;
                         metroTextBox2.Text        = empty3;
                         metroCheckBox1.CheckState = CheckState.Checked;
                         metroButton3.Visible      = true;
                         autologinapproved         = true;
                     }
                     else
                     {
                         metroCheckBox1.CheckState = CheckState.Unchecked;
                         metroButton3.Visible      = false;
                     }
                 }
             }
         }
         CheckLock();
     }
     catch
     {
         Prompt.Popup("Resetted Registry. Reasons below." + Environment.NewLine + "Possible causes include the following:" + Environment.NewLine + "- The protected data was tampered with and/or contained invalid characters.");
         Form1.CurrentForm.metroToggle28.CheckState = CheckState.Unchecked;
         Form1.CurrentForm.metroToggle28.Checked    = false;
         ClearRegistry();
     }
 }
        private void bwDataRequest_DoWork(object sender, DoWorkEventArgs e)
        {
            // Find out the Index of the bWorker that called this DoWork (could be cleaner, I know)
            int Y;
            int Index  = default;
            var loopTo = Information.UBound(bwDataRequest);

            for (Y = 0; Y <= loopTo; Y++)
            {
                if (sender.Equals(bwDataRequest[Y]))
                {
                    Index = Y;
                    break;
                }
            }

            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                e.Result = false;
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                fileExtension[queueBWorker[Index]] = "{'error':true,'message':'" + resources.GetString("errorNoNetwork", CultureInfo.CurrentCulture) + "'}";
                return;
            }

            _queue_data_struct queue;

            queue = (_queue_data_struct)e.Argument;
            var vars = new Dictionary <string, string>();

            vars = queue.vars;
            if (!vars.ContainsKey("id"))
            {
                vars.Add("id", state.userId);
            }

            if (!vars.ContainsKey("pid"))
            {
                var appId = new FingerPrint();
                vars.Add("pid", appId.Value());
            }

            if (!vars.ContainsKey("language"))
            {
                vars.Add("language", state.currentLang);
            }

            string json       = JsonConvert.SerializeObject(vars, Formatting.Indented);
            var    encryption = new AesCipher(state);
            string encrypted  = HttpUtility.UrlEncode(encryption.encrypt(json));
            var    PostData   = new Dictionary <string, string>();

            PostData.Add("origin", state.customization.softwareAccessMode);
            PostData.Add("data", encrypted);
            string Data2Send = "";

            for (int i = 0, loopTo1 = PostData.Count - 1; i <= loopTo1; i++)
            {
                Data2Send += HttpUtility.UrlEncode(PostData.Keys.ElementAtOrDefault(i)) + "=" + HttpUtility.UrlEncode(PostData[PostData.Keys.ElementAtOrDefault(i)]) + "&";
            }
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";
            var data = Encoding.UTF8.GetBytes(Data2Send);

            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;
            var requestStream = request.GetRequestStream();

            requestStream.Write(data, 0, data.Length);
            requestStream.Close();
            int readings   = 0;
            var speedtimer = new Stopwatch();
            _data_statistics dataStatisticsItem;

            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (var stream = response.GetResponseStream())
                    {
                        using (var bytes = new MemoryStream())
                        {
                            var Buffer = new byte[257];
                            dataStatisticsItem.filesize          = Math.Round(bytes.Length / (double)1024, 0);
                            dataStatisticsItem.bytesSentReceived = 0;
                            dataStatisticsItem.speed             = 0;
                            dataStatistics[queueBWorker[Index]]  = dataStatisticsItem;
                            while (bytes.Length < response.ContentLength)
                            {
                                int read = stream.Read(Buffer, 0, Buffer.Length);
                                if (read > 0)
                                {
                                    bytes.Write(Buffer, 0, read);
                                }
                                else
                                {
                                    break;
                                }

                                readings += 1;
                                if (readings >= 5)
                                {
                                    dataStatisticsItem.speed            = 20480 / (speedtimer.ElapsedMilliseconds / (double)1000);
                                    dataStatistics[queueBWorker[Index]] = dataStatisticsItem;
                                    speedtimer.Reset();
                                    readings = 0;
                                    updateProgressStatistics?.Invoke(this, dataStatisticsItem, queue.misc);
                                }
                            }

                            var utf8Encoding = new UTF8Encoding(true);
                            if (response.StatusCode == HttpStatusCode.Accepted | (int)response.StatusCode == 200)
                            {
                                string responseFromServer = utf8Encoding.GetString(bytes.ToArray());
                                string decrypted          = "";
                                if (IsBase64String(responseFromServer) & !responseFromServer.Equals(""))
                                {
                                    decrypted = encryption.decrypt(responseFromServer).Replace(@"\'", "'");
                                    fileExtension[queueBWorker[Index]] = decrypted;
                                    e.Result = false;
                                }
                                else if (response.GetResponseHeader("Content-Disposition") is object && !response.GetResponseHeader("Content-Disposition").Equals(""))
                                {
                                    fileExtension[queueBWorker[Index]] = response.GetResponseHeader("Content-Disposition").Substring(response.GetResponseHeader("Content-Disposition").IndexOf("filename=") + 9);
                                    e.Result = bytes.ToArray();
                                }
                                else
                                {
                                    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                                    fileExtension[queueBWorker[Index]] = "{'error':true,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + " (" + ((int)response.StatusCode).ToString() + ")'}";
                                    e.Result = false;
                                }
                            }
                            else
                            {
                                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(state.currentLang);
                                fileExtension[queueBWorker[Index]] = "{'error':true,'message':'" + resources.GetString("contactingCommServer", CultureInfo.CurrentCulture) + " (" + ((int)response.StatusCode).ToString() + ")', 'statuscode':'" + ((int)response.StatusCode).ToString() + "'}";
                                e.Result = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                e.Result = false;
                fileExtension[queueBWorker[Index]] = "{'error':true,'message':'" + ex.Message + "'}";
            }
        }
Пример #19
0
        /// <summary>
        /// Contacts server for Login Check
        /// </summary>
        /// <param name="Username">Username</param>
        /// <param name="Password">Password</param>
        /// <param name="HWID">Hardware ID</param>
        /// <param name="Token">Users Token</param>
        /// <returns></returns>
        public string Login(string Username, string Password, out string Token)
        {
            string Success;

            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            Token = "";

            if (!Prepare.PrepareString(Username) || !Prepare.PrepareString(Password))
            {
                if (!Prepare.PrepareString(Username))
                {
                    Log.Write("Prepare Failed: Username="******"Prepare Failed: Password="******"Empty Credentials");
            }

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=Login&Username="******"&Password="******"&HWID=" + FingerPrint.Value());

            if (Response.Split('-')[0] == "Login Found")
            {
                Token = Response.Split('-')[1];

                Log.Write("Login Found: " + Username + " -> " + Password + " -> " + Token);

                Success = "Login Found";
            }
            else
            {
                Log.Write("Error: Login not Found -> " + Response);

                Success = Response;
            }

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Success);
        }
Пример #20
0
        /// <summary>
        /// Contacts server for Login Check
        /// </summary>
        /// <param name="Username">Username</param>
        /// <param name="Password">Password</param>
        /// <param name="HWID">Hardware ID</param>
        /// <param name="Token">Users Token</param>
        /// <returns></returns>
        public string ResetPassword(string Username, string Password)
        {
            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            if (!Prepare.PrepareString(Password))
            {
                if (!Prepare.PrepareString(Password))
                {
                    Log.Write("Prepare Failed: Password="******"Empty Credentials");
            }

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=ResetPassword&Username="******"&Password="******"&HWID=" + FingerPrint.Value());

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Response);
        }
Пример #21
0
        private static void ReceiveCallback(IAsyncResult ar)
        {
            try
            {
                var state     = (StateObject)ar.AsyncState;
                var client    = state.WorkSocket;
                var bytesRead = client.EndReceive(ar);

                if (bytesRead > 0)
                {
                    var       msg    = new CCMessage(state.Buffer, bytesRead);
                    short     magic  = 0;
                    ByteArray packet = new CCMessage();
                    if (msg.Read(ref magic) &&
                        magic == Magic &&
                        msg.Read(ref packet))
                    {
                        CCMessage.MessageType coreId = 0;
                        var message = new CCMessage(packet);
                        message.Read(ref coreId);
                        switch (coreId)
                        {
                        case CCMessage.MessageType.Notify:
                        {
                            var info = "";
                            message.Read(ref info);
                            if (info.Contains("<region>") && info.Contains("</region>"))
                            {
                                info = info.Replace("<region>", "");
                                info = info.Replace("</region>", "");
                                if (info == "S4Violet362")
                                {
                                    var sendmsg = new CCMessage();
                                    sendmsg.Write(Constants.LoginWindow.GetUsername());
                                    sendmsg.Write(Constants.LoginWindow.GetPassword());
                                    sendmsg.Write(FingerPrint.Value());
                                    sendmsg.Write("test");

                                    RmiSend(client, 15, sendmsg);
                                    Constants.LoginWindow.UpdateLabel("Connecting...");
                                }
                                else
                                {
                                    Constants.LoginWindow.UpdateLabel("Error");
                                }
                            }

                            break;
                        }

                        case CCMessage.MessageType.Rmi:
                        {
                            short rmiId = 0;
                            if (!message.Read(ref rmiId))
                            {
                                Constants.LoginWindow.UpdateLabel("Received corrupted Rmi message.");
                            }
                            else
                            {
                                switch (rmiId)
                                {
                                case 16:
                                {
                                    var success = false;
                                    if (message.Read(ref success) && success)
                                    {
                                        ReceiveDone.Set();
                                        var code = "";
                                        message.Read(ref code);
                                        Constants.LoginWindow.UpdateLabel(
                                            $"");
                                        Constants.LoginWindow.Ready(code);
                                        _connected = true;
                                        var sendmsg = new CCMessage();
                                        RmiSend(client, 17, sendmsg);
                                        client.Disconnect(false);
                                        client.Close();

                                        Process.Start("S4client.exe", string.Format("-rc:eu -lac:eng -auth_server_ip:{0} -aeria_acc_code:{1}", Constants.ConnectEndPoint.Address, Constants.LoginWindow.AuthCode));
                                        Environment.Exit(0);
                                    }
                                    else
                                    {
                                        ReceiveDone.Set();
                                        var errcode = "";
                                        message.Read(ref errcode);
                                        Constants.LoginWindow.UpdateLabel($"Failed: {errcode}");
                                        Constants.LoginWindow.Reset();
                                        _connected = true;
                                        client.Disconnect(false);
                                        client.Close();
                                    }
                                }
                                break;

                                default:
                                    Constants.LoginWindow.UpdateLabel($"Received unknown rmiId. {rmiId}");
                                    break;
                                }
                            }
                            break;
                        }

                        case CCMessage.MessageType.Encrypted:
                        {
                            break;
                        }
                        }

                        if (!_connected)
                        {
                            client.BeginReceive(state.Buffer, 0, StateObject.BufferSize, 0,
                                                ReceiveCallback, state);
                        }
                    }
                    else
                    {
                        ReceiveDone.Set();
                        client.Disconnect(true);
                    }
                }
            }
            catch (Exception e)
            {
                // ignored
#if DEBUG
                Constants.LoginWindow.UpdateLabel($"Error -> {e.ToString()}");
#endif
            }
        }
Пример #22
0
        /// <summary>
        /// Contacts server for Registeration Check
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Password"></param>
        /// <param name="HWID"></param>
        /// <returns></returns>
        public string Register(string Username, string Password)
        {
            string Success;

            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            if (!Prepare.PrepareString(Username) || !Prepare.PrepareString(Password))
            {
                if (!Prepare.PrepareString(Username))
                {
                    Log.Write("Prepare Failed: Username="******"Prepare Failed: Password="******"Empty Credentials");
            }

            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=Register&Username="******"&Password="******"&HWID=" + FingerPrint.Value());

            if (Response == "Registration Successful")
            {
                Log.Write("Registration Successful: " + Username + " -> " + Password);

                Success = "Registration Successful";
            }
            else
            {
                Log.Write("Registration Failed: " + Username + " -> " + Password);

                Success = Response;
            }

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Success);
        }
Пример #23
0
 public void TestFingerPrint()
 {
     Console.WriteLine(FingerPrint.FingerPrintInfos());
     Console.WriteLine(FingerPrint.Value());
 }
 internal UniqueValue()
 {
     fingerPrintValue        = FingerPrint.Value();
     reducedFingerPrintValue = GetReducedFingerPrintValue();
 }