Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnthiriet
Created December 1, 2020 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnthiriet/c7400dc69f5f12f1ff50aa65c2537677 to your computer and use it in GitHub Desktop.
Save johnthiriet/c7400dc69f5f12f1ff50aa65c2537677 to your computer and use it in GitHub Desktop.
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