예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public void ProcessEntries()
        {
            if (cDataBatch != null && cDataBatch.Count > 0)
            {
                List <HTTPRequests> lNewRecords = new List <HTTPRequests>();
                List <String>       lNewData;
                Match    lMatchURI;
                Match    lMatchHost;
                Match    lMatchCookies;
                String   lMethod     = String.Empty;
                String   lRemoteHost = String.Empty;
                String   lReqString  = String.Empty;
                String   lCookies    = String.Empty;
                String[] lSplit;
                String   lProto;
                String   lMAC;
                String   lSrcIP;
                String   lSrcPort;
                String   lDstIP;
                String   lDstPort;
                String   lData;

                lock (this)
                {
                    lNewData = new List <String>(cDataBatch);
                    cDataBatch.Clear();
                } // lock (this)...


                foreach (String lEntry in lNewData)
                {
                    try
                    {
                        if (!String.IsNullOrEmpty(lEntry))
                        {
                            if ((lSplit = Regex.Split(lEntry, @"\|\|")).Length >= 7)
                            {
                                lProto   = lSplit[0];
                                lMAC     = lSplit[1];
                                lSrcIP   = lSplit[2];
                                lSrcPort = lSplit[3];
                                lDstIP   = lSplit[4];
                                lDstPort = lSplit[5];
                                lData    = lSplit[6];

                                if (((lMatchURI = Regex.Match(lData, @"(\s+|^)(GET|POST)\s+([^\s]+)\s+HTTP\/"))).Success)
                                {
                                    lMethod    = lMatchURI.Groups[2].Value.ToString();
                                    lReqString = lMatchURI.Groups[3].Value.ToString();

                                    if (((lMatchHost = Regex.Match(lData, @"\.\.Host\s*:\s*([\w\d\-_\.]+?)\.\.", RegexOptions.IgnoreCase))).Success)
                                    {
                                        lRemoteHost = lMatchHost.Groups[1].Value.ToString();
                                    }
                                    else
                                    {
                                        lRemoteHost = lDstIP;
                                    }

                                    if (((lMatchCookies = Regex.Match(lData, @"\.\.Cookie\s*:\s*(.*?)(\.\.|$)", RegexOptions.IgnoreCase))).Success)
                                    {
                                        lCookies = lMatchCookies.Groups[1].Value.ToString();
                                    }
                                    else
                                    {
                                        lCookies = String.Empty;
                                    }

                                    lNewRecords.Add(new HTTPRequests(lMAC, lSrcIP, lMethod, lRemoteHost, lReqString, lCookies, lData));


                                    /*
                                     * If we reached the max no. of records remove records on the top.
                                     */
                                    try
                                    {
                                        cHTTPRequests.Add(new HTTPRequests(lMAC, lSrcIP, lMethod, lRemoteHost, lReqString, lCookies, lData));
                                        if (cHTTPRequests.Count > cMaxTableRows)
                                        {
                                            cHTTPRequests.RemoveAt(0);
                                        }
                                    }
                                    catch (Exception lEx)
                                    {
                                        PluginParameters.HostApplication.LogMessage(lEx.StackTrace);
                                    }
                                } // if (lDstPort == "80" ...
                            }     // if (lSpli...
                        }         // if (pData.Le...
                    }
                    catch (Exception lEx)
                    {
                        MessageBox.Show(String.Format("{0} : {1}", Config.PluginName, lEx.ToString()));
                    }
                } // for (String lE...

                cTask.addRecords(lNewRecords);
            } // if (cDat...
        }