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

Fixes #61, and other improvements. #68

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ItsIgnacioPortal
Copy link

@ItsIgnacioPortal ItsIgnacioPortal commented Jun 4, 2022

When installing apkleaks from PyPi on Windows, jadx.bat was installed in the path C:\Program Files\Python39\Lib\site-packages\jadx\bin\jadx.bat. This caused #61, because apkleaks was trying to run C:/Program Files/Python39/Lib/site-packages/jadx/bin/jadx.bat Aurora.Droid.ver.1.0.8.build.8.apk -d C:\Users\REDACTED\AppData\Local\Temp\apkleaks-t996o3tz without quoting the jadx.bat path.

@ItsIgnacioPortal ItsIgnacioPortal changed the title Fixes #61, and makes it so we pass the file parameter as an absolute path to the command. Fixes #61, and other improvements. Jun 4, 2022
apkleaks/apkleaks.py Outdated Show resolved Hide resolved
apkleaks/apkleaks.py Outdated Show resolved Hide resolved
apkleaks/apkleaks.py Show resolved Hide resolved
apkleaks/apkleaks.py Show resolved Hide resolved
Comment on lines +94 to +119

#If the path contains a space..
#This is the case if apkleaks was installed on windows through PyPi, as apkleaks.exe ends up in the path "C:/Program Files/Python39/Lib/site-packages/jadx/bin/jadx.bat" (in this example, under python39)
#On windows, if an executable's path doesn't contain spaces but is it quoted anyway, the command fails. We must only quote the path if it has spaces.
if(self.jadx.__contains__(" ")):
args = ["\"" + self.jadx + "\"", self.file, "-d", self.tempdir]
else:
args = [self.jadx, self.file, "-d", self.tempdir]


try:
args.extend(re.split(r"\s|=", self.disarg))
except Exception:
pass

#add single quotes to every parameter
comm = "%s" % (" ".join(quote(arg) for arg in args))

#jadix.bat doesn't like single quotes. Replace them with double quotes
comm = comm.replace("\'","\"")

#If the path to jadx contains a space
if(self.jadx.__contains__(" ")):
#eliminate duplicate quotes
comm = comm.replace("\"\"","\"")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this can be reworked cleaner & less typing using pathlib module and apply it to both JADX and APK file paths.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do realize it's a very sloppy way of doing it. I didn't want to completely refactor the logic you put in place, mostly because I didn't know what issues that could cause down the line. For example, I don't understand what the porpuse of this codeblock is:

try:
	args.extend(re.split(r"\s|=", self.disarg))
except Exception:
	pass

So I decided to just keep it and instead modify as little as possible to make this work.

You can refactor it if you want, but I'm satisfied with it as it is. decompile() is called a single time during the execution of apkleaks, so performance doesn't really matter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'C:/Program' is not recognized as an internal or external command, operable program or batch file.
2 participants