public Uri GenerateUri(WebServerUriType type, Uri url, string buffer) { Uri result = null; // get last segment and save the rest segments in a builder StringBuilder builder = new StringBuilder(); string lastSegment = string.Empty; // remove scheme string scheme = url.Scheme; string tempUrl = url.ToString(); string[] segments = tempUrl.Replace(scheme + "://", "").Split('/'); // append scheme segments[0] = scheme + "://" + segments[0]; for (int i=0;i<segments.Length;i++) { if ( i == (segments.Length-1) ) { if ( segments[i].Length == 0 ) { lastSegment = "/"; } else { // last segment lastSegment = segments[i]; } } else { if ( segments[i].Length == 0 ) { builder.Append("/"); } else { // save segments builder.Append(segments[i] + "/"); } } } if ( lastSegment != "/" ) { switch (type) { case WebServerUriType.Normal: result = GenerateNormalUriTest(lastSegment, builder.ToString(), buffer); break; } } else { result = url; } return result; }
/// <summary> /// Fills the uri with tests. /// </summary> /// <param name="url"> The url.</param> /// <param name="uriType"> The WebServerUriType type.</param> /// <returns> The updated uri.</returns> public Uri FillUri(Uri url, WebServerUriType uriType) { return url; }
/// <summary> /// Fills the uri with tests. /// </summary> /// <param name="url"> The url.</param> /// <param name="uriType"> The WebServerUriType type.</param> /// <returns> The updated uri.</returns> public Uri FillUri(Uri url, WebServerUriType uriType) { string buffer = this.SqlValue; // copy url Uri temp = new Uri(url.ToString()); UriGenerator generator = new UriGenerator(); try { temp = generator.GenerateUri(uriType, temp, buffer); return temp; } catch (Exception ex) { ExceptionHandler.RegisterException(ex); return url; } }
/// <summary> /// Builds a unit test for a uri. /// </summary> /// <param name="testType"> The test type</param> /// <param name="webServerUriType"> The web server url type.</param> /// <param name="url"> The uri data.</param> /// <returns> An edited cookie collection.</returns> public Uri BuildUnitTestGetRequest(UnitTestType testType, WebServerUriType webServerUriType, Uri url) { Uri result = null; IHtmlFormUnitTest tester = null; // Call FillForm switch (testType) { case UnitTestType.BufferOverflow: tester = new BufferOverflowTester((BufferOverflowTesterArgs)this.Arguments); break; case UnitTestType.DataTypes: tester = new DataTypesTester((DataTypesTesterArgs)this.Arguments); break; case UnitTestType.SqlInjection: tester = new SqlInjectionTester((SqlInjectionTesterArgs)this.Arguments); break; case UnitTestType.XSS: tester = new XssInjectionTester((XssInjectionTesterArgs)this.Arguments); break; } if ( tester != null ) result = tester.FillUri(url,webServerUriType); return result; }
/// <summary> /// Applies the test to url. /// </summary> /// <param name="test"> The test to apply.</param> /// <param name="webServerUriType"> The web server uri type.</param> /// <param name="url"> The url.</param> /// <returns> A new url.</returns> protected Uri ApplyTestToUrl(Test test, WebServerUriType webServerUriType, Uri url) { UnitTester tester = new UnitTester(test.Arguments); return tester.BuildUnitTestGetRequest(test.TestType, webServerUriType, url); }
/// <summary> /// Fills the uri with tests. /// </summary> /// <param name="url"> The url.</param> /// <param name="uriType"> The WebServerUriType type.</param> /// <returns> The updated uri.</returns> public Uri FillUri(Uri url, WebServerUriType uriType) { BufferOverflowGenerator gen = new BufferOverflowGenerator(); string buffer = gen.GenerateStringBuffer(this.BufferLength); // chop extra chars buffer = buffer.Substring(0,this.BufferLength); buffer = EncodeDecode.UrlEncode(buffer); // copy url Uri temp = new Uri(url.ToString()); UriGenerator generator = new UriGenerator(); try { temp = generator.GenerateUri(uriType, temp, buffer); return temp; } catch (Exception ex) { ExceptionHandler.RegisterException(ex); return url; } }
/// <summary> /// Fills the uri with tests. /// </summary> /// <param name="url"> The url.</param> /// <param name="uriType"> The WebServerUriType type.</param> /// <returns> The updated uri.</returns> public Uri FillUri(Uri url, WebServerUriType uriType) { string buffer = String.Empty; switch ( this.SelectedDataType ) { case DataType.Character: buffer = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; break; case DataType.Numeric: buffer = "0123456789"; break; case DataType.Null: buffer = ""; break; } // copy url Uri temp = new Uri(url.ToString()); UriGenerator generator = new UriGenerator(); try { temp = generator.GenerateUri(uriType, temp, buffer); return temp; } catch (Exception ex) { ExceptionHandler.RegisterException(ex); return url; } }