Skip to content

Instantly share code, notes, and snippets.

@Fuzion24
Created November 14, 2014 05:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuzion24/272949505d58ee4cc3da to your computer and use it in GitHub Desktop.
Save Fuzion24/272949505d58ee4cc3da to your computer and use it in GitHub Desktop.

Android 5.0

I/chromium( 6890): [INFO:CONSOLE(37)] "AddJavascriptInterface: top[Android]: com.WebAppInterface@3847a08c - 
error: Access to java.lang.Object.getClass is blocked", source: http://[REDACTED].com/ (37)

For applications targeting Android >= 5.0, you can enumerate the methods available from inside javascript. "Enumeration of methods will be enabled for applications targeting API levels newer than KitKat (to preserve compatibility with older apps)."

Our Java bridge object:

    @JavascriptInterface
    public void showToast(String toast) {
        Toast.makeText(mContext, toast, Toast.LENGTH_LONG).show();
    }

    @JavascriptInterface
    public void exposedFunction(){
    }

    public void nonExposedFunction(){}

Our javascript:

try {
  var x  =  Object.keys(Android).toString();
  log(x);
} catch(e){
  log(e.message);
}

Now we can see the enumeration of the annotated objects being logged:

I/chromium( 9833): [INFO:CONSOLE(37)] 
"AddJavascriptInterface: exposedFunction,showToast", source: http://[REDACTED].com/ (37)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment