예제 #1
0
        private async Task CloneConfig()
        {
            if (selectedConfig == null)
            {
                await ShowNoConfigSelectedMessage();

                return;
            }

            // Pack and unpack to clone
            var packed = await ConfigPacker.Pack(selectedConfig);

            using var ms = new MemoryStream(packed);
            var newConfig = await ConfigPacker.Unpack(ms);

            // Change the id and save it again
            newConfig.Id = Guid.NewGuid().ToString();
            await ConfigRepo.Save(newConfig);

            // Set it as currently selected config
            configs.Insert(0, newConfig);
            selectedConfig = newConfig;
            ConfigService.Configs.Add(selectedConfig);
            ConfigService.SelectedConfig = selectedConfig;

            VolatileSettings.DebuggerLog = new();
            Nav.NavigateTo("config/edit/metadata");
        }
예제 #2
0
        private static void Run(Options opts)
        {
            options = opts;

            var rlSettings = new RuriLibSettingsService("UserData");
            var pluginRepo = new PluginRepository("UserData/Plugins");

            // Unpack the config
            using var fs = new FileStream(opts.ConfigFile, FileMode.Open);
            var config = ConfigPacker.Unpack(fs).Result;

            // Setup the job
            job = new MultiRunJob(rlSettings, pluginRepo)
            {
                Providers  = new RuriLib.Models.Bots.Providers(rlSettings),
                Bots       = opts.BotsNumber,
                Config     = config,
                DataPool   = new FileDataPool(opts.WordlistFile, opts.WordlistType),
                HitOutputs = new List <IHitOutput> {
                    new FileSystemHitOutput("UserData/Hits")
                },
                ProxyMode    = opts.ProxyMode,
                ProxySources = new List <ProxySource> {
                    new FileProxySource(opts.ProxyFile)
                    {
                        DefaultType = opts.ProxyType
                    }
                }
            };

            // Ask custom inputs (if any)
            foreach (var input in config.Settings.InputSettings.CustomInputs)
            {
                System.Console.WriteLine($"{input.Description} ({input.DefaultAnswer}): ");
                var answer = System.Console.ReadLine();
                job.CustomInputsAnswers[input.VariableName] = string.IsNullOrWhiteSpace(answer)
                    ? input.DefaultAnswer
                    : answer;
            }

            // Hook event handlers
            job.OnCompleted += (sender, args) => completed = true;
            job.OnResult    += PrintResult;
            job.OnTaskError += PrintTaskError;
            job.OnError     += (sender, ex) => System.Console.WriteLine($"Error: {ex.Message}", Color.Tomato);

            // Start the job
            job.Start().Wait();

            // Wait until it finished
            while (!completed)
            {
                Thread.Sleep(100);
                UpdateTitle();
            }

            // Print colored finish message
            System.Console.Write($"Finished. Found: ");
            System.Console.Write($"{job.DataHits} hits, ", Color.GreenYellow);
            System.Console.Write($"{job.DataCustom} custom, ", Color.DarkOrange);
            System.Console.WriteLine($"{job.DataToCheck} to check.", Color.Aquamarine);

            // Prevent console from closing until the user presses return, then close
            System.Console.ReadLine();
            Environment.Exit(0);
        }