Triton

JonathanSalwanApache-2.0活跃维护

Triton 是一个动态二进制分析库,提供指令语义提升、符号执行和污点分析能力,用来搭建逆向工程与软件验证工具。

Triton is a dynamic binary analysis library. Build your own program analysis tools, automate your reverse engineering, perform software verification or just emulate code.

v0.9发布于 2022-02-09 10:16 UTC4,364star +3 / 7 天599fork同步于 2026-11-10 17:39 UTC

怎么上手

由 README 提炼,执行前请确认
pip install triton-library
硬件要求按 README 说明

README 未说明硬件要求,未提及显存或 GPU;从源码编译依赖 libcapstone >= 5.0.x,libboost、libpython、libz3、libbitwuzla、llvm 均为可选依赖

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

动态二进制分析库,可构建符号执行、污点分析与代码模拟等程序分析工具

Triton 是一个动态二进制分析库,提供指令语义提升、符号执行和污点分析能力,用来搭建逆向工程与软件验证工具。

核心能力

  • 支持动态符号执行与动态污点分析
  • 为 x86、x86-64、ARM32、AArch64、RISC-V 32/64 指令集生成 AST 语义表示
  • 提供表达式合成与 SMT 化简 pass
  • 支持向 LLVM、Z3 双向 lifting
  • 内置 Z3 与 Bitwuzla 的 SMT solver 接口,提供 C++ 与 Python API

容易踩的坑

从源码编译默认不启用 LLVM 和 Bitwuzla 接口,需要额外加 -DLLVM_INTERFACE=ON -DBITWUZLA_INTERFACE=ON 才能用完整功能;MacOS M1 上可能报找不到 PythonLibs,需手动指定 PYTHON_EXECUTABLE、PYTHON_LIBRARIES、PYTHON_INCLUDE_DIRS;Python 自动补全需先运行脚本生成 triton.pyi 并放到共享库同目录

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.9
  1. v0.9Version 0.9最新正式版2022-02-09 · 2022-02-09 10:16 UTC

    We are glad to announce the release of Triton v0.9 which brings several features:

    • Better dealing with path constraints
    • Lifting To SMT file
    • Lifting to Python file
    • Lifting to LLVM file
    • Lifting to LLVM IR and back
    • Python from 3.6 to 3.9 comparability
    • Add new AST optimizations
    • Add new instructions
    • Add FPU specification
    • Add support for Thumb IT instructions
    • Add the Bitwuzla solver interface
    • Add a synthesis expression engine
    • Fix semantics
    • Fix optimizations
    • And so many more
  2. v0.8.1Version 0.8.12020-04-27 · 2020-04-27 10:03 UTC
    查看更新说明

    This release is based on the v0.8 and only contains the regression patch (72cf02b931c2352a47cb0e8ddb291b60a2e66d5b) related to the ALIGNED_MEMORY optimization issue (see #889).

  3. v0.8Version 0.82020-04-23 · 2020-04-23 12:46 UTC
    查看更新说明

    We are glad to announce the release of Triton v0.8 which brings the ARM32 architecture and much more! All fixes and improvements can be found here and a blog post describing what's new in the v0.8 has been released.

  4. v0.7Version 0.72019-10-01 · 2019-10-01 11:57 UTC
    查看更新说明

    This version is a big step forward for the project. Below some improvements which have been made:

    • AArch64 support (more than 100 instructions supported)
    • Android support
    • Python 3.6 support
    • Fix some of bugs
    • Capstone 3.0.x and 4.0.x support
    • Fix some memory leaks
    • Shortcut access to a Register over the C++ API (#767)
    • Allow users to set alias on a symbolic variable (#763)
    • Provide a visitor feature in order to looking specific nodes in a tree (#711)
    • iff SMT node support (#571)

    All updates can be found here.

  5. v0.6Version 0.62018-11-12 · 2018-11-12 10:35 UTC
    查看更新说明

    Version 0.6 provides new features, fixes and big improvements in term of design compared to 0.5. The full list and details of these changes can be found in the the Github issues interface. Version 0.6 has been pushed in order to prepare a new version (0.7) which will focus on AArch64 support already in development.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Triton is a dynamic binary analysis library. It provides internal components that allow you to build your program analysis tools, automate reverse engineering, perform software verification or just emulate code.

    • Dynamic symbolic execution
    • Dynamic taint analysis
    • AST representation of the x86, x86-64, ARM32, AArch64 and RISC-V 32/64 ISA semantic
    • Expressions synthesis
    • SMT simplification passes
    • Lifting to LLVM as well as Z3 and back
    • SMT solver interface to Z3 and Bitwuzla
    • C++ and Python API

    As Triton is a kind of a part-time project, please, don't blame us if it is not fully reliable. Open issues or pull requests are always better than trolling =). However, you can follow the development on twitter @qb_triton.

    Quick start

    Getting started

    from triton import *
    
    >>> # Create the Triton context with a defined architecture
    >>> ctx = TritonContext(ARCH.X86_64)
    
    >>> # Define concrete values (optional)
    >>> ctx.setConcreteRegisterValue(ctx.registers.rip, 0x40000)
    
    >>> # Symbolize data (optional)
    >>> ctx.symbolizeRegister(ctx.registers.rax, 'my_rax')
    
    >>> # Execute instructions
    >>> ctx.processing(Instruction(b"\x48\x35\x34\x12\x00\x00")) # xor rax, 0x1234
    >>> ctx.processing(Instruction(b"\x48\x89\xc1")) # mov rcx, rax
    
    >>> # Get the symbolic expression
    >>> rcx_expr = ctx.getSymbolicRegister(ctx.registers.rcx)
    >>> print(rcx_expr)
    (define-fun ref!8 () (_ BitVec 64) ref!1) ; MOV operation - 0x40006: mov rcx, rax
    
    >>> # Solve constraint
    >>> ctx.getModel(rcx_expr.getAst() == 0xdead)
    {0: my_rax:64 = 0xcc99}
    
    >>> # 0xcc99 XOR 0x1234 is indeed equal to 0xdead
    >>> hex(0xcc99 ^ 0x1234)
    '0xdead'
    

    Install using pip

    Triton can be installed using pip:

    pip install triton-library
    

    Install from source

    Triton relies on the following dependencies:

    * libcapstone                >= 5.0.x   https://github.com/capstone-engine/capstone
    * libboost      (optional)   >= 1.68
    * libpython     (optional)   >= 3.6
    * libz3         (optional)   >= 4.6.0   https://github.com/Z3Prover/z3
    * libbitwuzla   (optional)   >= 0.4.x   https://github.com/bitwuzla/bitwuzla
    * llvm          (optional)   >= 12
    

    Linux and MacOS

    $ git clone https://github.com/JonathanSalwan/Triton
    $ cd Triton
    $ mkdir build ; cd build
    $ cmake ..
    $ make -j3
    $ sudo make install
    

    By default, LLVM and Bitwuzla are not compiled. If you want to enjoy the full power of Triton, the cmake compile is:

    $ cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH=$(llvm-config --prefix) -DBITWUZLA_INTERFACE=ON ..
    
    MacOS M1 Note:

    In case if you get compilation errors like:

    Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
    

    Try to specify PYTHON_EXECUTABLE, PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS for your specific Python version:

    cmake -DCMAKE_INSTALL_PREFIX=/opt/homebrew/ \
          -DPYTHON_EXECUTABLE=/opt/homebrew/bin/python3 \
          -DPYTHON_LIBRARIES=/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib \
          -DPYTHON_INCLUDE_DIRS=/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10/ \
          ..
    

    This information you can get out from this snippet:

    from sysconfig import get_paths
    info = get_paths()
    print(info)
    
    Python Autocompletion

    If Python autocompletion is not working, follow these steps:

    1. Execute the script
    2. Place the generated triton.pyi file in the same directory as the Triton shared object you want to provide hints for (for example, /usr/lib/python3.13/).

    Your IDE must support parsing .pyi files.

    Windows

    You can use cmake to generate the .sln file of libTriton.

    > git clone https://github.com/JonathanSalwan/Triton.git
    > cd Triton
    > mkdir build
    > cd build
    > cmake -G "Visual Studio 14 2015 Win64" \
      -DBOOST_ROOT="C:/Users/jonathan/Works/Tools/boost_1_61_0" \
      -DPYTHON_INCLUDE_DIRS="C:/Python36/include" \
      -DPYTHON_LIBRARIES="C:/Python36/libs/python36.lib" \
      -DZ3_INCLUDE_DIRS="C:/Users/jonathan/Works/Tools/z3-4.6.0-x64-win/include" \
      -DZ3_LIBRARIES="C:/Users/jonathan/Works/Tools/z3-4.6.0-x64-win/bin/libz3.lib" \
      -DCAPSTONE_INCLUDE_DIRS="C:/Users/jonathan/Works/Tools/capstone-5.0.1-win64/include" \
      -DCAPSTONE_LIBRARIES="C:/Users/jonathan/Works/Tools/capstone-5.0.1-win64/capstone.lib" ..
    

    You can use setup.py to generate the debug version of triton.pyd on Windows.

    > git clone https://github.com/JonathanSalwan/Triton.git
    > cd Triton
    > $env:COMPILER_DIR="C:/deps/llvm/llvm2116r/bin"
    > $env:CMAKE_PREFIX_PATH="C:/deps/llvm/llvm-project-21.1.6.src/install/lib/cmake/llvm;C:/code/cxx-common-cmake/build/install"
    > python_d -m build --wheel
    > python_d -m pip install (Get-ChildItem .\dist\triton_library*)
    
    

    However, if you prefer to directly download the precompiled library, check out our AppVeyor's artefacts. Note that if you use AppVeyor's artefacts, you probably have to install the Visual C++ Redistributable packages for Visual Studio 2012.

    Installing from vcpkg

    The Triton port in vcpkg is kept up to date by Microsoft team members and community contributors. The url of vcpkg is: https://github.com/Microsoft/vcpkg. You can download and install Triton using the vcpkg dependency manager:

    $ git clone https://github.com/Microsoft/vcpkg.git
    $ cd vcpkg
    $ ./bootstrap-vcpkg.sh  # ./bootstrap-vcpkg.bat for Windows
    $ ./vcpkg integrate install
    $ ./vcpkg install triton
    

    If the version is out of date, please create an issue or pull request on the vcpkg repository.

    Contributors

    They already used Triton

    Tools

    • Exrop: Automatic ROPChain Generation.
    • Pimp: Triton based R2 plugin for concolic execution and total control.
    • Ponce: IDA 2016 plugin contest winner! Symbolic Execution just one-click away!
    • QSynthesis: Greybox Synthesizer geared for deobfuscation of assembly instructions.
    • TritonDSE: Triton-based DSE library with loading and exploration capabilities.
    • Titan: Titan is a VMProtect devirtualizer using Triton.

    Papers and conference

    Cite Triton

    @inproceedings{SSTIC2015-Saudel-Salwan,
      author    = {Saudel, Florent and Salwan, Jonathan},
      title     = {Triton: A Dynamic Symbolic Execution Framework},
      booktitle = {Symposium sur la s{\'{e}}curit{\'{e}} des technologies de l'information
                   et des communications},
      series    = {SSTIC},
      pages     = {31--54},
      address   = {Rennes, France},
      month     = jun,
      year      = {2015},
    }