コード例 #1
0
 /// <summary>
 /// After the response is retrieved, add it to the tree
 /// </summary>
 /// <param name="oSession">Returned session</param>
 public void AutoTamperResponseAfter(Session oSession)
 {
     // If it's null, it will have been intercepted by the filters
     if (oSession.ViewItem != null)
     {
         CustomTreeView tv = FiddlerApplication.UI.pnlSessions.Controls[Constants.TreeViewName] as CustomTreeView;
         if (tv != null)
         {
             tv.Invoke(new Add(AddSession), new object[] { tv, oSession });
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Initialization after the extension loads
        /// </summary>
        public void OnLoad()
        {
            // Locate the original sessions listview
            lvSessions = FiddlerApplication.UI.pnlSessions.Controls[Constants.ListViewName] as SessionListView;
            FiddlerApplication.UI.pnlSessions.SizeChanged += new EventHandler(pnlSessions_SizeChanged);

            // Create our TreeView
            tv               = new CustomTreeView();
            tv.Name          = Constants.TreeViewName;
            tv.ImageList     = this.imageList;
            tv.Location      = lvSessions.Location;
            tv.Size          = lvSessions.Size;
            tv.HideSelection = false;                                   // If "false" the highlight is too "light", so we'll keep the selection "manually"
            tv.ContextMenu   = FiddlerApplication.UI.mnuSessionContext; // Assign same context menu
            //tv.BeforeSelect += new TreeViewCancelEventHandler(tv_BeforeSelect);
            //tv.LostFocus += new EventHandler(tv_LostFocus);
            tv.AfterSelect          += new TreeViewEventHandler(tv_AfterSelect);
            tv.AfterCollapse        += new TreeViewEventHandler(tv_AfterCollapse);
            tv.AfterExpand          += new TreeViewEventHandler(tv_AfterExpand);
            tv.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(tv_NodeMouseDoubleClick);
            //tv.KeyDown += new KeyEventHandler(tv_KeyDown);
            //tv.PreviewKeyDown += new PreviewKeyDownEventHandler(tv_PreviewKeyDown);
            FiddlerApplication.UI.pnlSessions.Controls.Add(tv);

            // Show or hide depending on the registry value
            this.ShowHidePanel();

            // TODO: Avoid hardcoded reference to the actual button
            // TODO: Research possible error executing the following (code after this would not execute)
            foreach (Control c in FiddlerApplication.UI.Controls)
            {
                if (c is ToolStrip)
                {
                    ToolStrip menuBar = c as ToolStrip;
                    foreach (ToolStripItem btn in menuBar.Items)
                    {
                        //if (btn.Text.Equals(Constants.RemoveButtonText, StringComparison.CurrentCultureIgnoreCase))
                        //if (btn.ToolTipText.Equals(Constants.RemoveButtonToolTipText, StringComparison.CurrentCultureIgnoreCase))
                        if (btn.ImageKey.Equals(Constants.RemoveButtonImageKey, StringComparison.CurrentCultureIgnoreCase))
                        {
                            ToolStripDropDownButton btnRemove = btn as ToolStripDropDownButton;
                            btnRemove.DropDownItemClicked += new ToolStripItemClickedEventHandler(btnRemove_DropDownItemClicked);
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initialization after the extension loads
        /// </summary>
        public void OnLoad()
        {
            // Locate the original sessions listview
            lvSessions = FiddlerApplication.UI.pnlSessions.Controls[Constants.ListViewName] as SessionListView;
            if (lvSessions == null)
            {
                MessageBox.Show("Unable to locate original sessions panel.", Constants.RegistryExtensionKeyName);
                return;
            }

            this.Initialize();

            lvSessions.Invalidated += LvSessions_Invalidated;
            FiddlerApplication.UI.pnlSessions.SizeChanged += new EventHandler(pnlSessions_SizeChanged);

            // Create our TreeView
            tv = new CustomTreeView
            {
                Name          = Constants.TreeViewName,
                ImageList     = this.imageList,
                Location      = lvSessions.Location,
                Size          = lvSessions.Size,
                HideSelection = false,                                  // If "false" the highlight is too "light", so we'll keep the selection "manually"
                ContextMenu   = FiddlerApplication.UI.mnuSessionContext // Assign same context menu
            };
            //tv.BeforeSelect += new TreeViewCancelEventHandler(tv_BeforeSelect);
            //tv.LostFocus += new EventHandler(tv_LostFocus);
            tv.AfterSelect          += new TreeViewEventHandler(tv_AfterSelect);
            tv.AfterCollapse        += new TreeViewEventHandler(tv_AfterCollapse);
            tv.AfterExpand          += new TreeViewEventHandler(tv_AfterExpand);
            tv.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(tv_NodeMouseDoubleClick);
            //tv.KeyDown += new KeyEventHandler(tv_KeyDown);
            //tv.PreviewKeyDown += new PreviewKeyDownEventHandler(tv_PreviewKeyDown);
            FiddlerApplication.UI.pnlSessions.Controls.Add(tv);

            // Show or hide depending on the registry value
            this.ShowHidePanel();
        }
コード例 #4
0
        /// <summary>
        /// Method that adds a session to a TreeView
        /// </summary>
        /// <param name="tv">CustomTreeView</param>
        /// <param name="oSession">Fiddler session</param>
        public void AddSession(CustomTreeView tv, Session oSession)
        {
            string hostName = oSession.hostname;

            if (oSession.isHTTPS)
            {
                hostName = "https://" + hostName;
                if (oSession.port != 443)
                {
                    hostName += ":" + oSession.port.ToString();
                }
            }
            else if (oSession.isFTP)
            {
                hostName = "ftp://" + hostName;
                if (oSession.port != 21)
                {
                    hostName += ":" + oSession.port.ToString();
                }
            }
            else
            {
                hostName = "http://" + hostName;
                if (oSession.port == 443)
                {
                    hostName = "https://" + oSession.hostname;
                }
                else if (oSession.port != 80)
                {
                    hostName += ":" + oSession.port.ToString();
                }
            }

            TreeNode result = null;

            // First locate the host
            foreach (TreeNode host in tv.Nodes)
            {
                if (host.Text == hostName)
                {
                    result = host;
                    break; // Exit foreach
                }
            }
            // Not found, create a new one so we nest following sessions to the same host below
            if (result == null)
            {
                result                  = tv.Nodes.Add(hostName);
                result.ImageKey         = Constants.ImageKeyHost;
                result.SelectedImageKey = Constants.ImageKeyHost;
            }

            string[] contents = oSession.PathAndQuery.Split(new char[] { '?' });
            string   justPath = "";

            if (contents.Length > 1)
            {
                justPath = contents[0];
            }
            else
            {
                justPath = oSession.PathAndQuery;
            }

            // Default node text to be displayed
            string nodeText = "/";

            if (!String.IsNullOrEmpty(contents[0]))
            {
                string[] folders = contents[0].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);;

                if (folders.Length > 1)
                {
                    // Go "down" in the hierarchy to locate the last subfolder where the session needs to be placed
                    for (int i = 0; i < folders.Length - 1; i++)
                    {
                        TreeNode found = null;
                        foreach (TreeNode child in result.Nodes)
                        {
                            if (child.Text == folders[i])
                            {
                                found = child;
                                break; // Exit foreach
                            }
                        }

                        if (found == null)
                        {
                            result                  = result.Nodes.Add(folders[i]);
                            result.ImageKey         = Constants.ImageKeyClosedFolder;
                            result.SelectedImageKey = Constants.ImageKeyClosedFolder;
                        }
                        else
                        {
                            result = found;
                        }
                    }
                }
                // The last one will be the actual page, image, script, etc...
                if (folders.Length > 0)
                {
                    nodeText = folders[folders.Length - 1];
                }
            }

            // Effectively create new node with the information so far
            TreeNode childNode = new TreeNode();

            childNode.Text = nodeText;
            if (contents.Length > 1)
            {
                childNode.Text += "?" + contents[1];
            }

            childNode.Tag         = oSession; // Store the Session here as well
            childNode.ToolTipText = oSession.fullUrl;

            string nodeImage = Constants.ImageKeyHttpCode200;

            switch (oSession.responseCode)
            {
            case 200:     // OK
                if (Constants.ImageExtensions.Any(ext => nodeText.ToLower().EndsWith(ext)))
                {
                    nodeImage = Constants.ImageKeyGenericImage;
                }
                break;

            case 301:     // Moved permanently
                nodeImage = Constants.ImageKeyHttpCode301;
                break;

            case 304:     // Unmodified
                if (Constants.ImageExtensions.Any(ext => nodeText.ToLower().EndsWith(ext)))
                {
                    nodeImage = Constants.ImageKeyGenericImageVisited;
                }
                else
                {
                    nodeImage = Constants.ImageKeyHttpCode304;
                }
                break;

            case 401:     // Unauthorized
                nodeImage = Constants.ImageKeyHttpCode401;
                break;

            case 404:     // Not found
                nodeImage = Constants.ImageKeyHttpCode404;
                break;

            default:
                break;
            }

            childNode.ImageKey         = nodeImage;
            childNode.SelectedImageKey = nodeImage;

            result.Nodes.Add(childNode);
        }