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

use source filename to rename obfuscated class name #281

Closed
linsmod opened this issue May 18, 2018 · 19 comments
Closed

use source filename to rename obfuscated class name #281

linsmod opened this issue May 18, 2018 · 19 comments

Comments

@linsmod
Copy link

linsmod commented May 18, 2018

meet some obfuscated app, the extracted class name and its file name are not friendly

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/* compiled from: MonConfig */
public class c {
}

wish a feature it can use the source file name to rename the obfuscated class name.

the we get

public class MonConfig{
}

if multi-class defined in one file, append something like $+number,

MonConfig$1 MonConfig$2 ...

then update package statement and import statement and calls
update output file name when export

@skylot
Copy link
Owner

skylot commented May 18, 2018

This feature already exists, in latest unstable build go to preferences and enable "Use source file name as class name alias":
image
By default it is disabled because source file often contains garbage or same filename for many classes and jadx still don't have enough checks to always generate correct code.

@skylot skylot closed this as completed May 18, 2018
@linsmod
Copy link
Author

linsmod commented May 18, 2018

yes, i remembered that, the option is checked sine yesterday, but it's not working. the same as 0.7.2-unstable, i tried again just now, switch off and switch on, still.

@linsmod
Copy link
Author

linsmod commented May 18, 2018

tim 20180518162533

@skylot
Copy link
Owner

skylot commented May 18, 2018

I see. Can you share this apk? I will investigate this issue. Thank you!

@skylot skylot reopened this May 18, 2018
@linsmod
Copy link
Author

linsmod commented May 18, 2018

uploading, wait.

@linsmod
Copy link
Author

linsmod commented May 18, 2018

@skylot
Copy link
Owner

skylot commented May 18, 2018

Oh! I didn't notice, sorry. You need to enable deobfuscation to use this feature, because it is a part of renaming procedure.
I will fix preferences dialog and these options will be grayed if deobfuscation is not enabled.
image

@linsmod
Copy link
Author

linsmod commented May 18, 2018

but ...
image

@linsmod
Copy link
Author

linsmod commented May 18, 2018

image

@linsmod
Copy link
Author

linsmod commented May 18, 2018

does this infomation helps?

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

@skylot
Copy link
Owner

skylot commented May 18, 2018

@kissstudio Ok, I can reproduce your issue.
In short: also enable Force rewrite deobfuscation map file option.
Some details: jadx creates apk_name.jobf file near apk file with last name mapping, so you can edit it by hand if you want. And next time jadx use these mapping and discards source file options. To disable loading mapping from file you can remove this file or use force option.

This is very complex combination of files and options and it must be somehow simplified, but I don't know yet how to do it. For now I can disable options if obfuscation not used and remove jobf file if parameters changed.

@linsmod
Copy link
Author

linsmod commented May 18, 2018

got that, i deleted the map file and its works, but the subclass names obfuscated is unchanged, can you please make it more friendly as i said above? when referenced by other calls, its not easy to understand what it be... ^^

@linsmod
Copy link
Author

linsmod commented May 18, 2018

only prefix the obfuscated subclass using the main class name maybe an another choice. display like
public class NetSyncTask_C04221{ }

@linsmod
Copy link
Author

linsmod commented May 18, 2018

i'd like to suggest using className+$+subClassName,
and using renamedClassName+$+renamedSubClassName when the RENAME option is on.

@korroktheslavemaster
Copy link

screenshot from 2018-05-22 12-58-27
Hi, I followed the instructions about obfuscation settings and deleted the .jobf file. I'm getting some files renamed, but most others are still their obfuscated names. Would appreciate if you would help out! I've attached screenshot of my settings. The apk can be found here: https://apkpure.com/irctc-connect/com.irctc.main

@skylot
Copy link
Owner

skylot commented May 22, 2018

@korroktheslavemaster there are another options in deobfuscation block which are not well documented: minimum and maximum name length. These option determine the range when name (class name, method name, etc) must be renamed (deobfuscated) or not.
For now renaming executed if nameLength < minLength or nameLength > maxLength.
So if you wanted to rename "bs" you need to increase minimum length:
image
Maybe jadx default value must be changed, because renaming only one character names is not very usefull.

@linsmod
Copy link
Author

linsmod commented May 22, 2018

length limitation should only be applied when source file name not exists

@korroktheslavemaster
Copy link

Thanks

@bagipro
Copy link
Collaborator

bagipro commented Apr 29, 2020

Seems to be fixed

@bagipro bagipro closed this as completed Apr 29, 2020
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

4 participants