예제 #1
0
 /// <summary>
 /// Opens the selected result of a Dork in the user's browser.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void openInBrowserToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (resultListView.SelectedItems.Count > 0)
     {
         string ResultURLItem = resultListView.SelectedItems[0].SubItems[2].Text;
         OSUtils.OpenInBrowser(ResultURLItem);
     }
 }
예제 #2
0
 /// <summary>
 /// Build up a path to our dorkfile.
 /// </summary>
 /// <param name="fileName">Normally gdorks.xml.</param>
 /// <returns>Full-qualified file name to use for the dork data.</returns>
 private string getDataPathFile(string fileName)
 {
     return(OSUtils.getApplicationPath()
            + ".." + System.IO.Path.DirectorySeparatorChar.ToString()
            + ".." + System.IO.Path.DirectorySeparatorChar.ToString()
            + Properties.Settings.Default.DataPath
            + System.IO.Path.DirectorySeparatorChar.ToString()
            + fileName);
 }
예제 #3
0
        /// <summary>
        /// Open browser with the selected Dork in the TreeView.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenInBrowser_Click(object sender, EventArgs e)
        {
            string req = GetRequestFromSelected();

            if (req != null)
            {
                OSUtils.OpenInBrowser(req);
            }
        }
예제 #4
0
 /// <summary>
 /// Open browser and navigate to Google's Terms of Service.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void showGTOSButton_Click(object sender, EventArgs e)
 {
     OSUtils.OpenInBrowser(URI_Google_TOS);
 }
예제 #5
0
 /// <summary>
 /// Open browser and navigate to the license (GNU AGPL v3.0).
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void showLicenseButton_Click(object sender, EventArgs e)
 {
     OSUtils.OpenInBrowser(URI_agplv3);
 }
예제 #6
0
        /// <summary>
        /// This is one of the hearts of gS.
        /// Like it is named, it checks the results and with them controls
        /// the outer interface of the ScanMonitor. It's somehow a respectful
        /// connection between the UI and the parallel scanner in the backend.
        /// </summary>
        /// <param name="scanmonitor">Instance of ScanMonitor while scanning.</param>
        private void CheckAndDisplayResults(ScanMonitor scanmonitor)
        {
            if (scanmonitor.HasResults())
            {
                Scanner  scanner  = scanmonitor.GetFinishedScanner();
                DorkDone dorkdone = scanner.ResultDork;
                if (dorkdone == null)
                {
                    return;
                }

                if (dorkdone.ScanResult == (int)RESULT_STATUS.Cancel)
                {
                    Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceInfo, "Scan was canceled.");
                    dorkdone.ViewItem.ImageIndex       = (int)RESULT_STATUS.Cancel;
                    dorkdone.ViewItem.SubItems[0].Text = rm.GetString("RES_CANCELSCAN");
                    dorkdone.ViewItem.SubItems[2].Text = "";
                    return;
                }
                if (dorkdone.ScanResult == (int)RESULT_STATUS.Nothing)
                {
                    Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceInfo, "Scan returned no results.");
                    dorkdone.ViewItem.ImageIndex       = (int)RESULT_STATUS.Nothing;
                    dorkdone.ViewItem.SubItems[0].Text = rm.GetString("RES_NORESULT");
                    dorkdone.ViewItem.SubItems[2].Text = "";
                    summaryStat.ScansNoResult++;
                    return;
                }
                if (dorkdone.ScanResult == (int)RESULT_STATUS.Failure)
                {
                    dorkdone.ViewItem.ImageIndex       = (int)RESULT_STATUS.Failure;
                    dorkdone.ViewItem.SubItems[0].Text = rm.GetString("RES_FAILED");
                    dorkdone.ViewItem.SubItems[2].Text = "";
                    summaryStat.ScansFailed++;
                    Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceInfo, "Scan failed.");
                    return;
                }
                if (dorkdone.ScanResult == (int)RESULT_STATUS.Blocked)
                {
                    dorkdone.ViewItem.ImageIndex       = (int)RESULT_STATUS.Blocked;
                    dorkdone.ViewItem.SubItems[0].Text = rm.GetString("RES_BLOCKED");
                    dorkdone.ViewItem.SubItems[2].Text = dorkdone.ResultURL;
                    summaryStat.ScansFailed++;
                    Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceInfo, "Scan was blocked.");

                    if (Properties.Settings.Default.BlockDetectMode == (int)BLOCKING_MODE.SingleAndStop)
                    {
                        int stoppedscans = scanmonitor.StopAllActive();
                        Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceVerbose, stoppedscans, "Scans canceled in queue");

                        while (scanmonitor.HasPendingScans())
                        {
                            Thread.Sleep(200);
                        }
                    }

                    if (Properties.Settings.Default.BlockDetectMode != (int)BLOCKING_MODE.Ignore)
                    {
                        ShowScanningDialog(false);

                        DialogResult dr = MessageBox.Show("Start browser to unlock block? Cancel will stop scanning.", "Block detected!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);

                        if (dr == DialogResult.Yes)
                        {
                            OSUtils.OpenInBrowser(dorkdone.ResultURL);
                            MessageBox.Show("Ready to resume?", "Resume scanning.", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        }
                        else if (dr == DialogResult.Cancel)
                        {
                            int stoppedscans = scanmonitor.StopAllActive();
                            Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceVerbose, stoppedscans, "Scans canceled in queue");

                            while (scanmonitor.HasPendingScans())
                            {
                                Thread.Sleep(100);
                            }
                            StopScanning();
                        }

                        ShowScanningDialog(true);
                    }

                    return;
                }
                if (dorkdone.ScanResult == (int)RESULT_STATUS.ScanWithResult)
                {
                    resultListView.Items.Remove(dorkdone.ViewItem); // remove the one that is displayed while scanning

                    if (scanner.Count > 0)
                    {
                        int      lastIdx    = 0;
                        DorkDone resDork    = scanner.ResultDork;
                        DorkDone followDork = null;

                        if (resDork.NextPage != 0)
                        {
                            if ((resDork.NextPage / 10) < Properties.Settings.Default.RequestPages)
                            {
                                followDork            = new DorkDone();
                                followDork            = (DorkDone)resDork.Clone();
                                followDork.ScanResult = (int)RESULT_STATUS.WhileScan;
                                Scanner nextscanner = new Scanner(new ScanGoogleProvider(), followDork);

                                while (!scanmonitor.IsThreadAvail())
                                {
                                    Thread.Sleep(300);
                                }

                                scanmonitor.Add(nextscanner);
                                Thread.Sleep(100);
                            }
                        }

                        do
                        {
                            ListViewItem lv1 = resultListView.Items.Add(rm.GetString("RES_SUCCESS"),
                                                                        (int)RESULT_STATUS.ScanWithResult);

                            lv1.SubItems.Add(resDork.Title);
                            lv1.SubItems.Add(resDork.ResultURL);
                            lastIdx = lv1.Index;
                            lv1.Tag = resDork;

                            summaryStat.ScansSuccess++;
                            resDork = resDork.Next;

                            resultListView.EnsureVisible(lastIdx);
                        } while (resDork != null);
                    }
                }
            }
        }