Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 8
0
 def test_payload_html_inside_comment(self):
     html = """
     <html>
         <!-- <body>PAYLOAD</body> -->
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlComment)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 12
0
 def test_payload_html_inside_comment(self):
     html = """
     <html>
         <!-- <body>PAYLOAD</body> -->
     </html>
     """
     self.assertIsInstance(get_context(html, 'PAYLOAD')[0], HtmlComment)
Exemplo n.º 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)
Exemplo n.º 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<'))
Exemplo n.º 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())
Exemplo n.º 16
0
 def test_payload_src(self):
     html = """
     <html>
         <img src="PAYLOAD" />
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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<'))
Exemplo n.º 20
0
 def test_payload_src(self):
     html = """
     <html>
         <img src="PAYLOAD" />
     </html>
     """
     context = get_context(html, 'PAYLOAD')[0]
     self.assertTrue(context.is_executable())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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<'))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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<'))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)