Advertisement
7a_

Untrusted HTML XSS/CSS challenge

7a_
Jan 26th, 2012
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Created By Abraham Aranguren <name.surname@gmail.com> Twitter: @7a_ http://7-a.org
  3. # Reference: http://lxml.de/lxmlhtml.html#cleaning-up-html
  4. # Requires lxml, installation instructions here: http://lxml.de/installation.html
  5. # Installation in Backtrack 5: /usr/bin/easy_install --allow-hosts=lxml.de,*.python.org lxml
  6. # Tip for Ubuntu courtesy of Mario Heiderich: Python2.7-dev is needed to compile this lib properly
  7. from lxml.html.clean import clean_html
  8. #ALLOWED_TAGS = ( 'div', 'table', 'tr', 'td', 'b', 'i', 'a', 'p' ) # Phase 2? :)
  9. class HTMLSanitiser:
  10.         def __init__(self):
  11.                 pass
  12.  
  13.         def CleanThirdPartyHTML(self, HTML):
  14.                 return clean_html(HTML)
  15.  
  16. # For testing as a standalone script:
  17. Sanitiser = HTMLSanitiser()
  18. with open('input.txt') as file:
  19.         print Sanitiser.CleanThirdPartyHTML(file.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement