Exemplo n.º 1
0
        private void dataGridView_SelectionChanged(object sender, EventArgs e)
        {
            richTextBox.Clear();
            if (dataGridView.SelectedRows.Count < 1)
            {
                return;
            }

            DataGridViewRow row = dataGridView.SelectedRows[0];

            if (row.Cells.Count <= 1)
            {
                return;
            }

            Event ev = dataGridView.SelectedRows[0].Cells[4].Value as Event;

            string         prettyXml;
            XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.DarkBlueScheme);

            XmlUtils.PrettyPrint(ev.RawData, out prettyXml, highlighter);

            richTextBox.Text = prettyXml;
            highlighter.HighlightRichTextBox(richTextBox);
        }
Exemplo n.º 2
0
Arquivo: HTTP.cs Projeto: wyrover/ospy
        private HTTPMessage ParseNode(TransactionNode httpNode, bool isRequest)
        {
            IPPacket pkt = httpNode.Slices[0].Packet;

            HTTPMessage msg = new HTTPMessage(httpNode.Index, pkt.Direction, pkt.Timestamp);

            if (isRequest)
            {
                msg.HeadlineText = String.Format("{0} {1} {2}", httpNode["Verb"], httpNode["Argument"], httpNode["Protocol"]);
            }
            else
            {
                msg.HeadlineText = String.Format("{0} {1}", httpNode["Protocol"], httpNode["Result"]);
            }

            TransactionNode headersNode = httpNode.FindChild("Headers", false);

            if (headersNode != null)
            {
                foreach (string name in headersNode.FieldNames)
                {
                    msg.AddHeaderField(name, headersNode.Fields[name]);
                }
            }

            TransactionNode bodyNode = httpNode.FindChild("Body", false);

            if (bodyNode != null)
            {
                if (bodyNode.Fields.ContainsKey("XML"))
                {
                    string         body;
                    XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.VisualizationScheme);

                    XmlUtils.PrettyPrint((string)bodyNode["XML"], out body, highlighter);

                    msg.BodyText = body;

                    highlighter.HighlightRichTextBox(msg.BodyBox);
                }
                else if (bodyNode.Fields.ContainsKey("HTML"))
                {
                    msg.BodyText = (string)bodyNode["HTML"];
                }
                else if (bodyNode.Fields.ContainsKey("Raw"))
                {
                    msg.SetBodyFromPreviewData((byte[])bodyNode.Fields["Raw"], 512);
                }
                else
                {
                    msg.BodyText = String.Format("{0} unhandled", bodyNode.FieldNames[0]);
                }
            }

            return(msg);
        }
Exemplo n.º 3
0
        public void DisplayXML(string xmlData)
        {
            string         prettyXml;
            XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.DarkBlueScheme);

            XmlUtils.PrettyPrint(xmlData, out prettyXml, highlighter);

            richTextBox.Text = prettyXml;
            highlighter.HighlightRichTextBox(richTextBox);
        }
Exemplo n.º 4
0
        public override VisualTransaction[] GetTransactions(IPSession session)
        {
            List <VisualTransaction> messages = new List <VisualTransaction>();

            char[] bodyTrimChars = new char[] { '\r', '\n' };

            foreach (TransactionNode node in session.Nodes)
            {
                if (node.Name == "MSNSBCommand")
                {
                    IPPacket pkt = node.Slices[0].Packet;

                    VisualTransaction vt = new VisualTransaction(node.Index, pkt.Direction, pkt.Timestamp);

                    string headline = (string)node["Command"];

                    if (node.Fields.ContainsKey("Arguments"))
                    {
                        headline += " " + (string)node["Arguments"];
                    }

                    vt.HeadlineText = headline;

                    XmlHighlighter highlighter = null;

                    TransactionNode payloadNode = node.FindChild("Payload", false);
                    if (payloadNode != null)
                    {
                        string body = "";

                        if (payloadNode.Fields.ContainsKey("XML"))
                        {
                            highlighter = new XmlHighlighter(XmlHighlightColorScheme.VisualizationScheme);
                            XmlUtils.PrettyPrint((string)payloadNode["XML"], out body, highlighter);
                        }
                        else if (payloadNode.Fields.ContainsKey("Text"))
                        {
                            body = (string)payloadNode["Text"];
                        }
                        else if (payloadNode.Fields.ContainsKey("MSNSLP"))
                        {
                            body = (string)payloadNode["MSNSLP"];
                        }
                        else if (payloadNode.FindChild("Headers") != null)
                        {
                            TransactionNode headersNode = payloadNode.FindChild("Headers");

                            vt.HeaderRowsPerCol = Int32.MaxValue;

                            foreach (string name in headersNode.Fields.Keys)
                            {
                                vt.AddHeaderField(name, headersNode.Fields[name].ToString());
                            }

                            TransactionNode bodyNode = payloadNode.FindChild("Body");
                            if (bodyNode != null)
                            {
                                body = bodyNode.Fields[bodyNode.FieldNames[0]].ToString();

                                body = body.TrimEnd(bodyTrimChars);
                            }
                        }
                        else
                        {
                            body = String.Format("Unhandled payload format: {0}",
                                                 (payloadNode.FieldNames.Count > 0) ? payloadNode.FieldNames[0] : payloadNode.Children[0].Name);
                        }

                        vt.BodyText = body;

                        if (highlighter != null)
                        {
                            highlighter.HighlightRichTextBox(vt.BodyBox);
                        }
                    }

                    messages.Add(vt);
                }
            }

            return(messages.ToArray());
        }