文章 19
评论 1
浏览 92966
自建Symproxy服务器加速pdb文件的下载 windows程序调试

自建Symproxy服务器加速pdb文件的下载 windows程序调试

使用windbg调试时需要从符号文件服务器下载系统中一些模块的符号表文件--pdb文件,一般都是从微软的服务器上下载,不过毕竟服务器在国外,挺慢的。所以可以根据自建一个symproxy服务器做代理。

方案一 pySymproxy

可以在github上找到,https://github.com/inbilla/pySymProxy, 所需环境:windows系统,python2.7,以及dbghelp.dll(dbghelp.dll
、symsrv.dll(symsrv.dll
. 两个文件。

pySymproxy使用简述

  1. 安装python2.7环境,下载pySymproxy,下载dbghelp.dll和symsrv.dll两个文件,使用pip安装依赖库
python -m pip install -r requirements.txt
  1. 修改pySymproxy的配置文件如下: ```

    {
      "identity": {
        "name": "PySymProxy - Default configuration",
        "host": "localhost",
        "administrator": "    ",
        "default_sympath": "srv*c:\\pysymbols*http://localhost:810/symbols"
      },
      "general": {
        "enableStatistics": true,
        "cacheLocation": "c:\\pysymbols",
        "blacklist": []
      },
      "servers": [
        {
          "name": "Microsoft symbol server",
          "identifier": "mss",
          "remote": "http://msdl.microsoft.com/download/symbols",
          "cacheLocation": "c:\\pysymbols",
          "retryTimout": 600,
          "maxRequests": 10
        },
        {
          "name": "Mozilla symbol server",
          "identifier": "mfss",
          "remote": "http://symbols.mozilla.org/firefox",
          "cacheLocation": "c:\\pysymbols",
          "retryTimout": 600,
          "maxRequests": 10
        }
      ],
    
      "logging":{
        "version": 1,
        "disable_existing_loggers": false,
        "formatters": {
          "console": {
            "level": "DEBUG",
            "format": "%(asctime)s [%(thread)s][%(levelname)s][%(module)s] %(message)s",
            "datefmt": "%m/%d/%Y %I:%M:%S %p"
          }
        },
        "handlers":{
          "console":{
            "class" : "logging.StreamHandler",
            "formatter" : "console",
            "level" : "DEBUG"
          },
          "file":{
            "class" : "logging.handlers.RotatingFileHandler",
            "filename" : "./data/log.txt",
            "maxBytes" : 524288,
            "backupCount" : 10,
            "formatter" : "console",
            "level" : "DEBUG"
          }
        },
        "loggers": {
            "": {
              "handlers": ["console", "file"],
              "level" : "DEBUG"
            }
        }
      }
    }
    
  2. 根据需要配置winhttp使用http代理
    因为上游符号服务器在国外,所以有个代理会很方便,配置起来很简单,例如:

    netsh winhttp  set proxy 127.0.0.1:10808
    

    这样symproxy服务器在从上游符号表服务器获取pdb文件时,会走代理快一些。

  3. 在windbg中使用或者测试,配置sympath变量:

    .sympath cache*D:\User\Symbols;srv*http://pdb.zzuhacker.cn/symbols
    

方案二:使用微软提供的方案,IIS+symproxy.dll

方法步骤:

  1. 准备文件symproxy.zip(symproxy.zip),压缩包中包含:
    install.bat
    staticContentClear.xml
    symproxy.dll
    symproxy.man
    symproxy.reg
    symsrv.dll
  2. 安装IIS功能,并开启isapi-filter功能
dism.exe /Enable-Feature /Online /FeatureName:IIS-ISAPIFilter /all
  1. 创建一个目录来存放缓存的pdb文件,比如是c:\symstore\symbols,并将文件的读权限赋给everyone
  2. 删除iis默认存在的站点,即“Default Web Site”
  3. 运行install.bat来安装
install.bat c:\\symstore\\symbols
  1. 配置winhttp代理,可选,加速从上游符号表服务器下载的速度
netsh winhttp  set proxy 127.0.0.1:10808
  1. 重启IIS
iisreset


标题:自建Symproxy服务器加速pdb文件的下载 windows程序调试
作者:erlkonig
地址:https://erlkonig.tech/articles/2021/02/14/1613316501182.html

记录精彩的程序人生

取消