예제 #1
0
파일: WebProxy.cs 프로젝트: QardenEden/Suru
		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();
		}
예제 #2
0
파일: WebProxy.cs 프로젝트: QardenEden/Suru
		private void DoOneJob(jobQ thejob){		
			try{
				#region JOBRECON_DIR
				
				if (thejob.jobtype.Equals("_dir_recon_")){
				
					statusBar1.Text="Testing directory "+thejob.location+" on host "+thejob.targethost+"  SSL is "+thejob.isSSL.ToString();
				
					bool istrue=testRequest(thejob.targethost,
						thejob.targetport,
						buildRequest(thejob.location,"","",thejob.header),
						(int)updownTimeOut.Value,
						false,
						thejob.isSSL,
						thejob.header,
						Convert.ToDouble(NUPDOWNBackEnd.Value));
				
					if (istrue == true) {
						

						//we also need to feed this back for recursive testing!
						detailedRequest feedback = new detailedRequest();
						feedback.port=thejob.targetport;
						feedback.host=thejob.targethost;
						feedback.isSSL=thejob.isSSL;
						feedback.header=thejob.header;
						feedback.URL=thejob.location+"/";
						feedback.filename="";
						feedback.filetype="";
						do_Recon(feedback);

						//ok add the treenode
						string proto;
						if (thejob.isSSL){
							proto="https://";
						} else {
							proto="http://";
						}

						discovered newdis = new discovered();
						newdis.host=thejob.targethost;
						newdis.isSSL=thejob.isSSL;
						newdis.port=thejob.targetport;
						newdis.URL=thejob.location;
						newdis.protocol=proto;
						newdis.mode=2;
						newdis.header=thejob.header;

						lock (discovered_goods){
							discovered_goods.Add(newdis);
						}
					}	
					lock (this){
						jobstodo--;
					}
				}
				
				#endregion

				#region JOB_CHECK_INDEX
				//do reconjob
				if (thejob.jobtype.Equals("_check_index_")){
					statusBar1.Text="Checking indexability for "+thejob.location+" on "+thejob.targethost+"  SSL is "+thejob.isSSL.ToString();
					bool isindex=checkIndexability(thejob);
					if (isindex){
						string proto;
						if (thejob.isSSL){
							proto="https://";
						} else {
							proto="http://";
						}
						discovered newdis = new discovered();
						newdis.host=thejob.targethost;
						newdis.isSSL=thejob.isSSL;
						newdis.port=thejob.targetport;
						newdis.URL=thejob.location+"[indexable]";
						newdis.protocol=proto;
						newdis.mode=3;
						newdis.header=thejob.header;

						discovered_goods.Add(newdis);
					}
					lock (this){
						jobstodo--;
					}
				}
				
				#endregion

				#region JOBRECON_FILE
				if (thejob.jobtype.Equals("__file_recon__")){
					string displaytext="Testing file /"+thejob.location+"/"+thejob.filename+"."+thejob.ext+" on host "+thejob.targethost+"  SSL is "+thejob.isSSL.ToString();
					statusBar1.Text=displaytext.Replace("//","/").Replace("///","/");
				
					bool istrue=testRequest(thejob.targethost,
						thejob.targetport,
						buildRequest(thejob.location,thejob.filename,thejob.ext,thejob.header),
						(int)updownTimeOut.Value,
						true,
						thejob.isSSL,
						thejob.header,
						Convert.ToDouble(NUPDOWNBackEnd.Value));
				
					if (istrue == true) {
						//ok add the treenode
						string proto;
						if (thejob.isSSL){
							proto="https://";
						} else {
							proto="http://";
						}

						discovered newdis = new discovered();
						newdis.host=thejob.targethost;
						newdis.isSSL=thejob.isSSL;
						newdis.port=thejob.targetport;
						newdis.URL=thejob.location+"/"+thejob.filename+"."+thejob.ext;
						newdis.protocol=proto;
						newdis.mode=4;
						newdis.header=thejob.header;

						lock (discovered_goods){
							discovered_goods.Add(newdis);
						}
					}
					lock (this){
						jobstodo--;
					}
				}
				#endregion

			
			} catch(Exception ex) {
				MessageBox.Show(ex.ToString());
			}
				
		}