Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add annotations to Java.registerClass #329

Open
realgam3 opened this issue Jul 28, 2024 · 1 comment
Open

[Feature] Add annotations to Java.registerClass #329

realgam3 opened this issue Jul 28, 2024 · 1 comment

Comments

@realgam3
Copy link

realgam3 commented Jul 28, 2024

Here's an example code in java to add Dialog function as JavaScript Interface to a WebView:

public class MainActivity extends AppCompatActivity {
    WebView webView;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = findViewById(R.id.interface_web);
         
        // opening the html file in webview
        webView.loadUrl("file:///android_asset/test.html");
 
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.addJavascriptInterface(this, "Dialog");
    }
 
    @JavascriptInterface
    public void showMsg(String fname, String pswd) {
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        builder.setTitle("Confirmation").setMessage("UserName:\t" + fname + "\nPassword:\t" + pswd)
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(getApplicationContext(), " Data Saved Locally", Toast.LENGTH_SHORT).show();
                        // You can use shared preference or db here to store The Data
                    }
                });
        builder.create().show();
    }
   
}

Everything in this code can be written with frida except using the annotation "@JavascriptInterface",
without the "@JavascriptInterface" annotation the Dialog function will not be available in the WebView...

@5andr0
Copy link

5andr0 commented Oct 22, 2024

Don't expect anyone to work on this. You can try to implement it at mkdex.js + class-factory.js and make a PR. If there's an existing class in your process with this signature I would recommend to hook/modify the functions and create a new instance of it. Alternatively you compile your class to a dex and use a dex class loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants