utils.py 879 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from collections import namedtuple
  4. try:
  5. FileNotFoundException = FileNotFoundError
  6. except NameError:
  7. FileNotFoundException = IOError
  8. Format = {
  9. 'text': 0,
  10. 'grep': 1,
  11. 'json': 2
  12. }
  13. Tech = namedtuple('Tech', ['name', 'version'])
  14. class ConnectionException(Exception):
  15. pass
  16. class UpdateInBurpException:
  17. pass
  18. def caseinsensitive_in(element, elist):
  19. """
  20. Given a list and an element, return true if the element is present in the list
  21. in a case-insensitive flavor
  22. """
  23. return element.lower() in map(str.lower, elist)
  24. def dict_from_caseinsensitivedict(cidict):
  25. # This is pretty bad, but in Python2 we don't have CaseInsensitiveDict and with Burp we cannot use requests's implementation
  26. d = {}
  27. for key, value in cidict.items():
  28. d[key.lower()] = (value, key)
  29. return d