private bool ApplyBigFilter(detailedRequest passed, HTTPRequest Hpassed){ if (bypassfiltercompletely){ return false; } //assume its good bool matchfilterh = false; //compare hosts if (currentFilter.Hosts.Count>0){ foreach (string item in currentFilter.Hosts){ if (passed.host.IndexOf(item)>=0){ matchfilterh=true; break; } } } else {matchfilterh=true;} //compare locations bool matchfilterl = false; if (currentFilter.Locations.Count>0){ foreach (string item in currentFilter.Locations){ if (passed.URL.IndexOf(item)>=0){ matchfilterl=true; break; } } }else { matchfilterl=true; } //compare actions bool matchfiltera = false; if (currentFilter.Actions.Count>0){ foreach (string item in currentFilter.Actions){ if (passed.action.IndexOf(item)>=0){ matchfiltera=true; break; } } } else { matchfiltera=true; } //compare ext bool matchfiltere=false; if (currentFilter.Ext.Count>0){ foreach (string item in currentFilter.Ext){ if (passed.filetype.IndexOf(item)>=0){ matchfiltere=true; //break; } } } else { matchfiltere=true; } //compare cookies bool matchfilterc=false; if (currentFilter.Cookies.Count>0){ foreach (string item in currentFilter.Cookies){ foreach (string Citem in passed.cookie){ if (Citem.IndexOf(item)>=0){ matchfilterc=true; //break; } } } } else { matchfilterc=true; } //compare parameters bool matchfilterpg = false; bool matchfilterpp = false; if (anyPostorGet==false){ foreach (string item in currentFilter.Parameters){ foreach (string Gitem in passed.GETparameters){ if (Gitem.IndexOf(item)>=0){ matchfilterpg=true; //break; } } if (matchfilterpg){ break; } } if (currentFilter.Parameters.Count<=0){ matchfilterpg=true; } // POST foreach (string item in currentFilter.Parameters){ foreach (string Pitem in passed.POSTparameters){ if (Pitem.IndexOf(item)>=0){ matchfilterpp=true; //break; } } } if (currentFilter.Parameters.Count<=0){ matchfilterpp=true; } } else { if (passed.GETparameters.Count>0 || passed.POSTparameters.Count>0){ matchfilterpg=true; matchfilterpp=true; } } //request bool matchfilterReq=false; if (currentFilter.RequestHeader.Count>0){ foreach (string item in currentFilter.RequestHeader){ if (Hpassed.header.IndexOf(item)>=0){ matchfilterReq=true; } } } else { matchfilterReq=true; } //response bool matchfilterRes=false; if (currentFilter.ResponseHeader.Count>0){ foreach (string item in currentFilter.ResponseHeader){ if (Hpassed.response.IndexOf(item)>=0){ matchfilterRes=true; } } } else { matchfilterRes=true; } //isSSL bool mfSSL=false; if (currentFilter.IsHTTPS && Hpassed.isSSL){ mfSSL=true; } //is HTTP bool mfHTTP=false; if (currentFilter.IsHTTP && !Hpassed.isSSL){ mfHTTP=true; } matchfiltere=matchfiltere^currentFilter.inExt; matchfiltera=matchfiltera^currentFilter.inActions; matchfilterl=matchfilterl^currentFilter.inLocations; matchfilterpg=matchfilterpg^currentFilter.inParameters; matchfilterpp=matchfilterpp^currentFilter.inParameters; matchfilterh=matchfilterh^currentFilter.inHost; matchfilterc=matchfilterc^currentFilter.inCookies; matchfilterReq=matchfilterReq^currentFilter.inRequests; matchfilterRes=matchfilterRes^currentFilter.inResponse; if (currentFilter.inParameters){ return !((mfSSL || mfHTTP) && matchfilterReq && matchfilterRes && matchfilterc && matchfiltere && matchfiltera && matchfilterh && matchfilterl && (matchfilterpg && matchfilterpp)); } else { return !((mfSSL || mfHTTP) && matchfilterReq && matchfilterRes && matchfilterc && matchfiltere && matchfiltera && matchfilterh && matchfilterl && (matchfilterpg || matchfilterpp)); } }
private void btnLoadData_Click(object sender, System.EventArgs e) { string filename=string.Empty; StreamReader reader; string dummy=string.Empty; try{ DialogResult opened=openFileDialog1.ShowDialog(); radioFile1.Checked=true; if (opened==DialogResult.OK){ filename=openFileDialog1.FileName; } else { return; } #region log data reader = new StreamReader(filename); string line=string.Empty; bool startrecord=true; bool recordheader=false; bool recordresponse=false; dummy=reader.ReadLine(); dummy=reader.ReadLine(); HTTPRequest newrequest=new HTTPRequest(); while (1==1) { try{ string responseline=string.Empty; while (recordresponse && responseline.Equals("--------->>>>>>")==false){ responseline=reader.ReadLine(); if (responseline.Equals("--------->>>>>>")){ recordresponse=false; recordheader=false; startrecord=true; newrequest.header=newrequest.header.TrimEnd('\n'); newrequest.header=newrequest.header.TrimEnd('\r'); Requests.Add(newrequest); break; } newrequest.response+=responseline+"\n"; } string headerline=string.Empty; while (recordheader && headerline.Equals("=-=-=-=-=-=-=-")==false){ headerline=reader.ReadLine(); if (headerline.Equals("=-=-=-=-=-=-=-")){ recordresponse=true; recordheader=false; break; } newrequest.header+=headerline+"\n"; } if (startrecord){ newrequest = new HTTPRequest(); newrequest.DT=Convert.ToDateTime(reader.ReadLine()); newrequest.reqnum=Convert.ToInt32(reader.ReadLine()); newrequest.host=reader.ReadLine(); string sz_line = reader.ReadLine(); if (sz_line.IndexOf("|") == -1) { newrequest.isSSL = Convert.ToBoolean(sz_line); newrequest.isHighlighted = false; newrequest.isColour = 0; } else { string[] st_line = sz_line.Split('|'); newrequest.isSSL = Convert.ToBoolean(st_line[0]); newrequest.isColour = Convert.ToInt32(st_line[1]); } newrequest.URL=reader.ReadLine(); recordheader=true; startrecord=false; } } catch { reader.Close(); //add the last one!! newrequest.header=newrequest.header.TrimEnd('\n'); newrequest.header=newrequest.header.TrimEnd('\r'); Requests.Add(newrequest); break; } } } catch { MessageBox.Show("Cannot find main file, or file is corrupt - sorry!"); return; } #endregion #region discovered try{ //read the discovered goods reader = new StreamReader(filename+".Suru-discovered"); string deaderline; dummy=reader.ReadLine(); while (1==1){ discovered disc = new discovered(); try{ disc.host=reader.ReadLine(); if (disc.host==null){ throw new Exception("moo"); } disc.isSSL=Convert.ToBoolean(reader.ReadLine()); disc.mode=Convert.ToInt32(reader.ReadLine()); disc.port=reader.ReadLine(); disc.protocol=reader.ReadLine(); disc.URL=reader.ReadLine(); while ((deaderline=reader.ReadLine()) != null){ if (deaderline.Equals("--------->>>>>>")){ break; } disc.header+=deaderline; } discovered_goods.Add(disc); } catch { reader.Close(); break; } } reader.Close(); } catch{ MessageBox.Show("Cant read "+filename+".Suru-discovered\nDiscovered data wont be shown\n"); return; } #endregion Reconnodes.Clear(); globalcount = Requests.Count; UpdateListViewControl(); }
private void mnu_HLBlack_Click(object sender, System.EventArgs e) { int n_index = 0; int n_myindex = 0; if (listView1.SelectedItems.Count != 0) { foreach ( ListViewItem z in listView1.SelectedItems) { n_myindex = z.Index; string sz_reqnum = z.Text.Substring(0, z.Text.IndexOf(" ")); int n_reqnum = Convert.ToInt32(sz_reqnum); HTTPRequest myhr = new HTTPRequest(); System.Drawing.Font myfont = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); foreach (HTTPRequest hr in Requests) { if (hr.reqnum == n_reqnum) { myhr = hr; break; } n_index++; } z.Font = myfont; z.ForeColor = System.Drawing.Color.Black; myhr.isHighlighted = false; myhr.isColour = 0; Requests[n_index] = myhr; } listView1.Refresh(); listView1.Items[n_myindex].Selected = true; } }