fix: frida_wireless import sdk/agent hook modules correctly
Use sdk/agent on sys.path instead of agent.hook under sdk/app/agent, which lacks wireless_deployer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,8 @@ Frida 无线管理路由 — 服务端设备管理与指令分发
|
||||
from __future__ import annotations
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from typing import Optional, List, Dict, Any
|
||||
from datetime import datetime
|
||||
@@ -26,6 +28,13 @@ router = APIRouter(prefix="/frida", tags=["Frida无线管理"])
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _ensure_sdk_agent_path() -> None:
|
||||
"""device 端 Hook 模块在 sdk/agent,非 sdk/app/agent。"""
|
||||
agent_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..", "agent"))
|
||||
if os.path.isdir(agent_dir) and agent_dir not in sys.path:
|
||||
sys.path.insert(0, agent_dir)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# § 1 数据模型
|
||||
# ============================================================
|
||||
@@ -325,7 +334,8 @@ async def generate_deploy_script(req: DeployScriptRequest):
|
||||
# 动态导入避免循环依赖
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'agent', 'hook'))
|
||||
from agent.hook.wireless_deployer import WirelessDeployer, DeployConfig
|
||||
_ensure_sdk_agent_path()
|
||||
from hook.wireless_deployer import WirelessDeployer, DeployConfig
|
||||
|
||||
config = DeployConfig(frida_arch=req.arch)
|
||||
deployer = WirelessDeployer(config)
|
||||
@@ -391,7 +401,8 @@ async def discover_devices(req: DiscoverRequest):
|
||||
扫描指定子网内运行 frida-server 的设备。
|
||||
"""
|
||||
try:
|
||||
from agent.hook.wireless_deployer import wireless_deployer
|
||||
_ensure_sdk_agent_path()
|
||||
from hook.wireless_deployer import wireless_deployer
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
devices = await loop.run_in_executor(
|
||||
@@ -439,7 +450,8 @@ async def frida_status():
|
||||
async def list_supported_actions():
|
||||
"""列出所有支持的 Frida RPC 操作"""
|
||||
try:
|
||||
from agent.hook.hook_executor import ACTION_TO_RPC, MODULE_NAMES
|
||||
_ensure_sdk_agent_path()
|
||||
from hook.hook_executor import ACTION_TO_RPC, MODULE_NAMES
|
||||
|
||||
# 按模块分组
|
||||
modules = {}
|
||||
|
||||
Reference in New Issue
Block a user