Xamarin Android Binding - Deofuscate sample script
$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