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

Java As Root , executing a class - Not found error #15

Open
oabukmail opened this issue Jan 16, 2017 · 3 comments
Open

Java As Root , executing a class - Not found error #15

oabukmail opened this issue Jan 16, 2017 · 3 comments

Comments

@oabukmail
Copy link

i finally managed to build the anbuild.dex with AndroidStudio

but when i run the JavaCommand

it outputs ( not found ) , as if its executing the class as string in the command line

Shell shell;
        try {
            shell = RootShell.getShell(true);
            JavaCommand cmd = new JavaCommand(
                    43,
                    false,
                    MainActivity.this,
                    runclass.class.getName()) {

                @Override
                public void commandOutput(int id, String line) {
                    Log.v("aaaaa",line);
                    //visualUpdate(TestHandler.ACTION_DISPLAY, line + "\n");
                    super.commandOutput(id, line);
                }

            };
            shell.add(cmd);
        } catch (Exception e) {
            e.printStackTrace();
        }
@Fusion
Copy link
Collaborator

Fusion commented Jan 17, 2017

Dumb question: do you install the file? Something like...

public class Prepare {
    public static boolean setup(Context context) {
        try {
            InputStream is = context.getAssets().open("anbuild.dex");
            FileOutputStream fos = context.openFileOutput("anbuild.dex", Context.MODE_PRIVATE);
            byte[] buffer = new byte[4096];
            int readCount;
            while(-1 != (readCount = is.read(buffer))) {
                fos.write(buffer, 0, readCount);
            }
            fos.close();
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    return true;
    }
}

Also, what is the output of runclass.class.getName()?

@oabukmail
Copy link
Author

oabukmail commented Jan 17, 2017

i have manually copied the anbuild.dex to res/raw folder

is that enough?

can you explain the code you mentioned ? and should i use it ?

the output of the runclass.class.getName() , is the com.example.test.runclass

after checking the JavaCommand and Command classes , i dont find anything that checks if im executing JavaCommand not a Command , thats why it takes the class name as a command instead of executing it
the JavaCommand Class , only sets the JavaCommand Value to true
and Command class doesn't consider this at all and never use it

after searching the internet , i found an old version of the Command class that has the getCommand method inside the Command Class thatchecking the JavaCommand boolean value if its true , it works something else

here is what and found

public String getCommand() {
        StringBuilder sb = new StringBuilder();

        if(javaCommand) {
            String filePath = context.getFilesDir().getPath();
            for (int i = 0; i < command.length; i+) {

                if(i > 0)
                {
                    sb.append('\n');
                }

                /*
                 * TODO Make withFramework optional for applications
                 * that do not require access to the fw. -CFR
                 */
                sb.append(
                        "dalvikvm -cp "  filePath  "/anbuild.dex"
                        + " com.android.internal.util.WithFramework"
                        + " com.stericson.RootTools.containers.RootClass "
                        + command[i]);
            }
        }
        else {
            for (int i = 0; i < command.length; i+) {
                if(i > 0)
                {
                    sb.append('\n');
                }

                sb.append(command[i]);
            }
        }
        return sb.toString();
    }

while on the real source code on github , the code is

public final String getCommand() {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < command.length; i++) {
            if (i > 0) {
                sb.append('\n');
            }

            sb.append(command[i]);
        }

        return sb.toString();
}

@oabukmail
Copy link
Author

oabukmail commented Jan 18, 2017

can be there an update to make RootClass run perfectly with AndroidStudio ???

also (com.android.internal.util.WithFramework) is not removed from Android M and higher

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