-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(script): add example script for resources rename (#2126)
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
jadx-plugins/jadx-script/examples/scripts/deobf/deobf-resources.jadx.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import jadx.api.plugins.options.OptionFlag.PER_PROJECT | ||
|
||
/** | ||
* Custom resources regexp deobfuscator | ||
*/ | ||
|
||
val jadx = getJadxInstance() | ||
|
||
val regexOpt = jadx.options.registerString( | ||
name = "regex", | ||
desc = "Apply resources rename for file names matches regex", | ||
defaultValue = """[Oo0]+\.xml""", | ||
).flags(PER_PROJECT) | ||
|
||
val regex = regexOpt.value.toRegex() | ||
var n = 0 | ||
|
||
jadx.stages.prepare { | ||
for (resFile in jadx.internalDecompiler.resources) { | ||
val fullName = resFile.originalName | ||
val name = fullName.substringAfterLast('/') | ||
if (name matches regex) { | ||
val path = fullName.substringBeforeLast('/') // TODO: path also may be obfuscated | ||
val ext = name.substringAfterLast('.') | ||
val newName = "$path/res-${n++}.$ext" | ||
log.info { "renaming resource: '$fullName' to '$newName'" } | ||
resFile.deobfName = newName | ||
} | ||
} | ||
} | ||
|
||
jadx.afterLoad { | ||
log.info { "Renames count: $n" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2807dc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, do a nightly channel of releases and add github actions (pipelines) for auto build of those releases please if possible as of plugins that might be nice to have is Lauries JADXecute plugin showcased here: https://www.youtube.com/watch?v=g0r3C1iEeBg