예제 #1
0
    def test_all(self):
        for context in get_contexts():
            found = False

            expected_context_name = context.get_name()
            for calculated_context in get_context(self.HTML, expected_context_name):
                if calculated_context.get_name() == expected_context_name:
                    found = True

            if not found:
                msg = "The analysis for %s context failed, got %r instead."
                msg = msg % (expected_context_name, get_context(self.HTML, expected_context_name))
                self.assertTrue(False, msg)
예제 #2
0
 def test_all(self):
     for context in get_contexts():
         found = False
         
         expected_context_name = context.get_name()
         for calculated_context in get_context(self.HTML, expected_context_name):
             if calculated_context.get_name() == expected_context_name:
                 found = True
         
         if not found:
             msg = 'The analysis for %s context failed, got %r instead.' 
             msg = msg % (expected_context_name,
                          get_context(self.HTML, expected_context_name))
             self.assertTrue(False, msg)
예제 #3
0
    def test_payload_with_space_equal_src_executable(self):
        """
        Related with:
            https://github.com/andresriancho/w3af/issues/1557
            https://github.com/andresriancho/w3af/issues/2919
        """
        html = """
        <html>
            <frame src="5vrws =">
        </html>
        """
        self.assertEqual(get_context(html, '5vrws%20%3D'), [])

        context = get_context(html, '5vrws =')[0]
        self.assertTrue(context.is_executable())
예제 #4
0
    def test_payload_with_space_equal_src_executable(self):
        """
        Related with:
            https://github.com/andresriancho/w3af/issues/1557
            https://github.com/andresriancho/w3af/issues/2919
        """
        html = """
        <html>
            <frame src="5vrws =">
        </html>
        """
        self.assertEqual(get_context(html, '5vrws%20%3D'), [])

        context = get_context(html, '5vrws =')[0]
        self.assertTrue(context.is_executable())
예제 #5
0
 def test_script_text(self):
     html = """
     <script>foo(); bar(PAYLOAD);</script>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1, contexts)
     self.assertIsInstance(contexts[0], ScriptText)
예제 #6
0
 def test_broken_4(self):
     html = """
     <a PAYLOAD="/xyz"></
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1, contexts)
     self.assertIsInstance(contexts[0], HtmlAttr)
예제 #7
0
 def test_style_text(self):
     html = """
     <style>foo(); bar(PAYLOAD);</style>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1, contexts)
     self.assertIsInstance(contexts[0], CSSText)
예제 #8
0
 def test_payload_html_inside_comment(self):
     html = """
     <html>
         <!-- <body>PAYLOAD</body> -->
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlComment)
예제 #9
0
    def test_django_500_sample(self):
        html = file(os.path.join(self.SAMPLES_DIR, 'django-500.html')).read()
        contexts = get_context(html, "QUBD5 =")

        self.assertEqual(len(contexts), 9)
        for c in contexts:
            self.assertIsInstance(c, HtmlText)
예제 #10
0
    def test_django_500_sample(self):
        html = file(os.path.join(self.SAMPLES_DIR, 'django-500.html')).read()
        contexts = get_context(html, "QUBD5 =")

        self.assertEqual(len(contexts), 9)
        for c in contexts:
            self.assertIsInstance(c, HtmlText)
예제 #11
0
 def test_payload_js2doublequote(self):
     html = """
     <html>
         <input type="button" value="ClickMe" onClick="PAYLOAD">
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[1], ScriptText)
예제 #12
0
 def test_payload_html_inside_comment(self):
     html = """
     <html>
         <!-- <body>PAYLOAD</body> -->
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlComment)
예제 #13
0
 def test_payload_js2doublequote(self):
     html = """
     <html>
         <input type="button" value="ClickMe" onClick="PAYLOAD">
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[1], ScriptText)
예제 #14
0
 def test_payload_text_can_break(self):
     html = """
     <html>
         <a>PAYLOAD<</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD<')[0]
     self.assertTrue(context.can_break('PAYLOAD<'))
예제 #15
0
 def test_payload_handler(self):
     html = """
     <html>
         <a onclick="PAYLOAD">foo</a>
     </html>
     """
     context = get_context(html, "PAYLOAD")[0]
     self.assertTrue(context.is_executable())
예제 #16
0
 def test_payload_src(self):
     html = """
     <html>
         <img src="PAYLOAD" />
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
예제 #17
0
 def test_payload_href(self):
     html = """
     <html>
         <a href="PAYLOAD">foo</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
예제 #18
0
 def test_payload_href(self):
     html = """
     <html>
         <a href="PAYLOAD">foo</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
예제 #19
0
 def test_payload_text_can_break(self):
     html = """
     <html>
         <a>PAYLOAD<</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD<')[0]
     self.assertTrue(context.can_break('PAYLOAD<'))
예제 #20
0
 def test_payload_src(self):
     html = """
     <html>
         <img src="PAYLOAD" />
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
예제 #21
0
 def test_payload_confuse_parser(self):
     html = """
     <html>
         <a attr="</a>">PAYLOAD</a>
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], HtmlText)
예제 #22
0
 def test_payload_script_single_quote2(self):
     html = """
     <html>
         <script type="text/javascript">//<!--
             init({login:'',foo:'PAYLOAD'})
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptSingleQuote)
예제 #23
0
 def test_payload_script_single_quote(self):
     html = """
     <html>
         <script foo='PAYLOAD'>
             bar
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlAttrSingleQuote)
예제 #24
0
 def test_payload_html_inside_script_with_comment(self):
     html = """
     <html>
         <script>
             <!-- <body>PAYLOAD</body> -->
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptText)
예제 #25
0
 def test_tag_attr_single_double_quote(self):
     html = """
     <html>
         <tag spam='eggs' attr="PAYLOAD" />
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], HtmlAttrDoubleQuote)
예제 #26
0
 def test_payload(self):
     html = """
     <html>
         <body>
             &added=blah111%3C1%3E<br>::::: blahPAYLOAD<br>::::: :::::
         </body>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlText)
예제 #27
0
    def test_payload_tag_name_close(self):
        html = """
        <foo>
        </PAYLOAD>
        """
        contexts = get_context(html, 'PAYLOAD')
        self.assertEqual(len(contexts), 1, contexts)

        self.assertIsInstance(contexts[0], HtmlTagClose)
예제 #28
0
 def test_payload_a_single_quote(self):
     html = """
     <html>
         <a foo='PAYLOAD'>
             bar
         </a>
     </html>
     """
     self.assertIsInstance(get_context(html, "PAYLOAD")[0], HtmlAttrSingleQuote)
예제 #29
0
 def test_payload_double_script(self):
     html = """
     <html>
         <script>foo</script>
             PAYLOAD
         <script>bar</script>
     </html>
     """
     self.assertIsInstance(get_context(html, "PAYLOAD")[0], HtmlText)
예제 #30
0
 def test_payload_script_single_quote2(self):
     html = """
     <html>
         <script type="text/javascript">//<!--
             init({login:'',foo:'PAYLOAD'})
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptSingleQuote)
예제 #31
0
 def test_payload_script_broken_double_open(self):
     html = """
     <html>
         <script>foo
             PAYLOAD
         <script>bar</script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptText)
예제 #32
0
 def test_payload_script_attr_value(self):
     html = """
     <html>
         <script foo=PAYLOAD foo2=aaa>
             bar
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlAttr)
예제 #33
0
 def test_payload_script_broken_double_close(self):
     html = """
     <html>
         <script>foo</script>
             PAYLOAD
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlText)
예제 #34
0
 def test_payload_text_with_end_quote(self):
     html = """
     <html>
         <a>Quoting the great Linus Torvalds: PAYLOAD<"</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD<')[0]
     self.assertIsInstance(context, HtmlText)
     self.assertTrue(context.can_break('PAYLOAD<'))
예제 #35
0
 def test_payload_script_attr_value(self):
     html = """
     <html>
         <script foo=PAYLOAD foo2=aaa>
             bar
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlAttr)
예제 #36
0
 def test_payload_script_single_quote(self):
     html = """
     <html>
         <script foo='PAYLOAD'>
             bar
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlAttrSingleQuote)
예제 #37
0
 def test_payload_script_broken_double_close(self):
     html = """
     <html>
         <script>foo</script>
             PAYLOAD
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlText)
예제 #38
0
 def test_payload_text_with_end_quote(self):
     html = """
     <html>
         <a>Quoting the great Linus Torvalds: PAYLOAD<"</a>
     </html>
     """
     context = get_context(html, 'PAYLOAD<')[0]
     self.assertIsInstance(context, HtmlText)
     self.assertTrue(context.can_break('PAYLOAD<'))
예제 #39
0
 def test_payload_html_inside_script_with_comment(self):
     html = """
     <html>
         <script>
             <!-- <body>PAYLOAD</body> -->
         </script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptText)
예제 #40
0
 def test_payload_script_broken_double_open(self):
     html = """
     <html>
         <script>foo
             PAYLOAD
         <script>bar</script>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], ScriptText)
예제 #41
0
 def test_payload(self):
     html = """
     <html>
         <body>
             &added=blah111%3C1%3E<br>::::: blahPAYLOAD<br>::::: :::::
         </body>
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlText)
예제 #42
0
 def test_payload_html_inside_comment(self):
     html = """
     <html>
         <!-- <body>PAYLOAD</body> -->
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], HtmlComment)
예제 #43
0
    def test_payload_tag_attr_key(self):
        html = """
        <a PAYLOAD="/xyz">foo</a>
        """
        contexts = get_context(html, 'PAYLOAD')

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, HtmlAttr)
예제 #44
0
 def test_payload_inside_noscript_2(self):
     html = """
     <html>
         <noscript>
             <a onmouseover="PAYLOAD">link</a>
         </noscript>
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 0)
예제 #45
0
 def test_payload_script_broken_double_close(self):
     html = """
     <html>
         <script>foo</script>
             PAYLOAD
         </script>
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], ScriptText)
예제 #46
0
 def test_payload_in_html_text(self):
     html = """
     <html>
         <body>
             PAYLOAD
         </body>
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], HtmlText)
예제 #47
0
    def test_payload_text_with_end_quote(self):
        html = """
        <html>
            <a>Quoting the great Linus Torvalds: PAYLOAD<"</a>
        </html>
        """
        contexts = get_context(html, 'PAYLOAD<"')
        self.assertEqual(len(contexts), 1)

        context = contexts[0]
        self.assertIsInstance(context, HtmlText)
예제 #48
0
 def test_payload_broken_double_open(self):
     html = """
     <html>
         <tag>foo
             PAYLOAD
         <tag>bar</tag>
     </html>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1)
     self.assertIsInstance(contexts[0], HtmlText)
예제 #49
0
 def test_script_text_comment(self):
     html = """
     <script type="text/javascript">
     <!--
     foo(); bar(PAYLOAD);
     //-->
     </script>
     """
     contexts = get_context(html, 'PAYLOAD')
     self.assertEqual(len(contexts), 1, contexts)
     self.assertIsInstance(contexts[0], ScriptText)