xml_export.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/python
  2. # -*- coding: iso-8859-15 -*-
  3. """
  4. This file is part of the cintruder project, http://cintruder.03c8.net
  5. Copyright (c) 2012/2016 psy <epsylon@riseup.net>
  6. cintruder is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation version 3 of the License.
  9. cintruder is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  12. details.
  13. You should have received a copy of the GNU General Public License along
  14. with cintruder; if not, write to the Free Software Foundation, Inc., 51
  15. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. """
  17. import xml.etree.ElementTree as xml
  18. import datetime, os
  19. class CIntruderXML(object):
  20. """
  21. Print results from an attack in an XML fashion
  22. """
  23. def __init__(self, cintruder):
  24. # initialize main CIntruder
  25. self.instance = cintruder
  26. def print_xml_results(self, captchas, filename, word_sug):
  27. dirname = os.path.dirname(filename)
  28. if dirname and not os.path.exists(dirname):
  29. os.mkdir(dirname)
  30. root = xml.Element("report")
  31. hdr = xml.SubElement(root, "header")
  32. title = xml.SubElement(hdr, "title")
  33. title.text = "Captcha Intruder [http://cintruder.03c8.net] Report: " + str(datetime.datetime.now())
  34. target = xml.SubElement(root, "target")
  35. captcha = xml.SubElement(target, "captcha")
  36. words = xml.SubElement(captcha, "word")
  37. captcha.text = str(captchas)
  38. words.text = str(word_sug)
  39. tree = xml.ElementTree(root)
  40. tree.write(filename)