From bf6d0bfc55b29f1e98b5e8e4eb00f57c6edfe5dd Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Wed, 9 Mar 2022 22:20:41 +0800 Subject: [PATCH 1/7] Migrate to setup.py and PEP 517 --- pyproject.toml | 68 +++++++++++++++++++++++++++++++++ qltool | 6 ++- setup.cfg | 70 +++++++++++++++++++++++++++++++++ setup.py | 102 ------------------------------------------------- 4 files changed, 143 insertions(+), 103 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..d34f7b769 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[project] +name = "qiling" +version = "1.2.0-dev" +description = "Qiling is an advanced binary emulation framework that cross-platform-architecture" +readme = "README.md" +requires-python = ">=3.8" +license = {file = "COPYING", text = "GPL-2.0-only"} +maintainers = [ + {name = "KaiJern Lau (xwings)", email = "info@qiling.io"} +] +keywords = ["qiling", "binary", "emulator", "framework", "malware", "analysis", "UEFI", "IoT"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + "Programming Language :: Python :: 3" +] + +dependencies = [ + "capstone>=4.0.1", + "unicorn==2.0.0-rc5", + "pefile>=2021.9.3", + "python-registry>=1.3.1", + "keystone-engine>=0.9.2", + "pyelftools>=0.26", + "gevent>=20.9.0", + "multiprocess>=0.70.12.2", + "pyyaml>=6.0", + "windows-curses>=2.1.0; platform_system == 'Windows'" +] + +[project.optional-dependencies] +evm = [ + "blake2b-py>=0.1.2", + "cached-property>=1.5.2; python_version < '3.8'", + "typing-extensions>=3.7.4.3; python_version < '3.8'", + "eth-keys>=0.2.1", + "eth-typing>=2.2.0", + "eth-utils>=1.9.4", + "eth_abi>=2.1.1", + "lru-dict>=1.1.6", + "py-ecc>=1.4.7", + "rlp>=2", + "trie==2.0.0-alpha.5", + "eth-hash[pycryptodome]", + "numpy", + "rich", + "cmd2" +] +fuzz = [ + "aflunicorn>=2.0.0; platform_system != 'Windows'", + "fuzzercorn>=0.0.1; platform_system == 'Linux'" +] + +[project.urls] +homepage = "qiling.io" +documentation = "docs.qiling.io" +epository = "github.com/qilingframework/qiling" +changelog = "github.com/qilingframework/qiling/blob/master/ChangeLog" + +[project.scripts] +qltool = "qltool:main" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + diff --git a/qltool b/qltool index 266dc0ba2..e0f47b654 100755 --- a/qltool +++ b/qltool @@ -165,7 +165,7 @@ def handle_examples(parser: argparse.ArgumentParser): parser.exit(0, __ql_examples) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser() parser.add_argument('--version', action='version', version=f'qltool for Qiling {ql_version}, using Unicorn {unicorn.__version__}') @@ -260,3 +260,7 @@ if __name__ == '__main__': print(report.generate_report(ql, pretty_print=True)) exit(ql.os.exit_code) + + +if __name__ == '__main__': + main() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..b64539c84 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,70 @@ +[metadata] +name = qiling +version = 1.2.0-dev +url = https://qiling.io/ +project_urls = + Documentation = https://docs.qiling.io + Repository = https://github.com/qilingframework/qiling + Changelog = https://github.com/qilingframework/qiling/blob/master/ChangeLog +maintainer = KaiJern Lau (xwings) +maintainer_email = info@qiling.io +classifiers = + Development Status :: 3 - Alpha + Intended Audience :: Developers + Topic :: Software Development :: Build Tools + License :: OSI Approved :: GNU General Public License v2 (GPLv2) + Programming Language :: Python :: 3 +license = GPLv2 +license_file = COPYING +description = Qiling is an advanced binary emulation framework that cross-platform-architecture +long_description = file: README.md +long_description_content_type = text/markdown +keywords= + qiling + binary + emulator + framework + malware + analysis + UEFI + IoT +platforms = any + +[options] +packages = find: +install_requires = + capstone>=4.0.1 + unicorn==2.0.0-rc5 + pefile>=2021.9.3 + python-registry>=1.3.1 + keystone-engine>=0.9.2 + pyelftools>=0.26 + gevent>=20.9.0 + multiprocess>=0.70.12.2 + pyyaml>=6.0 + windows-curses>=2.1.0; platform_system == 'Windows' +python_requires = >=3.8 +scripts = + qltool +include_package_data = True + +[options.extras_require] +evm = + blake2b-py>=0.1.2 + cached-property>=1.5.2; python_version < '3.8' + typing-extensions>=3.7.4.3; python_version < '3.8' + eth-keys>=0.2.1 + eth-typing>=2.2.0 + eth-utils>=1.9.4 + eth_abi>=2.1.1 + lru-dict>=1.1.6 + py-ecc>=1.4.7 + rlp>=2 + trie==2.0.0-alpha.5 + eth-hash[pycryptodome] + numpy + rich + cmd2 +fuzz = + aflunicorn>=2.0.0; platform_system != 'Windows' + fuzzercorn>=0.0.1; platform_system == 'Linux' diff --git a/setup.py b/setup.py deleted file mode 100644 index 398a7fb57..000000000 --- a/setup.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python3 -# -# Python setup for Qiling framework - -import sys, os -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) -gb = {} -with open(os.path.join(here, "qiling", "__version__.py"), "r+") as f: - exec(f.read(), gb) - -VERSION = gb['__version__'] - -requirements = [ - "capstone>=4.0.1", - "unicorn>=2.0.0-rc6", - "pefile>=2021.9.3", - "python-registry>=1.3.1", - "keystone-engine>=0.9.2", - "pyelftools>=0.26", - "gevent>=20.9.0", - "multiprocess>=0.70.12.2", - "pyyaml>=6.0" -] - -extras = { - "evm": [ - "blake2b-py>=0.1.2", - "cached-property>=1.5.2;python_version<'3.8'", - "typing-extensions>=3.7.4.3;python_version<'3.8'", - "eth-keys>=0.2.1", - "eth-typing>=2.2.0", - "eth-utils>=1.9.4", - "eth_abi>=2.1.1", - "lru-dict>=1.1.6", - "py-ecc>=1.4.7", - "rlp>=2", - "trie==2.0.0-alpha.5", - "eth-hash[pycryptodome]", - "numpy", - "rich", - "cmd2" - ], - "fuzz" : [ - - ] -} - -with open("README.md", "r", encoding="utf-8") as ld: - long_description = ld.read() - -if "win32" in sys.platform: - requirements += ["windows-curses>=2.1.0"] - -if "win32" not in sys.platform: - extras["fuzz"] += ["unicornafl>=2.0.0"] - -if "linux" in sys.platform: - extras["fuzz"] += ["fuzzercorn>=0.0.1"] - -setup( - name='qiling', - version=VERSION, - - description='Qiling is an advanced binary emulation framework that cross-platform-architecture', - url='http://qiling.io', - long_description=long_description, - long_description_content_type="text/markdown", - maintainer='KaiJern Lau (xwings)', - maintainer_email='info@qiling.io', - - license='GPLv2', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 5 - Production/Stable - #'Development Status :: 5 - Production/Stable', - 'Development Status :: 3 - Alpha', - - # Indicate who your project is intended for - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Build Tools', - - # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 3', - ], - - keywords='qiling binary emulator framework malware analysis UEFI IoT', - - packages=find_packages(), - scripts=['qltool'], - include_package_data=True, - install_requires=requirements, - extras_require=extras, -) From 95f6345168a6c0349a12f0f3c3ddc9129af4dcca Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Thu, 10 Mar 2022 19:39:00 +0800 Subject: [PATCH 2/7] Fix PyPi publishing workflow --- .github/workflows/pythonpublish.yml | 5 ++--- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index ec800b2a2..daece1c75 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -13,11 +13,10 @@ jobs: python-version: '3.x' - name: Install dependencies run: | - pip install setuptools wheel + pip install setuptools wheel build - name: Build distribution 📦 run: | - pip install . - python setup.py sdist bdist_wheel + python -m build - uses: actions/upload-artifact@v2 with: path: ${{ github.workspace }}/dist/* diff --git a/pyproject.toml b/pyproject.toml index d34f7b769..29d0fefc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,6 @@ changelog = "github.com/qilingframework/qiling/blob/master/ChangeLog" qltool = "qltool:main" [build-system] -requires = ["setuptools"] +requires = ["setuptools>=40.9.0", "wheel"] build-backend = "setuptools.build_meta" From 797b042aa4daca0a0268ea57f2616335983a7f18 Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Sun, 1 May 2022 13:59:30 +0800 Subject: [PATCH 3/7] Fix schema on URLs --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 855f9dc86..ce644be09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,10 +54,10 @@ fuzz = [ ] [project.urls] -homepage = "qiling.io" -documentation = "docs.qiling.io" -epository = "github.com/qilingframework/qiling" -changelog = "github.com/qilingframework/qiling/blob/master/ChangeLog" +homepage = "https://qiling.io" +documentation = "https://docs.qiling.io" +epository = "https://github.com/qilingframework/qiling" +changelog = "https://github.com/qilingframework/qiling/blob/master/ChangeLog" [project.scripts] qltool = "qltool:main" From b2aab1b2872e94e66129ffad623b358dd2861c26 Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Sat, 7 May 2022 16:08:27 +0800 Subject: [PATCH 4/7] Fix typo and required setuptools ver --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ce644be09..5733716f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,13 +56,13 @@ fuzz = [ [project.urls] homepage = "https://qiling.io" documentation = "https://docs.qiling.io" -epository = "https://github.com/qilingframework/qiling" +repository = "https://github.com/qilingframework/qiling" changelog = "https://github.com/qilingframework/qiling/blob/master/ChangeLog" [project.scripts] qltool = "qltool:main" [build-system] -requires = ["setuptools>=40.9.0", "wheel"] +requires = ["setuptools>=61.0.0", "wheel"] build-backend = "setuptools.build_meta" From 683bf43d3776df683707671741d90d2ff6230ab5 Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Sat, 7 May 2022 17:33:35 +0800 Subject: [PATCH 5/7] Remove syspage from MANIFEST.in --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index ead0863c9..3a680e281 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,3 @@ recursive-include qiling/debugger/gdb/xml * recursive-include qiling/extensions/windows_sdk/defs * recursive-include qiling/profiles * include qiling/os/uefi/guids.csv -include qiling/os/qnx/syspage.bin From 7b1d102852133d5061b094e8e901ef113b6f4161 Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Thu, 20 Oct 2022 23:36:46 +0800 Subject: [PATCH 6/7] Stub setup.py, use only pyproject.toml --- pyproject.toml | 5 ++- setup.py | 99 +------------------------------------------------- 2 files changed, 6 insertions(+), 98 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 526b20ee2..636daf174 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,10 @@ dependencies = [ "gevent>=20.9.0", "multiprocess>=0.70.12.2", "windows-curses>=2.1.0;platform_system=='Windows'", - "pyyaml>=6.0" + "pyyaml>=6.0", + "python-fx", + "questionary", + "termcolor" ] [project.optional-dependencies] diff --git a/setup.py b/setup.py index eca31524a..70298919e 100644 --- a/setup.py +++ b/setup.py @@ -2,101 +2,6 @@ # # Python setup for Qiling framework -from setuptools import setup, find_packages +from setuptools import setup -# NOTE: use "-dev" for dev branch -VERSION = "1.4.5" + "-dev" -#VERSION = "1.4.4" - -requirements = [ - "capstone>=4.0.1", - "unicorn>=2.0.0", - "pefile>=2022.5.30", - "python-registry>=1.3.1", - "keystone-engine>=0.9.2", - "pyelftools>=0.28", - "gevent>=20.9.0", - "multiprocess>=0.70.12.2", - "windows-curses>=2.1.0;platform_system=='Windows'", - "pyyaml>=6.0", - "python-fx", - "questionary", - "termcolor", -] - -extras = { - "evm": [ - "blake2b-py>=0.1.2", - "cached-property>=1.5.2;python_version<'3.8'", - "typing-extensions>=3.7.4.3;python_version<'3.8'", - "eth-keys>=0.2.1", - "eth-typing>=2.2.0", - "eth-utils>=1.9.4", - "eth_abi>=2.1.1", - "lru-dict>=1.1.6", - "py-ecc>=1.4.7", - "rlp>=2", - "trie==2.0.0-alpha.5", - "eth-hash[pycryptodome]", - "numpy", - "rich", - "cmd2" - ], - "fuzz" : [ - "unicornafl>=2.0.0;platform_system!='Windows'", - "fuzzercorn>=0.0.1;platform_system=='Linux'" - ], - "RE": [ - "r2libr>=5.7.4", - ] -} - -with open("README.md", "r", encoding="utf-8") as ld: - long_description = ld.read() - -setup( - name='qiling', - version=VERSION, - - description='Qiling is an advanced binary emulation framework that cross-platform-architecture', - url='http://qiling.io', - long_description=long_description, - long_description_content_type="text/markdown", - maintainer='KaiJern Lau (xwings)', - maintainer_email='info@qiling.io', - - license='GPLv2', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 5 - Production/Stable - #'Development Status :: 5 - Production/Stable', - 'Development Status :: 3 - Alpha', - - # Indicate who your project is intended for - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Build Tools', - - # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 3', - ], - - keywords='qiling binary emulator framework malware analysis UEFI IoT', - - packages=find_packages(), - scripts=['qltool'], - package_data={ - 'qiling': ['profiles/*.ql'], - 'qiling.debugger.gdb': ['xml/*/*'], - 'qiling.os.uefi': ['guids.csv'], - 'qiling.arch.evm.analysis': ['signatures.json'] - }, - install_requires=requirements, - extras_require=extras, -) +setup() From 0dcf436c9788be22bbd74277b634c807048346a5 Mon Sep 17 00:00:00 2001 From: nullableVoidPtr <30564701+nullableVoidPtr@users.noreply.github.com> Date: Thu, 20 Oct 2022 23:47:48 +0800 Subject: [PATCH 7/7] Fix unbound report in scope --- qltool | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qltool b/qltool index 5f816789e..ef426cec0 100755 --- a/qltool +++ b/qltool @@ -266,12 +266,12 @@ def main(): ql.run(timeout=options.timeout) if options.json: - report = report.generate_report(ql) + generated_report = report.generate_report(ql) if qltui_enabled: - report["syscalls"] = qltui.transform_syscalls(ql.os.stats.syscalls) - qltui.show_report(ql, report, hook_dictionary) + generated_report["syscalls"] = qltui.transform_syscalls(ql.os.stats.syscalls) + qltui.show_report(ql, generated_report, hook_dictionary) else: - pprint(report) + pprint(generated_report) exit(ql.os.exit_code)