internal void SetBody(byte[] BodyArray) { this.html = new HTML(); if (BodyArray == null) { this.SetEmptyBody(); return; } else if (BodyArray.Length == 0) { this.SetEmptyBody(); return; } this.bodyArray = BodyArray; this.bodyString = Encoding.GetEncoding(this.GetEncoding(BodyArray)).GetString(this.bodyArray); this.Headers.Set("Content-Length", this.bodyArray.Length.ToString()); this.CheckBodyFormatAndHandleIt(); }
public List <HtmlNode> GetForms() { List <HtmlNode> ProcessedForms = new List <HtmlNode>(); HtmlNodeCollection Forms = this.GetNodes("form"); if (Forms == null) { return(ProcessedForms); } foreach (HtmlNode Form in Forms) { string FormString = Form.OuterHtml; HTML FormHtml = new HTML(FormString); List <string> InputElements = GetInputNodeStrings(FormHtml.Html.DocumentNode.FirstChild); ProcessedForms.Add(GetStrippedForm(FormHtml.Html.DocumentNode.FirstChild, InputElements)); } return(ProcessedForms); }
internal void SetBody(string BodyString) { this.BodyFormatChecked = false; this.html = new HTML(); if (BodyString == null) { this.SetEmptyBody(); return; } else if (BodyString.Length == 0) { this.SetEmptyBody(); return; } this.bodyString = BodyString; this.bodyArray = Encoding.GetEncoding(this.GetEncoding()).GetBytes(this.bodyString); this.Headers.Set("Content-Length", this.bodyArray.Length.ToString()); //this.CheckBodyFormatAndHandleIt(); }
internal void SetBody(byte[] NewBodyArray) { this.BodyFormatChecked = false; this.html = new HTML(); if (NewBodyArray == null) { this.SetEmptyBody(); return; } else if (NewBodyArray.Length == 0) { this.SetEmptyBody(); return; } this.bodyArray = new byte[NewBodyArray.Length]; NewBodyArray.CopyTo(this.bodyArray, 0); this.bodyString = Encoding.GetEncoding(this.GetEncoding(NewBodyArray)).GetString(this.bodyArray); this.Headers.Set("Content-Length", this.bodyArray.Length.ToString()); //this.CheckBodyFormatAndHandleIt(); }
HtmlNode GetStrippedForm(HtmlNode OriginalForm, List<string> InputElementStrings) { OriginalForm.RemoveAllChildren(); foreach (string InputElementString in InputElementStrings) { HTML InputHtml = new HTML(InputElementString); OriginalForm.AppendChild(InputHtml.Html.DocumentNode.FirstChild); } return OriginalForm; }
public List<HtmlNode> GetForms() { List<HtmlNode> ProcessedForms = new List<HtmlNode>(); HtmlNodeCollection Forms = this.GetNodes("form"); if (Forms == null) return ProcessedForms; foreach (HtmlNode Form in Forms) { string FormString = Form.OuterHtml; HTML FormHtml = new HTML(FormString); List<string> InputElements = GetInputNodeStrings(FormHtml.Html.DocumentNode.FirstChild); ProcessedForms.Add(GetStrippedForm(FormHtml.Html.DocumentNode.FirstChild, InputElements)); } return ProcessedForms; }
void CheckBodyFormatAndHandleIt() { if (this.BodyFormatChecked) { return; } this.BodyFormatChecked = true; this.isJson = false; this.isHtml = false; this.isJavaScript = false; this.isXml = false; this.isCss = false; if (this.IsBinary) { return; } if (HTML.DoesHaveAngleBracketsAsStartingBoundary(this.BodyString)) { if (HTML.DoesHaveHtmlDocType(this.BodyString) || HTML.DoesHaveHtmlTags(this.BodyString)) { if (this.ProcessHtml()) { this.isHtml = true; } } if (!HTML.DoesHaveHtmlDocType(this.BodyString) && Tools.IsXml(this.BodyString)) { this.isXml = true; return; } if (this.IsHtml || this.IsXml) { return; } } else { if (!Tools.IsBinary(this.BodyArray)) { if (Tools.IsJson(this.BodyString)) { this.isJson = true; return; } if (Tools.IsJavaScript(this.BodyString)) { this.isJavaScript = true; return; } if (Tools.IsCss(this.BodyString)) { this.isCss = true; return; } if (this.ProcessHtml()) { this.isHtml = true; return; } } } }
internal static void TraceFromUI() { try { IronUI.ShowTraceStatus("Trace in progress...", false); IronJint IJ = new IronJint(); UIIJ = IJ; IJ.SetSourcesAndSinks(ConfiguredSourceObjects, ConfiguredSinkObjects, ConfiguredSourceReturningMethods, ConfiguredSinkReturningMethods, ConfiguredArgumentReturningMethods, ConfiguredArgumentAssignedASourceMethods, ConfiguredArgumentAssignedToSinkMethods); IJ.ClearAllTaint(); IJ.JintStack.Clear(); string DirtyJS = ""; if (Tools.IsJavaScript(InputCodeString)) { DirtyJS = InputCodeString; } else { try { HTML H = new HTML(InputCodeString); List<string> Scripts = H.GetJavaScript(); StringBuilder ScriptString = new StringBuilder(); foreach (string Script in Scripts) { ScriptString.AppendLine(Script); } DirtyJS = ScriptString.ToString(); } catch { throw new Exception("Entered text does not contain valid JavaScript"); } } if (DirtyJS.Length == 0) { throw new Exception("No valid JavaScript input available to trace"); } string CleanCode = Beautify(DirtyJS); IronUI.SetJSTaintTraceCode(CleanCode, false); IJ.Lines = new List<string>(CleanCode.Split(new string[] { "\r\n" }, StringSplitOptions.None)); if (PauseAtTaint) IronUI.SetJSTaintTraceResult(); IJ.StartedFromUI = true; IJ.Analyze(CleanCode); if (!PauseAtTaint) IronUI.SetJSTaintTraceResult(); IronUI.ShowTraceStatus("Trace Completed", false); IronUI.ResetTraceStatus(); } catch(ThreadAbortException) {} catch(Exception Exp) { StopUITrace(); IronUI.ResetTraceStatus(); IronUI.ShowTraceStatus("Trace Stopped due to error: " + Exp.Message, true); IronException.Report("Error performing JS Taint Trace", Exp.Message, Exp.StackTrace); } }
internal void SetBody(string BodyString) { this.html = new HTML(); if (BodyString == null) { this.SetEmptyBody(); return; } else if(BodyString.Length == 0) { this.SetEmptyBody(); return; } this.bodyString = BodyString; this.bodyArray = Encoding.GetEncoding(this.GetEncoding()).GetBytes(this.bodyString); this.CheckBodyFormatAndHandleIt(); }
internal void SetBody(string BodyString) { this.BodyFormatChecked = false; this.html = new HTML(); if (BodyString == null) { this.SetEmptyBody(); return; } else if(BodyString.Length == 0) { this.SetEmptyBody(); return; } this.bodyString = BodyString; this.bodyArray = Encoding.GetEncoding(this.GetEncoding()).GetBytes(this.bodyString); this.Headers.Set("Content-Length", this.bodyArray.Length.ToString()); //this.CheckBodyFormatAndHandleIt(); }