Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
LLM4Decompile — リバースエンジニアリング: 大規模言語モデルによるバイナリコードの逆コンパイル | Kitploit
ツール/GitHubGitHub/albertan017/llm4decompile
リバースエンジニアリングバイナリ解析機械学習AI支援リバースエンジニアリング
GitHubalbertan017/llm4decompile

LLM4Decompile

リバースエンジニアリング: 大規模言語モデルによるバイナリコードの逆コンパイル

リポジトリを見るウェブサイト
7.0k5456ヶ月前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

LLM4Decompile

📊 結果 | 🤗 モデル | 🚀 クイックスタート | 📚 HumanEval-Decompile | 📎 引用 | 📝 論文 | 🖥️ Colab | ▶️ YouTube

リバースエンジニアリング: 大規模言語モデルによるバイナリコードの逆コンパイル

GitHub Tread

更新情報

  • [2025-10-04]: SK²Decompileをリリース: スケルトンからスキンへのLLMベースの二段階バイナリ逆コンパイル。フェーズ1 構造復元(スケルトン): バイナリ/疑似コードを難読化された中間表現に変換 🤗 HF Link。フェーズ2 識別子命名(スキン): 意味のある識別子を持つ人間が読めるソースコードを生成 🤗 HF Link。
  • [2024-10-17]: decompile-ghidra-100kをリリース。これは10万件のトレーニングサンプルのサブセットです(各最適化レベル25k件)。単一のA100 40G GPUで約3.5時間で実行できるトレーニングスクリプトを提供しています。0.26の再実行可能性率を達成し、総コスト20ドル未満でLLM4Decompileを迅速に再現できます。

概要

  • LLM4Decompile は、逆コンパイルに特化した先駆的なオープンソース大規模言語モデルです。現在のバージョンは、GCCのO0からO3までの最適化レベルにおけるLinux x86_64バイナリを、人間が読めるCソースコードに逆コンパイルすることができます。私たちのチームは、より幅広いアーキテクチャと構成を組み込むための継続的な取り組みを通じて、このツールの機能拡張に取り組んでいます。
  • LLM4Decompile-End はバイナリを直接逆コンパイルすることに焦点を当てています。LLM4Decompile-Ref はGhidraによって逆コンパイルされた疑似コードを洗練させます。

評価

フレームワーク

image

コンパイル時、プリプロセッサはソースコード(SRC)を処理してコメントを除去し、マクロやインクルードを展開します。クリーニングされたコードは次にコンパイラに渡され、アセンブリコード(ASM)に変換されます。このASMはアセンブラによってバイナリコード(0と1)に変換されます。リンカは関数呼び出しをリンクして実行可能ファイルを作成し、プロセスを完了させます。一方、逆コンパイルはバイナリコードをソースファイルに戻す変換を含みます。LLMはテキストでトレーニングされているため、バイナリデータを直接処理する能力がありません。そのため、バイナリはまず Objdump によってアセンブリ言語(ASM)に逆アセンブルされる必要があります。バイナリと逆アセンブルされたASMは等価であり、相互変換できることに注意してください。したがって、私たちはこれらを同じ意味で扱います。最後に、逆コンパイルされたコードとソースコードの間で損失が計算され、トレーニングを導きます。逆コンパイルされたコード(SRC')の品質を評価するために、テストアサーション(再実行可能性)を通じてその機能がテストされます。

メトリクス

  • 再実行可能性 は、逆コンパイルされたコードが正しく実行され、定義済みのすべてのテストケースに合格できるかどうかを評価します。

ベンチマーク

  • HumanEval-Decompile 標準Cライブラリのみに依存する164個のC関数のコレクション。
  • ExeBench 実際のプロジェクトから抽出された2,621個の関数のコレクション。各関数はユーザー定義の関数、構造体、マクロを使用しています。

結果

results

image

モデル

LLM4Decompileには、13億から330億パラメータのサイズのモデルが含まれており、これらのモデルをHugging Faceで公開しています。

注記3: V1.5シリーズは、より大規模なデータセット(15Bトークン)と最大トークンサイズ4,096でトレーニングされており、以前のモデルと比較して顕著な性能(100%以上の改善)を達成しています。

注記4: V2シリーズはGhidraを基盤としており、Ghidraによって逆コンパイルされた疑似コードを改良するために20億トークンでトレーニングされています。詳細はghidraフォルダを確認してください。

クイックスタート

Open In Colab

セットアップ: 必要な環境をインストールするには、以下のスクリプトを使用してください。

root@kitploit:~
git clone https://github.com/albertan017/LLM4Decompile.git
cd LLM4Decompile
conda create -n 'llm4decompile' python=3.9 -y
conda activate llm4decompile
pip install -r requirements.txt

以下は、私たちのモデルの使用例です(V1.5用に改訂。以前のモデルについては、HFの対応するモデルページを確認してください)。 注: 逆コンパイルしたい関数名で "func0" を置き換えてください。

前処理: Cコードをバイナリにコンパイルし、バイナリをアセンブリ命令に逆アセンブルします。

root@kitploit:~
import subprocess
import os
func_name = 'func0'
OPT = ["O0", "O1", "O2", "O3"]
fileName = 'samples/sample' #'path/to/file'
for opt_state in OPT:
    output_file = fileName +'_' + opt_state
    input_file = fileName+'.c'
    compile_command = f'gcc -o {output_file}.o {input_file} -{opt_state} -lm'#compile the code with GCC on Linux
    subprocess.run(compile_command, shell=True, check=True)
    compile_command = f'objdump -d {output_file}.o > {output_file}.s'#disassemble the binary file into assembly instructions
    subprocess.run(compile_command, shell=True, check=True)
    
    input_asm = ''
    with open(output_file+'.s') as f:#asm file
        asm= f.read()
        if '<'+func_name+'>:' not in asm: #IMPORTANT replace func0 with the function name
            raise ValueError("compile fails")
        asm = '<'+func_name+'>:' + asm.split('<'+func_name+'>:')[-1].split('\n\n')[0] #IMPORTANT replace func0 with the function name
        asm_clean = ""
        asm_sp = asm.split("\n")
        for tmp in asm_sp:
            if len(tmp.split("\t"))<3 and '00' in tmp:
                continue
            idx = min(
                len(tmp.split("\t")) - 1, 2
            )
            tmp_asm = "\t".join(tmp.split("\t")[idx:])  # remove the binary code
            tmp_asm = tmp_asm.split("#")[0].strip()  # remove the comments
            asm_clean += tmp_asm + "\n"
    input_asm = asm_clean.strip()
    before = f"# This is the assembly code:\n"#prompt
    after = "\n# What is the source code?\n"#prompt
    input_asm_prompt = before+input_asm.strip()+after
    with open(fileName +'_' + opt_state +'.asm','w',encoding='utf-8') as f:
        f.write(input_asm_prompt)

アセンブリ命令は次の形式である必要があります:

<FUNCTION_NAME>:\nOPERATIONS\nOPERATIONS\n

典型的なアセンブリ命令は次のようになります:

root@kitploit:~
<func0>:
endbr64
lea    (%rdi,%rsi,1),%eax
retq

逆コンパイル: LLM4Decompileを使用して、アセンブリ命令をCに変換します:

root@kitploit:~
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_path = 'LLM4Binary/llm4decompile-6.7b-v1.5' # V1.5 Model
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path,torch_dtype=torch.bfloat16).cuda()

with open(fileName +'_' + OPT[0] +'.asm','r') as f:#optimization level O0
    asm_func = f.read()
inputs = tokenizer(asm_func, return_tensors="pt").to(model.device)
with torch.no_grad():
    outputs = model.generate(**inputs, max_new_tokens=2048)### max length to 4096, max new tokens should be below the range
c_func_decompile = tokenizer.decode(outputs[0][len(inputs[0]):-1])

with open(fileName +'.c','r') as f:#original file
    func = f.read()

print(f'original function:\n{func}')# Note we only decompile one function, where the original file may contain multiple functions
print(f'decompiled function:\n{c_func_decompile}')

Dockerセットアップ

root@kitploit:~
# build docker
docker build -t llm4decompile .

# run docker with GPU
docker run --gpus all -it --name llm4decompile llm4decompile /bin/bash

# run demo.py (choose a model suitable for your resources before running)
cd ghidra
python demo.py

HumanEval-Decompile

データは llm4decompile/decompile-eval/decompile-eval-executable-gcc-obj.json にJSONリスト形式で保存されています。164*4(O0、O1、O2、O3)個のサンプルがあり、それぞれに5つのキーがあります:

  • task_id: 問題のIDを示します。
  • type: 最適化ステージで、[O0、O1、O2、O3]のいずれかです。
  • c_func: HumanEval問題のCソリューション。
  • c_test: Cテストアサーション。
  • input_asm_prompt: プロンプト付きのアセンブリ命令。前処理の例のようにして導出できます。

評価スクリプトを確認してください。

進行中

  • クリーニング処理を施した大規模なトレーニングデータセット。(完了:2024.05.13)
  • 一般的な言語/プラットフォームおよび設定のサポート。
  • 実行可能バイナリのサポート。(完了:2024.05.13)
  • 逆コンパイルツール(例: Ghidra、Rizin)との統合。

ライセンス

このコードリポジトリはMITおよびDeepSeekライセンスの下でライセンスされています。

引用

root@kitploit:~
@misc{tan2024llm4decompile,
      title={LLM4Decompile: Decompiling Binary Code with Large Language Models}, 
      author={Hanzhuo Tan and Qi Luo and Jing Li and Yuqun Zhang},
      year={2024},
      eprint={2403.05286},
      archivePrefix={arXiv},
      primaryClass={cs.PL}
}

スター履歴

Star History Chart

ツールをダウンロード
モデルチェックポイントサイズ再実行可能性注記
llm4decompile-1.3b-v1.5🤗 HF Link1.3B27.3%注記3
llm4decompile-6.7b-v1.5🤗 HF Link6.7B45.4%注記3
llm4decompile-1.3b-v2🤗 HF Link1.3B46.0%注記4
llm4decompile-6.7b-v2🤗 HF Link6.7B52.7%注記4
llm4decompile-9b-v2🤗 HF Link9B64.9%注記4
llm4decompile-22b-v2🤗 HF Link22B63.6%注記4