Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 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();
 }
Exemplo n.º 8
0
        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;
                    }
                }
            }
        }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 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();
 }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
 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();
 }