public void AddURLToTreeView(string url, int mode, Hashtable htNodes, TreeTagType treetag) { Regex r = new Regex(@"^\s*(?<protocol>https?)://(?<path>.*)", RegexOptions.IgnoreCase); Match m = r.Match(url); TreeNodeCollection nodes = treeRecon.Nodes; if ( m.Success ) { Protocol p = (Protocol)Enum.Parse(typeof(Protocol), m.Result("${protocol}"), true); char[] separators = { '\\', '/' }; ExtendedTreeNode etn = null; bool updateflag=false; foreach ( string path in m.Result("${path}").Split(separators) ) { if (path.Length>0){ if ( htNodes.ContainsKey(path) ) { etn = (ExtendedTreeNode)htNodes[path]; } else { etn = new ExtendedTreeNode(path); etn.ForeColor = getColourCode(mode, p); etn.Tag = (TreeTagType)treetag; nodes.Add(etn); htNodes.Add(path, etn); updateflag=true; } // Expand the node in mode two & three if ( (mode == 2 || mode==3 || mode==4) && chkReconAlwaysExpand.Checked) etn.Expand(); htNodes = etn.children; nodes = etn.Nodes; } } // next node etn.ForeColor = getColourCode(mode, p); if (updateflag){ treeRecon.Refresh(); } } // if valid url } // end AddURLToTreeView()
private void AddDirectoryForDirectoryscan(object sender, System.EventArgs e){ try{ TreeNode current = treeRecon.GetNodeAt(MouseX, MouseY); jobQ singlejob = new jobQ(); string FP=current.FullPath; string templocation=string.Empty; //host string[] FP_parts=FP.Split('\\'); singlejob.targethost=FP_parts[0]; string temp=""; for (int t=1; t<FP_parts.Length; t++){ temp+=FP_parts[t]+"/"; } temp=temp.TrimEnd('/'); templocation="/"+temp; templocation=templocation.Replace("//","/"); TreeTagType rectag = new TreeTagType(); rectag=(TreeTagType)current.Tag; //isSSL singlejob.isSSL = rectag.isSSL; singlejob.targetport=rectag.port; singlejob.ext="-NONE-"; singlejob.jobtype="_dir_recon_"; singlejob.header=clean_partial_header(rectag.header); ArrayList totestfor=new ArrayList(); totestfor.AddRange(txtWiktoTestDirs.Lines); if (chkSmartDirScan.Checked){ foreach (string item in kn_dirs){ string[] partsd = item.Split(':'); string[] dirparts = partsd[1].Split('/'); foreach (string dirpart in dirparts){ if (totestfor.Contains(dirpart)==false && dirpart.Length>0){ totestfor.Add(dirpart); } } } } foreach (string dir in totestfor){ singlejob.location=templocation+"/"+dir; singlejob.location=singlejob.location.Replace("//","/"); JOBQ.Add(singlejob); } } catch{} }
private void clearQonehost(object sender, System.EventArgs e){ try{ TreeNode current = treeRecon.GetNodeAt(MouseX, MouseY); TreeTagType thistag = new TreeTagType(); //thistag=(TreeTagType)treeRecon.SelectedNode.Tag; thistag=(TreeTagType)current.Tag; //string[] parts = treeRecon.SelectedNode.FullPath.Split('\\'); string[] parts = current.FullPath.Split('\\'); ArrayList tempQ = new ArrayList(); tempQ.AddRange(JOBQ.GetRange(0,JOBQ.Count)); lock (JOBQ){ JOBQ.Clear(); foreach (jobQ item in tempQ){ if (item.targethost.Equals(parts[0])==false){ JOBQ.Add(item); } } } } catch{} }
//this is for adding a file finding job. private void treeRecon_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e) { //lets see TreeNode current = e.Node; jobQ singlejob = new jobQ(); string FP=current.FullPath; //host string[] FP_parts=FP.Split('\\'); singlejob.targethost=FP_parts[0]; string temp=""; for (int t=1; t<FP_parts.Length; t++){ temp+=FP_parts[t]+"/"; } temp=temp.TrimEnd('/'); singlejob.location="/"+temp; singlejob.location=singlejob.location.Replace("//","/"); TreeTagType rectag = new TreeTagType(); rectag=(TreeTagType)current.Tag; //isSSL singlejob.isSSL = rectag.isSSL; singlejob.targetport=rectag.port; singlejob.jobtype="__file_recon__"; singlejob.header=clean_partial_header(rectag.header); if (current.Checked){ foreach (string filetype in txtWiktoTestTypes.Lines){ foreach (string filename in txtWiktoTestFilenames.Lines){ singlejob.ext=filetype; singlejob.filename=filename; JOBQ.Add(singlejob); } } } else { //remove it from the Q lock (JOBQ){ ArrayList kaas = new ArrayList(); kaas.AddRange(JOBQ.GetRange(0,JOBQ.Count)); foreach (jobQ item in kaas){ if (item.targethost.Equals(singlejob.targethost) && item.location.Equals(singlejob.location) && item.targetport.Equals(singlejob.targetport) && item.isSSL==singlejob.isSSL){ //remove it JOBQ.Remove(item); } } } } }
//this is very much the same as on top...with minor diffs. private void timer1_Tick(object sender, System.EventArgs e) { lock (this){ //lets first update the discovery tree... foreach (discovered item in discovered_goods){ //add the tag to the tree entry TreeTagType tag = new TreeTagType(); tag.isSSL=item.isSSL; tag.port=item.port; tag.header=item.header; AddURLToTreeView(item.protocol+item.host+item.URL,item.mode, Reconnodes,tag); } if (chkProxyAutoUpdate.Checked){ try{ if (Requests.Count <1){ return; } } catch{ return; } WorkRequests = new ArrayList(); lock (Requests){ int countr=0; for (int g=displayed_items; g<Requests.Count; g++){ WorkRequests.Add(Requests[g]); countr++; } displayed_items+=countr; } //display //EditRequests.Clear(); int actuallyadded=0; foreach (HTTPRequest item in WorkRequests){ string display=string.Empty; if (item.host.Equals("this is a comment")){ display="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; EditRequests.Add(item); } else{ detailedRequest work =getHTTPdetails(item.header,item.host,item.isSSL); detailed_Requests.Add(work); bool badextflag=true; badextflag=ApplyBigFilter(work,item); if (badextflag==false){ display+=item.reqnum.ToString()+" "; try{ txtCrowResponse.Text=item.response; char [] tosplit={' ','\r'}; string[] response_parts=item.response.Split(tosplit); display+=response_parts[1]; } catch{} if (item.header.IndexOf("SensePost-SuruWP: edited request")>=0){ display+="="; } else {display+=" ";} string proto=""; if (item.isSSL){ display+="# "; proto="https://"; } else { display+="+ "; proto="http://"; } if (work.isXML){ display+="X"; } if (work.isMultiPart){ display+="MP"; } if (work.action.Equals("GET")==true){ display+="G "; } if (work.action.Equals("POST")==true){ display+="P "; } display+=work.GETparameters.Count.ToString()+" "; display+=work.POSTparameters.Count.ToString()+" "; if (chkShowHosts.Checked){ display+=work.host+" "; } display+=work.URL; if (work.URL.Length>0){ do_Recon(work); }else{ MessageBox.Show("NULL URL auto"); } //add the tag to the tree entry TreeTagType tag = new TreeTagType(); tag.isSSL=work.isSSL; tag.port=work.port; if (work.header.IndexOf("Cookie:")<0 && work.cookie.Count>0){ //we need to restitch the bloody cookies into the header....if they not there already.. string cookieline="Cookie: "; foreach (string itemc in work.cookie){ cookieline+=itemc+txtCookieVariableSeparator.Text[0]; } cookieline.TrimEnd(';'); //lets add it right at the top string tempheader=cookieline+"\r\n"+work.header; work.header=tempheader; } tag.header=clean_partial_header(work.header); AddURLToTreeView(proto+work.host+work.URL,1, Reconnodes, tag); EditRequests.Add(item); actuallyadded++; //add to widget } } if (display.Length>4){ listView1.Items.Add(display); } } if (actuallyadded>0){ //lstURLs.SelectedIndex=lstURLs.Items.Count-1; ///***** NEW DATA HERE *****/// ///***** NEW DATA HERE *****/// } } } }
private void UpdateListViewControl() { listView1.Items.Clear(); txtHTTPdetails.Clear(); EditRequests.Clear(); detailed_Requests.Clear(); try { if (Requests.Count <1){ return; } } catch{ return; } WorkRequests = new ArrayList(); lock (Requests){ foreach (HTTPRequest test in Requests){ WorkRequests.Add(test); } } //display foreach (HTTPRequest item in WorkRequests){ string display=string.Empty; bool isHighlighted = false; int isColour = 0; detailedRequest work =getHTTPdetails(item.header,item.host,item.isSSL); detailed_Requests.Add(work); bool badextflag=true; badextflag=ApplyBigFilter(work,item); if (badextflag==false){ display+=item.reqnum.ToString()+" "; try{ txtCrowResponse.Text=item.response; char [] tosplit={' ','\r'}; string[] response_parts=item.response.Split(tosplit); display+=response_parts[1]; } catch{} if (item.header.IndexOf("SensePost-SuruWP: edited request")>=0){ display+="="; } else {display+=" ";} string proto=""; if (item.isSSL){ display+="# "; proto="https://"; } else { display+="+ "; proto="http://"; } if (work.isXML){ display+="X"; } if (work.isMultiPart){ display+="MP"; } if (work.action.Equals("GET")==true){ display+="G "; } if (work.action.Equals("POST")==true){ display+="P "; } switch (item.isColour) { case 0: isHighlighted = false; isColour = 0; break; case 1: isHighlighted = true; isColour = 1; break; case 2: isHighlighted = true; isColour = 2; break; case 3: isHighlighted = true; isColour = 3; break; case 4: isHighlighted = true; isColour = 4; break; case 5: isHighlighted = true; isColour = 5; break; case 6: isHighlighted = true; isColour = 6; break; case 7: isHighlighted = true; isColour = 7; break; case 8: isHighlighted = true; isColour = 8; break; case 9: isHighlighted = true; isColour = 9; break; default: isColour = 0; isColour = 0; isHighlighted = false; break; } display+=work.GETparameters.Count.ToString()+" "; display+=work.POSTparameters.Count.ToString()+" "; if (chkShowHosts.Checked){ display+=work.host+" "; } display+=work.URL; if (work.URL.Length>0){ do_Recon(work); }else{ MessageBox.Show("NULL URL click"); } //add the tag to the tree entry TreeTagType tag = new TreeTagType(); tag.isSSL=work.isSSL; tag.port=work.port; tag.header=work.header; AddURLToTreeView(proto+work.host+work.URL,1, Reconnodes, tag); EditRequests.Add(item); } if (display.Length>4){ listView1.Items.Add(display); ListViewItem z = listView1.Items[listView1.Items.Count-1]; switch (isColour) { case 0: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Black; break; case 1: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Brown; break; case 2: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Red; break; case 3: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Orange; break; case 4: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.DarkKhaki; break; case 5: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Green; break; case 6: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Cyan; break; case 7: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Blue; break; case 8: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Purple; break; case 9: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.DarkGray; break; default: z.Font = new System.Drawing.Font("MS Referense Sans Serif", 7.75F); z.ForeColor = System.Drawing.Color.Black; break; } listView1.Items[listView1.Items.Count-1].Selected = true; } } }