From 0b261b4e0224ee8fa55230703ac8b7f3c74694b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20S?= Date: Sun, 25 Sep 2016 21:17:22 +0200 Subject: [PATCH] Added options to delete key(s) from the input depending of preferences. --- ASFui/ASFProcess.cs | 81 +++++++++++++++++++----- ASFui/App.config | 15 +++++ ASFui/Properties/Settings.Designer.cs | 60 ++++++++++++++++++ ASFui/Properties/Settings.settings | 15 +++++ ASFui/SettingsForm.Designer.cs | 90 ++++++++++++++++++++++++++- ASFui/SettingsForm.cs | 11 ++++ 6 files changed, 252 insertions(+), 20 deletions(-) diff --git a/ASFui/ASFProcess.cs b/ASFui/ASFProcess.cs index ecdd20c..4393f2b 100644 --- a/ASFui/ASFProcess.cs +++ b/ASFui/ASFProcess.cs @@ -1,7 +1,10 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using Microsoft.VisualBasic; @@ -11,12 +14,17 @@ namespace ASFui [SuppressMessage("ReSharper", "InconsistentNaming")] public class ASFProcess { + private readonly ASFui _asf; private Process ASF; private readonly RichTextBox output; private Thread outputThread; + private readonly StringBuilder sb = new StringBuilder(); + private bool loaded; + private string key; - public ASFProcess(RichTextBox rtb) + public ASFProcess(ASFui asf, RichTextBox rtb) { + _asf = asf; ASF = new Process(); output = rtb; @@ -42,44 +50,82 @@ public ASFProcess(RichTextBox rtb) private void PrintOutput() { - var sb = new StringBuilder(); int s; while ((s = ASF.StandardOutput.Read()) != 0) { - MethodInvoker mi1 = delegate + MethodInvoker mi = delegate { + key = Regex.Match(sb.ToString(), @"[0-9A-Z]{5}-[0-9A-Z]{5}-[0-9A-Z]{5}", RegexOptions.IgnoreCase).Value; output.AppendText(sb.ToString()); + Check(); output.SelectionStart = output.Text.Length; output.ScrollToCaret(); sb.Clear(); }; sb.Append(Convert.ToChar(s)); - if(s == '\n') + + if (s == '\n') { - output.Invoke(mi1); + output.Invoke(mi); } + } + } - if (sb.ToString().EndsWith("\"android:\"):") || sb.ToString().EndsWith("login:") || + private void Check() + { + if (sb.ToString().EndsWith("\"android:\"):") || sb.ToString().EndsWith("login:") || sb.ToString().EndsWith("+1234567890):") || sb.ToString().EndsWith("mobile:") || sb.ToString().EndsWith("email:") || sb.ToString().EndsWith("PIN:") || sb.ToString().EndsWith("app:") || sb.ToString().EndsWith("hostname:")) + { + output.AppendText(sb + " "); + var result = Interaction.InputBox(sb.ToString(), @"Enter necessary input"); + ASF.StandardInput.WriteLine(result); + ASF.StandardInput.Flush(); + output.AppendText(result + Environment.NewLine + sb); + sb.Clear(); + } + + else if ((!sb.ToString().StartsWith("[AES]") ^ sb.ToString().StartsWith("[ProtectedDataForCurrentUser]")) + && sb.ToString().EndsWith("password:")) + { + var Password = new Password(ASF, sb.ToString()); + Password.ShowDialog(); + sb.Clear(); + } + + if (key != "") + { + if (sb.ToString().Contains("OK") && Properties.Settings.Default.ClearOk) { - output.AppendText(sb + " "); - var result = Interaction.InputBox(sb.ToString(), @"Enter necessary input"); - ASF.StandardInput.WriteLine(result); - ASF.StandardInput.Flush(); - output.AppendText(result + Environment.NewLine); - sb.Clear(); + _asf.tbInput.Lines = _asf.tbInput.Lines.ToList().Except(new List { key }).ToArray(); } - else if((!sb.ToString().StartsWith("[AES]") ^ sb.ToString().StartsWith("[ProtectedDataForCurrentUser]")) - && sb.ToString().EndsWith("password:")) + + else if (sb.ToString().Contains("DuplicatedKey") && Properties.Settings.Default.ClearDuplicated) { - var Password = new Password(ASF, sb.ToString()); - Password.ShowDialog(); - sb.Clear(); + _asf.tbInput.Lines = _asf.tbInput.Lines.ToList().Except(new List { key }).ToArray(); + } + + else if (sb.ToString().Contains("InvalidKey") && Properties.Settings.Default.ClearInvalid) + { + _asf.tbInput.Lines = _asf.tbInput.Lines.ToList().Except(new List { key }).ToArray(); + } + + else if (sb.ToString().Contains("AlreadyOwned") && Properties.Settings.Default.ClearOwned) + { + _asf.tbInput.Lines = _asf.tbInput.Lines.ToList().Except(new List { key }).ToArray(); + } + + else if (sb.ToString().Contains("OnCooldown") && Properties.Settings.Default.ClearCooldown) + { + _asf.tbInput.Lines = _asf.tbInput.Lines.ToList().Except(new List { key }).ToArray(); } } + + if (!sb.ToString().Contains("Init() Success!") || loaded) return; + _asf.GetBotList(); + loaded = true; } public void Start() @@ -108,5 +154,6 @@ public void Stop() outputThread.Abort(); ASF = null; } + } } diff --git a/ASFui/App.config b/ASFui/App.config index 02cbca9..71b108f 100644 --- a/ASFui/App.config +++ b/ASFui/App.config @@ -31,6 +31,21 @@ False + + True + + + True + + + False + + + False + + + False + diff --git a/ASFui/Properties/Settings.Designer.cs b/ASFui/Properties/Settings.Designer.cs index 4679889..bedcb0d 100644 --- a/ASFui/Properties/Settings.Designer.cs +++ b/ASFui/Properties/Settings.Designer.cs @@ -106,5 +106,65 @@ public bool Minimized { this["Minimized"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ClearOk { + get { + return ((bool)(this["ClearOk"])); + } + set { + this["ClearOk"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ClearDuplicated { + get { + return ((bool)(this["ClearDuplicated"])); + } + set { + this["ClearDuplicated"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ClearInvalid { + get { + return ((bool)(this["ClearInvalid"])); + } + set { + this["ClearInvalid"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ClearOwned { + get { + return ((bool)(this["ClearOwned"])); + } + set { + this["ClearOwned"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ClearCooldown { + get { + return ((bool)(this["ClearCooldown"])); + } + set { + this["ClearCooldown"] = value; + } + } } } diff --git a/ASFui/Properties/Settings.settings b/ASFui/Properties/Settings.settings index ecf67f0..0778589 100644 --- a/ASFui/Properties/Settings.settings +++ b/ASFui/Properties/Settings.settings @@ -23,5 +23,20 @@ False + + True + + + True + + + False + + + False + + + False + \ No newline at end of file diff --git a/ASFui/SettingsForm.Designer.cs b/ASFui/SettingsForm.Designer.cs index d98095a..19e2748 100644 --- a/ASFui/SettingsForm.Designer.cs +++ b/ASFui/SettingsForm.Designer.cs @@ -41,8 +41,15 @@ private void InitializeComponent() this.rbLocal = new System.Windows.Forms.RadioButton(); this.btnSave = new System.Windows.Forms.Button(); this.lbSaved = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.cbCooldown = new System.Windows.Forms.CheckBox(); + this.cbOwned = new System.Windows.Forms.CheckBox(); + this.cbInvalid = new System.Windows.Forms.CheckBox(); + this.cbDuplicated = new System.Windows.Forms.CheckBox(); + this.cbOK = new System.Windows.Forms.CheckBox(); this.gbBinaryPath.SuspendLayout(); this.gbLocalRemote.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // ofdBinarySearch @@ -127,7 +134,7 @@ private void InitializeComponent() // // btnSave // - this.btnSave.Location = new System.Drawing.Point(368, 120); + this.btnSave.Location = new System.Drawing.Point(368, 216); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 23); this.btnSave.TabIndex = 4; @@ -138,17 +145,86 @@ private void InitializeComponent() // lbSaved // this.lbSaved.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.lbSaved.Location = new System.Drawing.Point(262, 120); + this.lbSaved.Location = new System.Drawing.Point(262, 216); this.lbSaved.Name = "lbSaved"; this.lbSaved.Size = new System.Drawing.Size(100, 23); this.lbSaved.TabIndex = 5; this.lbSaved.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // + // groupBox1 + // + this.groupBox1.Controls.Add(this.cbCooldown); + this.groupBox1.Controls.Add(this.cbOwned); + this.groupBox1.Controls.Add(this.cbInvalid); + this.groupBox1.Controls.Add(this.cbDuplicated); + this.groupBox1.Controls.Add(this.cbOK); + this.groupBox1.Location = new System.Drawing.Point(12, 120); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(425, 90); + this.groupBox1.TabIndex = 6; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Clear Keys Input"; + // + // cbCooldown + // + this.cbCooldown.AutoSize = true; + this.cbCooldown.Location = new System.Drawing.Point(182, 44); + this.cbCooldown.Name = "cbCooldown"; + this.cbCooldown.Size = new System.Drawing.Size(89, 17); + this.cbCooldown.TabIndex = 4; + this.cbCooldown.Text = "On cooldown"; + this.cbCooldown.UseVisualStyleBackColor = true; + // + // cbOwned + // + this.cbOwned.AutoSize = true; + this.cbOwned.Location = new System.Drawing.Point(182, 20); + this.cbOwned.Name = "cbOwned"; + this.cbOwned.Size = new System.Drawing.Size(184, 17); + this.cbOwned.TabIndex = 3; + this.cbOwned.Text = "When the game is already owned"; + this.cbOwned.UseVisualStyleBackColor = true; + // + // cbInvalid + // + this.cbInvalid.AutoSize = true; + this.cbInvalid.Location = new System.Drawing.Point(6, 67); + this.cbInvalid.Name = "cbInvalid"; + this.cbInvalid.Size = new System.Drawing.Size(136, 17); + this.cbInvalid.TabIndex = 2; + this.cbInvalid.Text = "When the key is invalid"; + this.cbInvalid.UseVisualStyleBackColor = true; + // + // cbDuplicated + // + this.cbDuplicated.AutoSize = true; + this.cbDuplicated.Checked = true; + this.cbDuplicated.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbDuplicated.Location = new System.Drawing.Point(7, 44); + this.cbDuplicated.Name = "cbDuplicated"; + this.cbDuplicated.Size = new System.Drawing.Size(155, 17); + this.cbDuplicated.TabIndex = 1; + this.cbDuplicated.Text = "When the key is duplicated"; + this.cbDuplicated.UseVisualStyleBackColor = true; + // + // cbOK + // + this.cbOK.AutoSize = true; + this.cbOK.Checked = true; + this.cbOK.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbOK.Location = new System.Drawing.Point(7, 20); + this.cbOK.Name = "cbOK"; + this.cbOK.Size = new System.Drawing.Size(153, 17); + this.cbOK.TabIndex = 0; + this.cbOK.Text = "When the key is redeemed"; + this.cbOK.UseVisualStyleBackColor = true; + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(455, 155); + this.ClientSize = new System.Drawing.Size(455, 248); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.lbSaved); this.Controls.Add(this.btnSave); this.Controls.Add(this.gbLocalRemote); @@ -163,6 +239,8 @@ private void InitializeComponent() this.gbBinaryPath.PerformLayout(); this.gbLocalRemote.ResumeLayout(false); this.gbLocalRemote.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.ResumeLayout(false); } @@ -179,5 +257,11 @@ private void InitializeComponent() private Button btnSave; private TextBox tbRemoteURL; private Label lbSaved; + private GroupBox groupBox1; + private CheckBox cbCooldown; + private CheckBox cbOwned; + private CheckBox cbInvalid; + private CheckBox cbDuplicated; + private CheckBox cbOK; } } \ No newline at end of file diff --git a/ASFui/SettingsForm.cs b/ASFui/SettingsForm.cs index 3656745..d2589d0 100644 --- a/ASFui/SettingsForm.cs +++ b/ASFui/SettingsForm.cs @@ -14,6 +14,11 @@ public SettingsForm() rbRemote.Checked = !Properties.Settings.Default.IsLocal; tbRemoteURL.Enabled = rbRemote.Checked; tbRemoteURL.Text = Properties.Settings.Default.RemoteURL; + cbOK.Checked = Properties.Settings.Default.ClearOk; + cbDuplicated.Checked = Properties.Settings.Default.ClearDuplicated; + cbInvalid.Checked = Properties.Settings.Default.ClearInvalid; + cbOwned.Checked = Properties.Settings.Default.ClearOwned; + cbCooldown.Checked = Properties.Settings.Default.ClearCooldown; } private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) @@ -37,6 +42,12 @@ private void btnSave_Click(object sender, EventArgs e) { Properties.Settings.Default.IsLocal = rbLocal.Checked; Properties.Settings.Default.RemoteURL = tbRemoteURL.Text; + Properties.Settings.Default.ClearOk = cbOK.Checked; + Properties.Settings.Default.ClearDuplicated = cbDuplicated.Checked; + Properties.Settings.Default.ClearInvalid = cbInvalid.Checked; + Properties.Settings.Default.ClearOwned = cbOwned.Checked; + Properties.Settings.Default.ClearCooldown = cbCooldown.Checked; + if (rbRemote.Checked) { if (CheckUrl())