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

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

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

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

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
TS_LLMLib — ローカルLLMによるセキュリティ分析、Ghidraバイナリ分析、C/C++脆弱性スキャン、そしてMCPツール統合による自動リバースエンジニアリングとレポート生成のためのPythonライブラリ。 | Kitploit
ツール/GitHubGitHub/trustedsec/ts_llmlib
静的分析脆弱性分析コード分析エクスプロイトリバースエンジニアリングスクリプトと自動化ユーティリティとフレームワークバイナリ解析機械学習AIセキュリティ
GitHubtrustedsec/ts_llmlib

TS_LLMLib

153ヶ月前未レビュー

ローカルLLMによるセキュリティ分析、Ghidraバイナリ分析、C/C++脆弱性スキャン、そしてMCPツール統合による自動リバースエンジニアリングとレポート生成のためのPythonライブラリ。

リポジトリを見る

人気

すべて見る →

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

すべてのツールを探索

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

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

ts_llmlib - TrustedSec LLM ライブラリ

TrustedSec LLM ライブラリは、ツールの使用をサポートするローカルLLMと対話するためのPythonライブラリです。ローカルLLMエンドポイントとMCP(Model Context Protocol)統合を活用することで、従来はフロンティアモデルでのみ可能だった大規模なワークフローを実行できます。

特徴

  • ローカルLLMサポート: OpenAI互換のAPIエンドポイントに接続するか、ローカルLLMサーバーを使用します
  • MCP統合: RPCおよびSSEプロトコルの両方に対する完全なModel Context Protocolサポート
  • ツールレジストリ: カスタムツールの拡張性を備えた組み込みのファイル操作ツール
  • 会話履歴: 複数ターンにわたってチャットコンテキストを維持
  • 時間制限: 暴走を防ぐための設定可能な実行タイムアウト
  • Pure Python: 標準ライブラリ以外の外部依存関係なし

インストール

Pythonパッケージとして

root@kitploit:~
# Clone or copy the repository
git clone https://github.com/trustedsec/ts_llmlib.git
cd ts_llmlib

# Install with pip
pip install -e .

手動インストール

ts_llmlib/ディレクトリをプロジェクトにコピーします。

root@kitploit:~
cp -rf ts_llmlib /path/to/your/project/

クイックスタート

基本的な使い方

root@kitploit:~
from ts_llmlib import ChatSession

# Initialize with defaults (connects to http://localhost:1234/v1/chat/completions)
chat = ChatSession()

# Run a prompt
response = chat.run_prompt("What files are in the current directory?")
print(response['content'])

カスタム設定の場合

root@kitploit:~
from ts_llmlib import ChatSession

# Configure with custom settings
chat = ChatSession(
    system_prompt="You are a helpful assistant that uses file tools.",
    tool_list=[],  # Empty = use default file tools
    mcp_servers={
        "default": "http://localhost:3000/mcp"
    },
    llm_endpoint_url="http://localhost:1234/v1/chat/completions",
    model_name="qwen3-coder-next",
    timeout=60,
    max_runtime=300
)

response = chat.run_prompt("Write 'hello' to /tmp/greeting.txt")
print(response['content'])

会話履歴を使用する場合

root@kitploit:~
from ts_llmlib import ChatSession

chat = ChatSession()

history = [
    {"role": "user", "content": "What is 2+2?"},
    {"role": "assistant", "content": "The answer is 4."}
]

response = chat.run_prompt("Can you write that to a file?", history=history)

組み込みツール

ツールパラメータ説明
read_local_filepath: strローカルファイルの内容を読み取ります
write_local_filepath: str, content: strローカルファイルに内容を書き込みます
list_directorypath: strパス内のファイルとディレクトリを一覧表示します

MCP統合

MCP(Model Context Protocol)は、外部ツールやサービスとの統合を可能にします。MCPサーバーが設定されている場合、ts_llmlibは次のことを行います:

  1. 各サーバーへの接続を初期化
  2. サーバーから利用可能なツールを取得
  3. 組み込みツールとマージ(一致する名前の場合はMCPツールが優先)
  4. 適切なサーバーを使用してツール呼び出しを実行

Ghidra MCPサーバーを使用した例

root@kitploit:~
from ts_llmlib import ChatSession

chat = ChatSession(
    mcp_servers={
        "ghidraSvr": "http://localhost:8081/sse"
    },
    llm_endpoint_url="http://localhost:1234/v1/chat/completions",
    model_name="qwen3-coder-next"
)

# The chat session will automatically fetch and integrate Ghidra tools
# such as list_methods, decompile_function, get_xrefs_to, etc.

MCPサーバーエンドポイント

ts_llmlibはRPCスタイルとSSE(Server-Sent Events)エンドポイントの両方をサポートします:

  • RPC: http://localhost:3000/mcp
  • SSE: http://localhost:3000/sse(RPCコール時に自動的に/mcpに変換)

APIリファレンス

ChatSessionクラス

root@kitploit:~
ChatSession(
    system_prompt: str | None = None,
    tool_list: list | None = None,
    mcp_servers: dict[str, str] | None = None,
    llm_endpoint_url: str = "http://localhost:1234/v1/chat/completions",
    model_name: str = "default",
    timeout: int = 60,
    max_runtime: int = 300
)

パラメータ:

  • system_prompt (str | None): カスタムシステムプロンプト。デフォルトは最小限のアシスタントプロンプトです。
  • tool_list (list | None): カスタムツール定義のリスト。空リストは組み込みツールを使用します。
  • mcp_servers (dict[str, str] | None): サーバー名をURLにマッピングする辞書。
  • llm_endpoint_url (str): LLM APIエンドポイントのURL。
  • model_name (str): LLMエンドポイントのモデル識別子。
  • timeout (int): HTTPリクエストのタイムアウト(秒)。
  • max_runtime (int): プロンプトの最大実行時間(秒)。

run_promptメソッド

root@kitploit:~
response = chat.run_prompt(
    user_prompt: str,
    conversation_history: list[dict] | None = None,
    disable_tools: list[str] | None = None,
    max_runtime: int | None = None
) -> dict

パラメータ:

  • user_prompt (str): ユーザーのメッセージまたは質問。
  • conversation_history (list[dict] | None): オプションの会話履歴(role/contentペアのリスト)。
  • disable_tools (list[str] | None): この呼び出しで無効にするツール名のリスト。
  • max_runtime (int | None): この特定の呼び出しのデフォルトの最大実行時間を上書きします。

戻り値:

root@kitploit:~
{
    "content": str,           # LLM response text
    "tool_calls": list,       # List of tool calls made (if any)
    "usage": dict | None,     # Token usage if available from the LLM
    "error": str | None       # Error message if failed
}

ツールレジストリ

ToolRegistryはチャットセッションで利用可能なすべてのツールを管理します:

  • 組み込みツール: ファイル操作(読み取り/書き込み/一覧表示)
  • MCPツール: MCPサーバーから取得したツール
  • カスタムツール: tool_listパラメータでユーザー定義されたツール

使用例

デフォルトのパスを上書きするには、次の変数を設定できます。これらはChatSessionでチェックされます。

root@kitploit:~
TS_LLM_MODEL=qwen3-coder-next TS_LLM_ENDPOINT=http://HOSTNAME:1234/v1/chat/completions
# Example usage
export TS_LLM_MODEL=qwen3-coder-next
export TS_LLM_ENDPOINT=http://HOSTNAME:1234/v1/chat/completions
ts_llmlib-redclippy
# OR
TS_LLM_MODEL=qwen3-coder-next TS_LLM_ENDPOINT=http://HOSTNAME:1234/v1/chat/completions ts_llmlib-redclippy

C/C++ソースコード解析

セキュリティ脆弱性についてC/C++ソースファイルを解析します:

root@kitploit:~
ts_llmlib-cpp-analyze <source_folder> <output_folder>

Ghidraバイナリ解析

Ghidra統合によるリバースエンジニアリングバイナリ解析:

root@kitploit:~
# Basic analysis
ts_llmlib-ghidra-analyze <output_folder>

# Rename-only mode (first pass)
ts_llmlib-ghidra-analyze --rename_only <output_folder>

# Process only previously unnamed functions
ts_llmlib-ghidra-analyze --process_unnamed_only <output_folder>

# Grouped analysis for call relationship grouping
ts_llmlib-ghidra-analyze --grouped <output_folder>

--rename_onlyを使用しない場合、実行後は以下を実行して構造をクリーンアップできます:

root@kitploit:~
ts_llmlib-ghidra-cleanup <input_folder> <output_folder>

脆弱性レポート生成

JSONレビューファイルからフォーマットされた脆弱性レポートを生成します:

root@kitploit:~
ts_llmlib-ghidra-report <review_folder>

GUIチャットアプリケーション

RedClippy Qtベースのチャットインターフェースを実行します(この例ではpyside6が必要です):

root@kitploit:~
ts_llmlib-redclippy

設定オプション

LLMエンドポイント設定

ts_llmlibはOpenAI互換のAPIエンドポイントに接続します。一般的なローカルLLMサーバー:

サーバーデフォルトURL
Ollamahttp://localhost:11434/v1/chat/completions
LM Studiohttp://localhost:1234/v1/chat/completions
vLLMhttp://localhost:8000/v1/chat/completions

時間制限

2つのタイムアウト設定が実行を制御します:

  • HTTPタイムアウト (timeout): 単一のAPIリクエストの最大時間
  • 最大実行時間 (max_runtime): プロンプト処理に許可される総経過時間(ツール呼び出しを含む)

どちらかの制限を超えた場合、レスポンスにエラーメッセージが含まれます。

エラーハンドリング

すべてのエラーはレスポンス辞書で返されます:

root@kitploit:~
response = chat.run_prompt("Some prompt")

if response.get('error'):
    print(f"Error: {response['error']}")
else:
    print(response['content'])

一般的なエラー

  • HTTPエラー: 接続拒否、タイムアウト、無効なAPIキー
  • JSONパースエラー: 無効なツール引数または不正なレスポンス
  • ツール実行エラー: ファイルの欠落、権限の問題、無効なパラメータ
  • タイムアウトエラー: 操作がmax_runtime制限を超えた

プロジェクト構造

root@kitploit:~
ts_llmlib/
├── __init__.py          # パッケージの初期化、ChatSessionをエクスポート
├── client.py            # LLMエンドポイントへのHTTPリクエスト用LLMClient
├── chat.py              # ChatSessionクラス(メインAPI)
├── mcp.py               # Model Context Protocol統合用MCPClient
├── tools.py             # ツール管理用ToolRegistry
├── HOW_TO_TS_LLMLIB.md  # 元のドキュメント
└── examples/            # サンプルスクリプト
    ├── c_cpp_analyze.py     # C/C++脆弱性解析スクリプト
    ├── redclippy.py         # QtベースのGUIチャットアプリケーション
    ├── ghidra_analyze.py    # Ghidraバイナリ解析(MCP統合用)
    ├── ghidra_vuln_report.py  # 脆弱性レポート生成器
    ├── ghidra_cleanup.py    # 出力ファイル再整理ユーティリティ
    └── example_ts_llmlib.py # ライブラリ使用例のサンプルスクリプト

pyproject.toml         # モダンなPythonパッケージ設定(スクリプトはここで定義)
LICENSE.txt            # BSD-3-Clause License
README.md              # このファイル

ライセンス

BSD-3-Clauseライセンス - 詳細はLICENSE.txtファイルを参照してください。

コントリビューション

貢献を歓迎します!遠慮なくプルリクエストを送信してください。

  1. リポジトリをフォーク
  2. フィーチャーブランチを作成(git checkout -b feature/AmazingFeature)
  3. 変更をコミット(git commit -m 'Add some AmazingFeature')
  4. ブランチにプッシュ(git push origin feature/AmazingFeature)
  5. プルリクエストを開く
ツールをダウンロード