コード例 #1
0
        private static void WriteResponseInfo(HttpWebResponse response, ResponseDetails details)
        {
            details.Response = String.Format("{0}{1}{2}", Convert.ToString(( int )response.StatusCode), ' ', response.StatusDescription);
            details.Size     = response.ContentLength == -1 ? "Not Presented" : response.ContentLength.ToString(CultureInfo.InvariantCulture);

            using (var stream = response.GetResponseStream())
            {
                using (var reader = new StreamReader(stream, Encoding.Default))
                {
                    details.Body = reader.ReadToEnd();
                }
            }

            if (ResponseDetails != null)
            {
                //Critical section
                _mutex.WaitOne();
                ResponseDetails.Add(details);
                _mutex.ReleaseMutex();
            }
        }
コード例 #2
0
        private static void SearchSpecificContent(ResponseDetails details, string searchText, string searchTag)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(details.Body);

            var body = doc.DocumentNode.SelectNodes(String.Format("{0}{1}", "//", searchTag));

            details.Body = "Did not exists";

            if (body != null)
            {
                foreach (var item in body)
                {
                    if (item.InnerText.Contains(searchText))
                    {
                        details.Body = String.Format("{0}{1}", searchText, " exists");
                        break;
                    }
                }
            }
        }
コード例 #3
0
		private static void SearchSpecificContent( ResponseDetails details, string searchText, string searchTag )
		{
			var doc = new HtmlDocument();
			doc.LoadHtml( details.Body );

			var body = doc.DocumentNode.SelectNodes( String.Format( "{0}{1}", "//", searchTag ) );
			details.Body = "Did not exists";

			if( body != null )
			{
				foreach( var item in body )
				{
					if( item.InnerText.Contains( searchText ) )
					{
						details.Body = String.Format( "{0}{1}", searchText, " exists" );
						break;
					}
				}
			}
		}
コード例 #4
0
		private static void WriteResponseInfo( HttpWebResponse response, ResponseDetails details )
		{
			details.Response = String.Format( "{0}{1}{2}", Convert.ToString( ( int )response.StatusCode ), ' ', response.StatusDescription );
			details.Size = response.ContentLength == -1 ? "Not Presented" : response.ContentLength.ToString( CultureInfo.InvariantCulture );

			using( var stream = response.GetResponseStream() )
			{
				using( var reader = new StreamReader( stream, Encoding.Default ) )
				{
					details.Body = reader.ReadToEnd();
				}
			}

			if( ResponseDetails != null )
			{
				//Critical section
				_mutex.WaitOne();
				ResponseDetails.Add( details );
				_mutex.ReleaseMutex();
			}
		}
コード例 #5
0
		public static void ScanResource( object request )
		{
			var castedRequest = ( HttpWebRequest )request;
			var details = new ResponseDetails
				{
					Url = castedRequest.RequestUri,
					Category = Categories.SignInPages
				};

			try
			{
				using( var response = ( HttpWebResponse )castedRequest.GetResponse() )
				{
					foreach( Cookie cookie in response.Cookies )
					{
						CookieContainer.Add( response.ResponseUri, cookie );
					}

					WriteResponseInfo( response, details );
				}
			}
			catch( WebException ex )
			{
				WriteResponseInfo( ( HttpWebResponse )ex.Response, details );
			}
		}