From 5f873a98c12660f7220355886cde745f86f6dcc2 Mon Sep 17 00:00:00 2001 From: ruri Date: Sun, 1 Mar 2020 14:54:59 +0100 Subject: [PATCH 01/62] Added Shuffle List to Utility block --- RuriLib/Blocks/BlockUtility.cs | 15 ++++++++++++++- RuriLib/Extensions.cs | 32 ++++++++++++++++++++++++++++++++ RuriLib/RuriLib.csproj | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 RuriLib/Extensions.cs diff --git a/RuriLib/Blocks/BlockUtility.cs b/RuriLib/Blocks/BlockUtility.cs index 1084012..58905c2 100644 --- a/RuriLib/Blocks/BlockUtility.cs +++ b/RuriLib/Blocks/BlockUtility.cs @@ -75,7 +75,10 @@ namespace RuriLib RemoveDuplicates, /// Picks a random element from a list variable. - Random + Random, + + /// Randomizes the order of elements in a list. + Shuffle } /// @@ -488,6 +491,16 @@ namespace RuriLib } break; + case ListAction.Shuffle: + lock (data.RandomLocker) + { + // This makes a copy of the original list + var listCopy = list.ToArray().ToList(); + listCopy.Shuffle(data.Random); + data.Variables.Set(new CVar(variableName, listCopy, isCapture)); + } + break; + default: break; } diff --git a/RuriLib/Extensions.cs b/RuriLib/Extensions.cs new file mode 100644 index 0000000..6987162 --- /dev/null +++ b/RuriLib/Extensions.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RuriLib +{ + /// + /// Extension methods for lists. + /// + public static class ListExtensions + { + /// + /// Randomizes the elements in a list. + /// + /// The list to shuffle + /// The random number generator + public static void Shuffle(this IList list, Random rng) + { + int n = list.Count; + while (n > 1) + { + n--; + int k = rng.Next(n + 1); + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + } + } +} diff --git a/RuriLib/RuriLib.csproj b/RuriLib/RuriLib.csproj index b861392..91f0592 100644 --- a/RuriLib/RuriLib.csproj +++ b/RuriLib/RuriLib.csproj @@ -247,6 +247,7 @@ + From 7ee49bb20d9e926d9c94eeadddc316142d3daf63 Mon Sep 17 00:00:00 2001 From: ruri Date: Sun, 1 Mar 2020 15:45:33 +0100 Subject: [PATCH 02/62] Added zero padding to RandomNum function --- .../Views/StackerBlocks/PageBlockFunction.xaml | 1 + RuriLib/Blocks/BlockFunction.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenBullet/Views/StackerBlocks/PageBlockFunction.xaml b/OpenBullet/Views/StackerBlocks/PageBlockFunction.xaml index 515c65b..e6518d9 100644 --- a/OpenBullet/Views/StackerBlocks/PageBlockFunction.xaml +++ b/OpenBullet/Views/StackerBlocks/PageBlockFunction.xaml @@ -121,6 +121,7 @@ public void ForceStop() { + if (Settings.General.SendToCheckOnAbort) + { + foreach (var bot in Bots.Where(b => b.Worker.IsBusy)) + { + ValidData validData = new ValidData(bot.Data, bot.Proxy, ProxyType.Http, BotStatus.NONE, "TOCHK", "", "", new List()); + HitsList.Add(validData); + var hit = new Hit(bot.Data, new VariableList(), bot.Proxy, "TOCHK", ConfigName, WordlistName); + RaiseFoundHit(hit); + } + } + AbortAllBots(); Master.Abort(); RaiseMessageArrived(LogLevel.Info, "Hard Aborted the Master Worker", false); diff --git a/RuriLib/ViewModels/RLSettings/SettingsGeneral.cs b/RuriLib/ViewModels/RLSettings/SettingsGeneral.cs index 0e355b7..ffa7265 100644 --- a/RuriLib/ViewModels/RLSettings/SettingsGeneral.cs +++ b/RuriLib/ViewModels/RLSettings/SettingsGeneral.cs @@ -47,6 +47,10 @@ namespace RuriLib.ViewModels /// Whether to store the last Response Source after a successful check. public bool SaveLastSource { get { return saveLastSource; } set { saveLastSource = value; OnPropertyChanged(); } } + private bool sendToCheckOnAbort = false; + /// Whether to save as ToCheck all the data lines that were being processed when the master worker was aborted. + public bool SendToCheckOnAbort { get { return sendToCheckOnAbort; } set { sendToCheckOnAbort = value; OnPropertyChanged(); } } + private bool webhookEnabled = false; /// Whether to activate the hit webhook that gets called upon a SUCCESS or a custom result. public bool WebhookEnabled { get { return webhookEnabled; } set { webhookEnabled = value; OnPropertyChanged(); } } From 5a93fd838c16e457ad402ec3aa15756b4a278184 Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Mar 2020 00:46:25 +0100 Subject: [PATCH 10/62] Fixed LoliScript documentation for RandomNum --- OpenBullet/LSDoc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenBullet/LSDoc.xml b/OpenBullet/LSDoc.xml index 149ebd2..9f6a074 100644 --- a/OpenBullet/LSDoc.xml +++ b/OpenBullet/LSDoc.xml @@ -239,7 +239,7 @@ FUNCTION Translate StopAfterFirstMatch=True FUNCTION DateToUnixTime "format" "input" -> VAR "DATE" FUNCTION Replace "what" "with" UseRegex=True "input" -> VAR "REPLACED" FUNCTION RegexMatch "pattern" "input" -> VAR "MATCHED" -FUNCTION RandomNum 0 100 -> VAR "RANDOM" +FUNCTION RandomNum "0" "100" -> VAR "RANDOM" FUNCTION CountOccurrences "tofind" "input" -> VAR "COUNT" FUNCTION CharAt "index" "input" -> VAR "CHAR" FUNCTION Substring "startindex" "length" "input" -> VAR "SUBSTRING" From 17cc432d865501f41ede269fec0c0c6bbcf679c2 Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Mar 2020 01:40:46 +0100 Subject: [PATCH 11/62] Moved functionality from ForceStop to RunCompleted --- RuriLib/Runner/RunnerViewModel.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/RuriLib/Runner/RunnerViewModel.cs b/RuriLib/Runner/RunnerViewModel.cs index d86c5c1..6743a46 100644 --- a/RuriLib/Runner/RunnerViewModel.cs +++ b/RuriLib/Runner/RunnerViewModel.cs @@ -407,17 +407,6 @@ namespace RuriLib.Runner /// public void ForceStop() { - if (Settings.General.SendToCheckOnAbort) - { - foreach (var bot in Bots.Where(b => b.Worker.IsBusy)) - { - ValidData validData = new ValidData(bot.Data, bot.Proxy, ProxyType.Http, BotStatus.NONE, "TOCHK", "", "", new List()); - HitsList.Add(validData); - var hit = new Hit(bot.Data, new VariableList(), bot.Proxy, "TOCHK", ConfigName, WordlistName); - RaiseFoundHit(hit); - } - } - AbortAllBots(); Master.Abort(); RaiseMessageArrived(LogLevel.Info, "Hard Aborted the Master Worker", false); @@ -646,6 +635,17 @@ namespace RuriLib.Runner // Executed when the Master Worker has finished its job private void RunCompleted(object sender, RunWorkerCompletedEventArgs e) { + if (Settings.General.SendToCheckOnAbort) + { + foreach (var bot in Bots.Where(b => b.Worker.IsBusy)) + { + ValidData validData = new ValidData(bot.Data, bot.Proxy, ProxyType.Http, BotStatus.NONE, "TOCHK", "", "", new List()); + HitsList.Add(validData); + var hit = new Hit(bot.Data, new VariableList(), bot.Proxy, "TOCHK", ConfigName, WordlistName); + RaiseFoundHit(hit); + } + } + if (e.Error != null) RaiseMessageArrived(LogLevel.Error, "The Master Worker has encountered an error: " + e.Error.Message, true); Master.Status = WorkerStatus.Idle; OnPropertyChanged("Busy"); From e0e303965387859d9462c5ef4a0e282ea9179194 Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Mar 2020 01:43:51 +0100 Subject: [PATCH 12/62] Fixed ToCheck going to Hit --- RuriLib/Runner/RunnerViewModel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RuriLib/Runner/RunnerViewModel.cs b/RuriLib/Runner/RunnerViewModel.cs index 6743a46..dbfba53 100644 --- a/RuriLib/Runner/RunnerViewModel.cs +++ b/RuriLib/Runner/RunnerViewModel.cs @@ -639,9 +639,9 @@ namespace RuriLib.Runner { foreach (var bot in Bots.Where(b => b.Worker.IsBusy)) { - ValidData validData = new ValidData(bot.Data, bot.Proxy, ProxyType.Http, BotStatus.NONE, "TOCHK", "", "", new List()); - HitsList.Add(validData); - var hit = new Hit(bot.Data, new VariableList(), bot.Proxy, "TOCHK", ConfigName, WordlistName); + ValidData validData = new ValidData(bot.Data, bot.Proxy, ProxyType.Http, BotStatus.NONE, "NONE", "", "", new List()); + ToCheckList.Add(validData); + var hit = new Hit(bot.Data, new VariableList(), bot.Proxy, "NONE", ConfigName, WordlistName); RaiseFoundHit(hit); } } From b3b1b2351be2fece8cf4faae117d9de4976354e8 Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Mar 2020 01:51:52 +0100 Subject: [PATCH 13/62] Added support for negative index to list variables --- RuriLib/Models/CVar.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RuriLib/Models/CVar.cs b/RuriLib/Models/CVar.cs index 10794ca..ce9c084 100644 --- a/RuriLib/Models/CVar.cs +++ b/RuriLib/Models/CVar.cs @@ -141,6 +141,14 @@ namespace RuriLib.Models { if (Type != VarType.List) return null; var list = Value as List; + + // If the index is negative, start from the end + if (index < 0) + { + // For example in a [1,2,3] list, the element at -1 is at index 3-1 = 2 which is element '3' + index = list.Count - index; + } + if (index > list.Count - 1 || index < 0) return null; return list[index]; } From ce5ff7670be6dcb6a3855c0155f49c7a220b405a Mon Sep 17 00:00:00 2001 From: ruri Date: Mon, 2 Mar 2020 16:59:02 +0100 Subject: [PATCH 14/62] Added option to not save empty captures --- .../Views/Main/Configs/OtherOptions/General.xaml | 1 + RuriLib/Blocks/BlockBase.cs | 12 ++++++++++-- RuriLib/Models/ConfigSettings.cs | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/OpenBullet/Views/Main/Configs/OtherOptions/General.xaml b/OpenBullet/Views/Main/Configs/OtherOptions/General.xaml index 980b33d..691cad4 100644 --- a/OpenBullet/Views/Main/Configs/OtherOptions/General.xaml +++ b/OpenBullet/Views/Main/Configs/OtherOptions/General.xaml @@ -25,6 +25,7 @@