安装qark
后执行qark --help
出现下面的错误
% qark --help
Traceback (most recent call last):
File "/Users/user/Library/Python/3.10/bin/qark", line 5, in <module>
from qark.qark import cli
File "/Users/user/Library/Python/3.10/lib/python/site-packages/qark/qark.py", line 13, in <module>
from qark.report import Report
File "/Users/user/Library/Python/3.10/lib/python/site-packages/qark/report.py", line 5, in <module>
from jinja2 import Environment, PackageLoader, select_autoescape, Template
File "/opt/homebrew/lib/python3.10/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/opt/homebrew/lib/python3.10/site-packages/jinja2/environment.py", line 16, in <module>
from jinja2.defaults import BLOCK_START_STRING, \
File "/opt/homebrew/lib/python3.10/site-packages/jinja2/defaults.py", line 32, in <module>
from jinja2.tests import TESTS as DEFAULT_TESTS
File "/opt/homebrew/lib/python3.10/site-packages/jinja2/tests.py", line 13, in <module>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)
原因分析:无法从collections
导入 'Mapping
,因为Python3.10版本以后对requests 库进行调整,collections
中不能直接调用方法Mapping
,MutableMapping
解决办法就是:找到引用collections
模块的__init__.py
文件或其他py文件,调整从abc
导入:
# 将这两句
from collections import Mapping
from collections import MutableMapping
# 替换为以下两句
from collections.abc import Mapping
from collections.abc import MutableMapping
# 即用collections.abc代替collections调用方法Mapping、MutableMapping
写了个命令批量替换,注意改下自己site-packages
的路径,
find /opt/homebrew/lib/python3.10/site-packages/ -name "*.py"| xargs grep "from collections import Mapping" | awk -F : '{ print $1 }' | xargs sed -i "" 's/from collections import Mapping/from collections.abc import Mapping/g'
find /usr/lib/python3.10/site-packages/ -name "*.py"| xargs grep "from collections import Mapping" | awk -F : '{ print $1 }' | xargs sed -i 's/from collections import Mapping/from collections.abc import Mapping/g'
unix与linux在执行sed指令时有些区别,
-i
指令后面多加一个""
空白符即可
替换后就能用qark
了
% qark --help
Usage: qark [OPTIONS]
Options:
--sdk-path DIRECTORY Path to the downloaded SDK directory if
already downloaded. Only necessary if
--exploit-apk is passed. If --exploit-apk is
passed and this flag is not passed,QARK will
attempt to use the ANDROID_SDK_HOME,
ANDROID_HOME, ANDROID_SDK_ROOT environment
variables (in that order) for a path.
--build-path DIRECTORY Path to place decompiled files and exploit
APK. [default: build]
--debug / --no-debug Show debugging statements (helpful for
issues). [default: False]
--apk PATH APK to decompile and run static analysis. If
passed, the --java option is not used.
--java PATH A directory containing Java code, or a Java
file, to run static analysis. If passed,the
--apk option is not used.
--report-type [html|xml|json|csv]
Type of report to generate along with
terminal output. [default: html]
--exploit-apk / --no-exploit-apk
Create an exploit APK targetting a few
vulnerabilities. [default: False]
--version Show the version and exit.
--help Show this message and exit.