vscode idapython debug

vscode idapython debug

1、在脚本中嵌入debugpy

import sys
#python3.exe -m pip install debugpy
# sys.path.append(r"D:\IDA Pro 7.6\Lib\site-packages\debugpy")
import debugpy

DEBUG_HOST = '127.0.0.1'
DEBUG_PORT = 5678

# required for hosted Python (e.g. Maya)
# got it from pyenv python >>> print(sys.executable)
#python_path=sys.executable #r"D:\IDA Pro 7.6\python3.exe"
#debugpy.configure(python=python_path)
debugpy.listen((DEBUG_HOST, DEBUG_PORT),in_process_debug_adapter=True)
idaapi.msg('listen\n')
'''
try:
    debugpy.listen((DEBUG_HOST, DEBUG_PORT),in_process_debug_adapter=True)
    idaapi.msg('listen\n')
except RuntimeError as e:
# except Exception as e:
    idaapi.msg(str(e))
    if "Only one usage of each socket address" in str(e):
        pass
'''
debugpy.wait_for_client()
idaapi.msg('breakpoint\n')
debugpy.breakpoint()

2、vscode python附加

launch.json

配置python attach

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Attach ",
            "type": "python",
            "request": "attach",
            "justMyCode": false,
            "port": 5678,
            "host": "127.0.0.1",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "${workspaceFolder}",
                }
            ]
        }
    ]
}

settings.json

方便调试,非必要

{
//add this
    "python.autoComplete.extraPaths": [
        "D:\\IDA Pro 7.6\\python\\3"
    ],
    "python.analysis.extraPaths": [
        "D:\\IDA Pro 7.6\\python\\3"
    ]
}

参考链接

https://community.shotgridsoftware.com/t/remote-debugging/3869/9

posted @ 2023-03-07 10:31  DirWangK  阅读(103)  评论(0编辑  收藏  举报