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

Anonymous classes are not shown in jobf file #1350

Closed
yotamN opened this issue Jan 23, 2022 · 6 comments
Closed

Anonymous classes are not shown in jobf file #1350

yotamN opened this issue Jan 23, 2022 · 6 comments
Labels
bug Core Issues in jadx-core module deobfuscation

Comments

@yotamN
Copy link
Contributor

yotamN commented Jan 23, 2022

Classes that were renamed to AnonymousClassX are not shown in the jobf file and it seems there is no way to know they were renamed. Is it the intended behavior or a bug?

It seems that at RenameVisitor.checkClassName change the name without updating the Deobfuscator map file. How should I go about adding it? I guess I should not just simply put the the changed class because there is no such method in the Deobfuscator class

@skylot
Copy link
Owner

skylot commented Jan 23, 2022

@yotamN it is a bug.
Deobfuscator quite messy right now, and looks like many renames are missing, because deobfuscator only used to generate new names and if we use another way to make a new name it will be missing or incorrect. This is a case for user renames and disabled deobfuscator.
I am thinking about more general approach: before saving, collect renames from *Info classes (ClassInfo, MethodInfo, FieldInfo) directly and merge/overwrite already exists map in deobfuscator.

@skylot skylot added bug Core Issues in jadx-core module deobfuscation and removed new feature labels Jan 23, 2022
@yotamN
Copy link
Contributor Author

yotamN commented Jan 23, 2022

I've tried to move the fixClsShortName into the deobfuscator now but I'm not sure I understand the logic in here. Why does it return after using the deobfuscator in line 90 and why does it change the name to anonymous class when the class starts with a digit?

Adding the rename from line 93 to the deobfuscator seems to break the state, it works but throws an exception

@skylot
Copy link
Owner

skylot commented Jan 23, 2022

why does it change the name to anonymous class when the class starts with a digit?

Java identifiers can't start with a digit, also it is a way java compiler name anonymous classes (just numbers)

Why does it return after using the deobfuscator in line 90

Looks like, newShortName variable is null, but next code in method using it, so we just quit.

I've tried to move the fixClsShortName into the deobfuscator

I think this is a bad idea because this method trying to fix invalid names and can work without enabled deobfuscator.
As I suggested before, it is better to process already applied renames at the end of Deobfuscator.fillDeobfPresets() method like this:

		for (ClassNode cls : root.getClasses()) {
			ClassInfo clsInfo = cls.getClassInfo();
			if (clsInfo.hasAlias()) {
				deobfPresets.getClsPresetMap().put(clsInfo.makeRawFullName(), clsInfo.getAliasShortName());
			}
			// TODO: similar for fields and methods
		}

This way, we don't need to worry about missing renames in jobf files.

@yotamN
Copy link
Contributor Author

yotamN commented Jan 23, 2022

it is a way java compiler name anonymous classes (just numbers)

Do you mean just numbers or also classes like 1bc?

Because the app I've been looking at have a lot of classes like the latter and I think they are being misidentified as anonymous classes. Sure it's not a big deal, just wants to make sure this is the intended behavior.

@skylot
Copy link
Owner

skylot commented Jan 23, 2022

Yeah, anonymous class names have only digits, and you are right it may be better to use regex like \d+. But anyway, we need to rename classes started with a digit.

@skylot
Copy link
Owner

skylot commented Jan 23, 2022

Fixed in PR #1353 by @yotamN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module deobfuscation
Projects
None yet
Development

No branches or pull requests

2 participants