Beispiel #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dork">Dork (like the one read from the XML).</param>
 public DorkDone(Dork dork)
 {
     this.Category = dork.Category;
     this.Comment  = dork.Comment;
     this.Name     = dork.Name;
     this.Query    = dork.Query;
     this.Title    = dork.Title;
 }
Beispiel #2
0
        /// <summary>
        /// Search a TreeNode.
        /// </summary>
        /// <param name="startNode">TreeNode to start the search.</param>
        /// <param name="searchTerm">String to search for.</param>
        /// <param name="inName">True to search in Dork's name.</param>
        /// <param name="inQuery">True to search in Dork's query.</param>
        /// <param name="inComment">True to search in Dork's comment.</param>
        /// <returns>TreeNode which fits which matches, null if noone was found.</returns>
        private TreeNode searchNodeEx(TreeNode startNode, string searchTerm,
                                      bool inName, bool inQuery, bool inComment)
        {
            TreeNode currentNode = startNode;

            if (currentNode == lastStartNode)
            {
                currentNode = GetNextDorkNode(startNode);
            }

            if (currentNode == rootnode)
            {
                currentNode = rootnode.Nodes[0];
            }

            lastStartNode = currentNode;

            while (true)
            {
                Dork dork = currentNode.Tag as Dork;
                if ((currentNode.Tag is Category) || (dork == null)) // it's a category
                {
                    currentNode = currentNode.Nodes[0];
                    dork        = currentNode.Tag as Dork;
                }
                if (inName)
                {
                    if (dork.Name.ToLower().Contains(searchTerm))
                    {
                        return(currentNode);
                    }
                }
                if (inQuery)
                {
                    if (dork.Query.ToLower().Contains(searchTerm))
                    {
                        return(currentNode);
                    }
                }
                if (inComment)
                {
                    if (dork.Comment.ToLower().Contains(searchTerm))
                    {
                        return(currentNode);
                    }
                }

                currentNode = GetNextDorkNode(currentNode);

                if (currentNode == lastStartNode)
                {
                    break;
                }
            }
            return(null);
        }
Beispiel #3
0
 /// <summary>
 /// Set dork to display.
 /// </summary>
 /// <param name="t">Dork to display</param>
 public void setDork(Dork t)
 {
     if (t != null)
     {
         this.Text              = t.Title;
         this.textBox1.Text     = t.Name;
         this.textBox2.Text     = t.Category;
         this.textBox3.Text     = t.Query;
         this.richTextBox1.Text = t.Comment;
     }
 }
Beispiel #4
0
        /// <summary>
        /// Show a complete dork record, well formated, in the Richtextbox.
        /// </summary>
        /// <param name="_dork">The dork to display.</param>
        private void formatDorkToRichText(Dork _dork)
        {
            FontStyle fs = richTextBox1.SelectionFont.Style;

            richTextBox1.Clear();
            richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold);
            richTextBox1.AppendText(_dork.Title + System.Environment.NewLine);
            richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Italic);
            richTextBox1.AppendText(_dork.Query + System.Environment.NewLine + System.Environment.NewLine);
            richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, fs);
            richTextBox1.AppendText(_dork.Comment);
        }
Beispiel #5
0
        /// <summary>
        /// Extracts the complete URL (which means ScanProvider plus query) of
        /// the selected Dork.
        /// </summary>
        /// <returns>URL of the selected Dork.</returns>
        private string GetRequestFromSelected()
        {
            TreeNode treenode = tvwDorks.SelectedNode;

            if (treenode != null)
            {
                Dork dork = treenode.Tag as Dork;
                if (dork != null)
                {
                    IScanProvider  scanProvider = new ScanGoogleProvider();
                    RequestBuilder req          = new RequestBuilder(scanProvider);

                    return(req.getRequest(dork.Query, scanHostTextBox.Text.Trim(), 0));
                }
            }
            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// MouseMove-event. This enables drag-and-drop if a dork is dragged somewhere,
        /// (to a browser eg).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvw_MouseMove(object sender, MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                TreeNode treenode = tvwDorks.SelectedNode;
                if (treenode != null)
                {
                    Dork dork = treenode.Tag as Dork;
                    if (dork != null)
                    {
                        IScanProvider  scanProvider = new ScanGoogleProvider();
                        RequestBuilder req          = new RequestBuilder(scanProvider);

                        string currentRequest = req.getRequest(dork.Query, "", 0);
                        tvwDorks.DoDragDrop(currentRequest, DragDropEffects.Copy);
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Click-event on 'Find'.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FindButton_Click(object sender, EventArgs e)
        {
            // store settings for next search attempt
            _searchTerm = Term.Text;
            _inName     = NameCheckBox.Checked;
            _inQuery    = QueryCheckBox.Checked;
            _inComment  = CommentCheckBox.Checked;

            TreeNode found = searchNodeEx(_startNode, Term.Text.ToLower(), _inName, _inQuery, _inComment);

            if (found != null)
            {
                Dork d = found.Tag as Dork;
                found.EnsureVisible();
                treeview.SelectedNode = found;
                _startNode            = found;
                lastStartNode         = found;
            }
            else
            {
                MessageBox.Show("No Dork could be found.", "Find Dork", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Open XML Dork file.
        /// </summary>
        /// <param name="filename">Name of the file to open (qfn).</param>
        /// <returns>Zero on success.</returns>
        public int Open(string filename)
        {
            if (File.Exists(filename))
            {
                xmldoc = new XmlDocument();

                try
                {
                    xmldoc.Load(filename);
                }
                catch (XmlException)
                {
                    throw;
                }
                catch (Exception)
                {
                    throw;
                }

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ConformanceLevel = ConformanceLevel.Auto;
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments   = true;

                XmlNodeReader nodereader = new XmlNodeReader(xmldoc);
                XmlReader     reader     = XmlReader.Create(nodereader, settings);
                Dork          myDork     = null;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == "CategoryItem")
                        {
                            reader.Read();
                            categorycollection.Add(reader.Value);
                        }

                        if (reader.Name == "Dork")
                        {
                            myDork = new Dork();
                            reader.Read();
                            myDork.Name = reader.Value;
                        }

                        if (reader.Name == "Title")
                        {
                            reader.Read();
                            myDork.Title = reader.Value;
                        }

                        if (reader.Name == "Category")
                        {
                            reader.Read();
                            myDork.Category = reader.Value;
                        }

                        if (reader.Name == "Query")
                        {
                            reader.Read();
                            myDork.Query = reader.Value;
                        }

                        if (reader.Name == "Comment")
                        {
                            reader.Read();
                            myDork.Comment = reader.Value;

                            if (String.IsNullOrEmpty(myDork.Title))
                            {
                                myDork.Title = myDork.Name;
                            }
                            dorkcollection.Add(myDork);
                            dorksCount++;
                        }
                    } //isElement
                }     // while
                return(0);
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
Beispiel #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dork">Dork</param>
 /// <param name="treenode">TreeNode</param>
 /// <param name="nextpage">NextPage</param>
 public SSelectedDork(Dork dork, TreeNode treenode, int nextpage)
 {
     this._dork     = dork;
     this._treenode = treenode;
     this._nextpage = nextpage;
 }
Beispiel #10
0
        /// <summary>
        /// Comperator.
        /// </summary>
        /// <param name="d">Probably another Dork</param>
        /// <returns>less than zero, zero, greater that zero</returns>
        public int CompareTo(Object d)
        {
            Dork dork = d as Dork;

            return(String.Compare(theName, dork?.Name, StringComparison.Ordinal));
        }