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

Support for methods that calls getString inside of them using parameters #19

Open
giacomoferretti opened this issue Feb 17, 2025 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed out of scope

Comments

@giacomoferretti
Copy link
Owner

Currently, paranoid-deobfuscator doesn't support methods that call getString using their parameters. We don't keep track of methods, we only deobfuscate direct calls to getString that don't use parameters but values.

A clear example:

public static String a(long j) {
    return DeobfuscatorHelper.getString(j);
}

See #18 for samples

@giacomoferretti giacomoferretti added bug Something isn't working help wanted Extra attention is needed enhancement New feature or request and removed bug Something isn't working labels Feb 17, 2025
@giacomoferretti
Copy link
Owner Author

This is WAY out of scope for me. It would mean to implement a somewhat JVM emulator in Python.

Let's take this for example:

public static String obfuscateMore(long j) {
    return DeobfuscatorHelper.getString(j*4);
}
.method public static obfuscateMore(J)Ljava/lang/String;
    .registers 4

    const-wide/16 v0, 0x4

    mul-long p0, p0, v0

    invoke-static {p0, p1}, LHello;->getString(J)Ljava/lang/String;

    move-result-object p0

    return-object p0
.end method

We cannot know what the function will do before invoking "getString". If someone need custom functionality, please fork the repo and implement it case-by-case.

@giacomoferretti
Copy link
Owner Author

It should change method signatures too.

Another example of expected result:

Input

public final class b extends Activity {
    public static String callStack1(String str, long j) {
        return callStack2(j, str);
    }

    public static String callStack2(long j, String str) {
        return callStack3(j);
    }

    public static String callStack3(long j) {
        return oneParam(j);
    }

    public static String oneParam(long j) {
        return a.a(j);
    }

    public static void recursive(long j, long j2) {
        a.recursive(j, j2);
        String a = a.a(j);
        String a2 = a.a(j2);
        PrintStream printStream = System.out;
        printStream.println((Object) a);
        printStream.println((Object) a2);
    }

    public static String twoParams(long j, long j2) {
        return a.a(j2);
    }

    @Override // android.app.Activity
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        PrintStream printStream = System.out;
        printStream.println((Object) oneParam(0L));
        printStream.println((Object) oneParam(133143986176L));
        printStream.println((Object) twoParams(3735928559L, 0L));
        printStream.println((Object) twoParams(3735928559L, 133143986176L));
        recursive(0L, 133143986176L);
        printStream.println((Object) callStack1("Call Stack", 0L));
    }
}

Output

public final class b extends Activity {
    public static String callStack1(String str, String str2) {
        return callStack2(str2, str);
    }

    public static String callStack2(String str, String str2) {
        return callStack3(str);
    }

    public static String callStack3(String str) {
        return oneParam(str);
    }

    public static String oneParam(String str) {
        return str;
    }

    public static void recursive(String str, String str2) {
        a.recursive(str, str2);
        String a = str;
        String a2 = str2;
        PrintStream printStream = System.out;
        printStream.println((Object) a);
        printStream.println((Object) a2);
    }

    public static String twoParams(long j, String str) {
        return str;
    }

    @Override // android.app.Activity
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        PrintStream printStream = System.out;
        printStream.println((Object) oneParam("HARDCODED_SUPER_SECRET_API_KEY"));
        printStream.println((Object) oneParam("https://secret.example.org/"));
        printStream.println((Object) twoParams(3735928559L, "HARDCODED_SUPER_SECRET_API_KEY"));
        printStream.println((Object) twoParams(3735928559L, "https://secret.example.org/"));
        recursive("HARDCODED_SUPER_SECRET_API_KEY", "https://secret.example.org/");
        printStream.println((Object) callStack1("Call Stack", "HARDCODED_SUPER_SECRET_API_KEY"));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed out of scope
Projects
None yet
Development

No branches or pull requests

1 participant