unicorn/bindings/python
2024-09-26 19:13:57 +08:00
..
prebuilt Allow dlls to be copied out of prebuilt directory 2016-11-17 20:59:39 -08:00
unicorn Remove pkg-packages 2024-09-26 17:15:53 +08:00
.gdb_history Bump version and generate bindings 2024-09-21 23:00:57 +08:00
build_wheel.sh Remove using of distutils (#1964) 2024-06-12 14:45:23 +08:00
Makefile Fix gen_const 2021-10-26 13:10:59 +02:00
MANIFEST.in Basically, make python builds work as expected 2016-09-12 14:06:20 -07:00
README.md Merge elicn's work 2024-03-08 16:16:12 +08:00
sample_all.sh Include networking auditing sample in script 2024-09-19 17:17:04 +03:00
sample_arm64.py Update sample for MRS hook 2022-02-27 15:28:32 +01:00
sample_arm64eb.py Fix Python 3 samples (#836) 2017-05-15 09:11:22 +08:00
sample_arm.py Implement coprocessor register read/write for python bindings 2022-02-11 23:03:56 +01:00
sample_armeb.py update armeb & arm64eb samples 2017-04-25 12:55:26 +08:00
sample_ctl.py Fix TCG opcode hook prototype 2023-07-14 00:42:40 +03:00
sample_m68k.py make cleanup 2016-11-06 16:27:24 -08:00
sample_mips.py make cleanup 2016-11-06 16:27:24 -08:00
sample_network_auditing.py Get Python samples running on Python 3 2016-07-29 00:28:43 -07:00
sample_ppc.py import Unicorn2 2021-10-03 22:14:44 +08:00
sample_riscv.py import Unicorn2 2021-10-03 22:14:44 +08:00
sample_s390x.py python: add some more comments for samples 2022-10-31 12:37:18 +08:00
sample_sparc.py make cleanup 2016-11-06 16:27:24 -08:00
sample_tricore.py TriCore Support (#1568) 2022-04-29 23:11:34 +02:00
sample_x86.py remove semicolons 2024-03-06 02:15:02 -05:00
setup.cfg Fixes to make python distribution for windows work 2016-11-05 09:18:50 -07:00
setup.py Still add plat-name for Linux 2024-09-26 19:11:53 +08:00
shellcode.py remove semicolons 2024-03-06 02:15:02 -05:00

Python Bindings for Unicorn

Originally written by Nguyen Anh Quynh, polished and redesigned by elicn, maintained by all community contributors.

Install

Install a prebuilt wheel from PyPI:

pip3 install unicorn

In case you would like to develop the bindings:

# Python3
DEBUG=1 THREADS=4 pip3 install --user -e .
# Workaround for Pylance
DEBUG=1 THREADS=4 pip3 install --user -e . --config-settings editable_mode=strict
# Python2
DEBUG=1 THREADS=4 pip install -e .

or install it by building it by yourself:

# Python3
THREADS=4 pip3 install --user .
# Python2, unfortunately `pip2` doesn't support in-tree build
THREADS=4 python3 setup.py install

Explanations for arguments:

  • THREADS=4 will use 4 threads for building.
  • DEBUG=1 will build debug version of unicorn.
  • --user will install the bindings to your user directory instead of requiring root permission.
  • -e infers the editable mode, which gives your instant feedback instead of re-compiling every time.

Note that you should setup a valid building environment according to docs/COMPILE.md but not necessarily build it because setup.py will do this for you.

Python2 compatibility

By default, Unicorn python bindings will be maintained against Python3 as it offers more powerful features which improves developing efficiency. Meanwhile, Unicorn will only keep compatible with all features Unicorn1 offers regarding Python2 because Python2 has reached end-of-life for more than 3 years as the time of writing this README. While offering all features for both Python2 & Python3 is desirable and doable, it inevitably costs too much efforts to maintain and few users really rely on this. Therefore, we assume that if users still stick to Python2, previous Unicorn1 features we offer should be enough. If you really want some new features Unicorn2 offers, please check and pull request to `unicorn/unicorn_py2``. We are happy to review and accept!