linkedin / qark

Tool to look for several security related Android application vulnerabilities
Other
3.19k stars 643 forks source link

Not able to decompile selected apk #320

Open devkenante opened 5 years ago

devkenante commented 5 years ago

Hi i have been facing this issue with the multiple apk which is in my local computer drives. The parsing get started with below command in cmd

qark --apk my_app_path.apk

but after running for say 60-90 sec it not work and hangs completely.

and on aborting manually it gives Error running fernflower I have installed all the perquisite required for executing qark. please help me for resolving this issue and proceed further.

Platform Windows 10 ,Python 2.7.13 pip is upgraded to 19. In case you want anything please let me know.

After two days i got below error

Failed to extract fernflower jar with command 'jar xf app-release.jar'
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\qark\decompiler\decompiler.py", line 294, in unpack_fernflower_jar
    retcode = subprocess.call(command)
  File "c:\python27\lib\subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "c:\python27\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "c:\python27\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
ranvijay-sachan commented 5 years ago

Getting same error.

andresriancho commented 4 years ago

Workaround:

diff --git a/qark/decompiler/external_decompiler.py b/qark/decompiler/external_decompiler.py
index 47d6a27..44e26f6 100644
--- a/qark/decompiler/external_decompiler.py
+++ b/qark/decompiler/external_decompiler.py
@@ -40,4 +40,5 @@ class Fernflower(ExternalDecompiler):
                                     command="java -jar {path_to_decompiler} -ren=1 {jar} {build_directory}/fernflower")

-DECOMPILERS = (CFR(), Procyon(), Fernflower())
+# DECOMPILERS = (CFR(), Procyon(), Fernflower())
+DECOMPILERS = (CFR(), Procyon())

The qark report is generated, and findings are there. Not exactly sure how this workaround impacts the overall process.

Joeyn414 commented 4 years ago

Did this get pushed to the official repo? Because I am still having an issue where the program hangs after about a minute, I then kill the process and it prints the error "Error running fernflower". I am running this against an apk file on my local mac in virtualenv.

Here are a few more lines above this error: `INFO: Decompiling class com/google/android/gms/measurement/internal/zzjv

INFO: ... done

INFO: Decompiling class com/google/android/gms/measurement/internal/zzjz

INFO: ... done

INFO: Decompiling class com/google/android/gms/measurement/internal/zzke

WARN: Heavily obfuscated exception ranges found!

WARN: Heavily obfuscated exception ranges found!

WARN: Heavily obfuscated exception ranges found!

WARN: Heavily obfuscated exception ranges found!

^CError running fernflower`

1110001 commented 4 years ago

I too getting the same error. Tried with a number of apk files and all got stuck while decompiling. While aborting, it shows Error running fernflower. Using Ubuntu 18.04, Python 2.7.17, pip 20.0.2

ranvijay-sachan commented 4 years ago

Qark Installation Refer to the github link to install qark. https://github.com/linkedin/qark (Install with requirement.txt) ~ git clone https://github.com/linkedin/qark ~ cd qark ~ pip install -r requirements.txt ~ pip install . ~ qark --help

I case of error: can't copy 'qark/lib/dex2jar-2.0/lib': doesn't exist or not a regular file If getting above error in the time of installation, please follow below steps: ~ cd /qark/qark/lib ~ mv dex2jar-2.0 /home/ ~ pip install . ~ cp -r /home/dex2jar-2.0 /usr/local/lib/python2.7/dist-packages/qark/lib/

Note: Tested with qark version 4.0.0 and python 2.7.12, Please use latest version for better vulnerabilities.

slreynolds commented 4 years ago

Another workaround would be to limit the maximum processing time for fernflower. This can be done with the -mpm parameter, see the fernflower docu.

Here is a diff:

diff --git a/qark/decompiler/external_decompiler.py b/qark/decompiler/external_decompiler.py
index 47d6a27..14a079a 100644
--- a/qark/decompiler/external_decompiler.py
+++ b/qark/decompiler/external_decompiler.py
@@ -37,7 +37,7 @@ class Fernflower(ExternalDecompiler):
                                     name="fernflower",
                                     path_to_decompiler=os.path.join(PATH_TO_DECOMPILERS,
                                                                     "fernflower.jar"),
-                                    command="java -jar {path_to_decompiler} -ren=1 {jar} {build_directory}/fernflower")
+                                    command="java -jar {path_to_decompiler} -mpm=30 -ren=1 {jar} {build_directory}/fernflower")

 DECOMPILERS = (CFR(), Procyon(), Fernflower())