-
-
Save johnthiriet/c7400dc69f5f12f1ff50aa65c2537677 to your computer and use it in GitHub Desktop.
Xamarin Android Binding - Deofuscate sample script
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
$cwdir = "/PathTo/jd-cli" | |
$aar = "/PathTo/base.aar" | |
Set-Location $cwdir | |
Remove-Item "tmp" -Recurse -ErrorAction Ignore | |
# Extract jar | |
./jd-cli "-ods tmp -oc $aar" | |
Get-ChildItem -recurse -filter "classes.jar" -File | Where-Object { | |
./jd-cli "-ods tmp -oc $($_.FullName)" | |
} | |
Get-ChildItem -Path "tmp/classes.jar" -Recurse -File | | |
Where-Object { $_.Extension -eq ".java" } | | |
Where-Object { $_.Name.Length -eq 6 } | | |
Where-Object { | |
$file = $_ | |
$module = $file.FullName | |
$indx = $module.IndexOf("classes.jar/") | |
$module = $module.Substring($indx + "classes.jar/".Length, $module.Length - $indx - "classes.jar/".Length) | |
$module = $module.Substring(0, $module.LastIndexOf("/")).Replace("/", ".") | |
@("interface", "class", "enum") | ForEach-Object { | |
$type = $_ | |
Select-String -Path $file.FullName -Pattern "\s+($type)\s+([a-zA-Z0-9]+)\s+.*" -AllMatches | ForEach-Object { | |
$_.Matches | Foreach-Object { | |
if ($type -eq "enum") { $type = "class" } | |
$name = $_.Groups[2].Value | |
$attr = '<attr path="/api/package[@name=''' + $module + ''']/' + $type + '[@name=''' + $name + ''']" name="obfuscated">false</attr>' | |
$attr >> result.txt | |
} | |
} | |
} | |
} | |
Remove-Item "tmp" -Recurse -ErrorAction Ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment