Exemplo n.º 1
0
        public MainWindow()
        {
            // Clean or create log file
            File.WriteAllText(Globals.logFile, "");

            InitializeComponent();

            Title = title;
            titleLabel.Content = title;

            // Set global reference to this window
            Globals.mainWindow = this;

            // Make sure all folders are there or recreate them
            var folders = new string[] { "Captchas", "ChromeExtensions", "Configs", "DB", "Screenshots", "Settings", "Sounds", "Wordlists" };

            foreach (var folder in folders.Select(f => System.IO.Path.Combine(Directory.GetCurrentDirectory(), f)))
            {
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
            }

            // Initialize Environment Settings
            try
            {
                Globals.environment = IOManager.ParseEnvironmentSettings(Globals.envFile);
            }
            catch
            {
                MessageBox.Show("Could not find / parse the Environment Settings file. Please fix the issue and try again.");
                Environment.Exit(0);
            }

            if (Globals.environment.WordlistTypes.Count == 0 || Globals.environment.CustomKeychains.Count == 0)
            {
                MessageBox.Show("At least one WordlistType and one CustomKeychain must be defined in the Environment Settings file.");
                Environment.Exit(0);
            }

            // Initialize Settings
            Globals.rlSettings = new RLSettingsViewModel();
            Globals.obSettings = new OBSettingsViewModel();

            // Create / Load Settings
            if (!File.Exists(Globals.rlSettingsFile))
            {
                MessageBox.Show("RuriLib Settings file not found, generating a default one");
                Globals.LogWarning(Components.Main, "RuriLib Settings file not found, generating a default one");
                IOManager.SaveSettings(Globals.rlSettingsFile, Globals.rlSettings);
                Globals.LogInfo(Components.Main, $"Created the default RuriLib Settings file {Globals.rlSettingsFile}");
            }
            else
            {
                Globals.rlSettings = IOManager.LoadSettings(Globals.rlSettingsFile);
                Globals.LogInfo(Components.Main, "Loaded the existing RuriLib Settings file");
            }

            if (!File.Exists(Globals.obSettingsFile))
            {
                MessageBox.Show("OpenBullet Settings file not found, generating a default one");
                Globals.LogWarning(Components.Main, "OpenBullet Settings file not found, generating a default one");
                OBIOManager.SaveSettings(Globals.obSettingsFile, Globals.obSettings);
                Globals.LogInfo(Components.Main, $"Created the default OpenBullet Settings file {Globals.obSettingsFile}");
            }
            else
            {
                Globals.obSettings = OBIOManager.LoadSettings(Globals.obSettingsFile);
                Globals.LogInfo(Components.Main, "Loaded the existing OpenBullet Settings file");
            }

            Topmost = Globals.obSettings.General.AlwaysOnTop;

            RunnerManagerPage = new RunnerManager(Globals.obSettings.General.AutoCreateRunner);
            if (Globals.obSettings.General.AutoCreateRunner)
            {
                CurrentRunnerPage = RunnerManagerPage.vm.Runners.FirstOrDefault().Page;
            }
            Globals.LogInfo(Components.Main, "Initialized RunnerManager");
            ProxyManagerPage = new ProxyManager();
            Globals.LogInfo(Components.Main, "Initialized ProxyManager");
            WordlistManagerPage = new WordlistManager();
            Globals.LogInfo(Components.Main, "Initialized WordlistManager");
            ConfigsPage = new Configs();
            Globals.LogInfo(Components.Main, "Initialized ConfigManager");
            HitsDBPage = new HitsDB();
            Globals.LogInfo(Components.Main, "Initialized HitsDB");
            OBSettingsPage = new Settings();
            Globals.LogInfo(Components.Main, "Initialized Settings");
            ToolsPage = new Tools();
            Globals.LogInfo(Components.Main, "Initialized Tools");
            AboutPage = new About();

            menuOptionRunner_MouseDown(this, null);

            var width  = Globals.obSettings.General.StartingWidth;
            var height = Globals.obSettings.General.StartingHeight;

            if (width > 800)
            {
                Width = width;
            }
            if (height > 600)
            {
                Height = height;
            }

            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            if (Globals.obSettings.Themes.EnableSnow)
            {
                Loaded += MainWindow_Loaded;
            }
        }
Exemplo n.º 2
0
        private void debuggerCheck(object sender, DoWorkEventArgs e)
        {
            // Dispose of previous browser (if any)
            if (vm.BotData != null)
            {
                if (vm.BotData.BrowserOpen)
                {
                    Globals.LogInfo(Components.Stacker, "Quitting the previously opened browser");
                    vm.BotData.Driver.Quit();
                    Globals.LogInfo(Components.Stacker, "Quitted correctly");
                }
            }

            // Convert Observables
            Globals.LogInfo(Components.Stacker, "Converting Observables");
            vm.ConvertKeychains();

            // Initialize Request Data
            Globals.LogInfo(Components.Stacker, "Initializing the request data");
            CProxy proxy = null;

            if (vm.TestProxy.StartsWith("(")) // Parse in advanced mode
            {
                try { proxy = (new CProxy()).Parse(vm.TestProxy); }
                catch { Globals.LogError(Components.Stacker, "Invalid Proxy Syntax", true); }
            }
            else // Parse in standard mode
            {
                proxy = new CProxy(vm.TestProxy, vm.ProxyType);
            }

            // Initialize BotData and Reset LS
            var cData = new CData(vm.TestData, Globals.environment.GetWordlistType(vm.TestDataType));

            vm.BotData = new BotData(Globals.rlSettings, vm.Config.Config.Settings, cData, proxy, vm.UseProxy);
            vm.LS.Reset();

            // Ask for user input
            foreach (var input in vm.BotData.ConfigSettings.CustomInputs)
            {
                Globals.LogInfo(Components.Stacker, $"Asking for user input: {input.Description}");
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    (new MainDialog(new DialogCustomInput(this, input.VariableName, input.Description), "Custom Input")).ShowDialog();
                }));
            }

            // Set start block
            Globals.LogInfo(Components.Stacker, "Setting the first block as the current block");

            // Print start line
            var proxyEnabledText = vm.UseProxy ? "ENABLED" : "DISABLED";

            vm.BotData.LogBuffer.Add(new LogEntry($"===== DEBUGGER STARTED FOR CONFIG {vm.Config.Name} WITH DATA {vm.TestData} AND PROXY {vm.TestProxy} ({vm.ProxyType}) {proxyEnabledText} ====={Environment.NewLine}", Colors.White));

            timer = new Stopwatch();
            timer.Start();

            // Open browser if Always Open
            if (vm.Config.Config.Settings.AlwaysOpen)
            {
                Globals.LogInfo(Components.Stacker, "Opening the Browser");
                SBlockBrowserAction.OpenBrowser(vm.BotData);
            }

            // Step-by-step
            if (vm.SBS)
            {
                vm.SBSClear = true; // Good to go for the first round
                do
                {
                    Thread.Sleep(100);

                    if (debugger.CancellationPending)
                    {
                        Globals.LogInfo(Components.Stacker, "Found cancellation pending, aborting debugger");
                        return;
                    }

                    if (vm.SBSClear)
                    {
                        vm.SBSEnabled = false;
                        Process();
                        Globals.LogInfo(Components.Stacker, $"Block processed in SBS mode, can proceed: {vm.LS.CanProceed}");
                        vm.SBSEnabled = true;
                        vm.SBSClear   = false;
                    }
                }while (vm.LS.CanProceed);
            }

            // Normal
            else
            {
                do
                {
                    if (debugger.CancellationPending)
                    {
                        Globals.LogInfo(Components.Stacker, "Found cancellation pending, aborting debugger");
                        return;
                    }

                    Process();
                }while (vm.LS.CanProceed);
            }

            // Quit Browser if Always Quit
            if (vm.Config.Config.Settings.AlwaysQuit)
            {
                try {
                    vm.BotData.Driver.Quit();
                    vm.BotData.BrowserOpen = false;
                    Globals.LogInfo(Components.Stacker, "Successfully quit the browser");
                }
                catch (Exception ex) { Globals.LogError(Components.Stacker, $"Cannot quit the browser - {ex.Message}"); }
            }
        }
Exemplo n.º 3
0
        public Stacker(ConfigViewModel config)
        {
            InitializeComponent();
            vm          = new StackerViewModel(config);
            DataContext = vm;

            // Style the LoliScript editor
            loliScriptEditor.ShowLineNumbers     = true;
            loliScriptEditor.TextArea.Foreground = new SolidColorBrush(Colors.Gainsboro);
            loliScriptEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue);
            using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd"))
            {
                loliScriptEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
            }

            // Load the Syntax Helper XML
            XmlDocument doc = new XmlDocument();

            try {
                doc.Load("SyntaxHelper.xml");
                var main = doc.DocumentElement.SelectSingleNode("/doc");
                syntaxHelperItems = main.ChildNodes;

                // Only bind the keydown event if the XML was successfully loaded
                loliScriptEditor.KeyDown += loliScriptEditor_KeyDown;
            }
            catch { }

            // Make the Avalon Editor for Syntax Helper and style it
            toolTipEditor = new TextEditor();
            toolTipEditor.TextArea.Foreground = Globals.GetBrush("ForegroundMain");
            toolTipEditor.Background          = new SolidColorBrush(Color.FromArgb(22, 22, 22, 50));
            toolTipEditor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue);
            toolTipEditor.FontSize = 11;
            toolTipEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            toolTipEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd"))
            {
                toolTipEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
            }

            toolTip = new ToolTip {
                Placement = PlacementMode.Relative, PlacementTarget = loliScriptEditor
            };
            toolTip.Content          = toolTipEditor;
            loliScriptEditor.ToolTip = toolTip;

            // Load the script
            vm.LS = new LoliScript(config.Config.Script);
            loliScriptEditor.Text = vm.LS.Script;

            // If the user prefers Stack view, switch to it
            if (!Globals.obSettings.General.DisplayLoliScriptOnLoad)
            {
                stackButton_Click(this, null);
            }

            // Style the logRTB
            logRTB.Font      = new System.Drawing.Font("Consolas", 10);
            logRTB.BackColor = System.Drawing.Color.FromArgb(22, 22, 22);

            // Hook the context menu to the logRTB
            System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();
            System.Windows.Forms.MenuItem    item = new System.Windows.Forms.MenuItem();
            item.Text   = "Clear";
            item.Click += ClearDebuggerLog;
            menu.MenuItems.Add(item);
            logRTB.ContextMenu = menu;
            logRTB.MouseClick += DebuggerLogRightClick;

            foreach (string i in Enum.GetNames(typeof(ProxyType)))
            {
                if (i != "Chain")
                {
                    proxyTypeCombobox.Items.Add(i);
                }
            }

            proxyTypeCombobox.SelectedIndex = 0;

            foreach (var t in Globals.environment.GetWordlistTypeNames())
            {
                testDataTypeCombobox.Items.Add(t);
            }

            testDataTypeCombobox.SelectedIndex = 0;

            // Initialize debugger
            debugger.WorkerSupportsCancellation = true;
            debugger.Status              = WorkerStatus.Idle;
            debugger.DoWork             += new DoWorkEventHandler(debuggerCheck);
            debugger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(debuggerCompleted);

            this.SaveConfig += Globals.mainWindow.ConfigsPage.ConfigManagerPage.OnSaveConfig;
        }
Exemplo n.º 4
0
 public void AddBlock(BlockBase block)
 {
     Globals.LogInfo(Components.Stacker, $"Added a block of type {block.GetType()} in position {vm.Stack.Count}");
     vm.AddBlock(block, -1);
 }