Skip to content

Latest commit

 

History

History
320 lines (264 loc) · 14 KB

schema.md

File metadata and controls

320 lines (264 loc) · 14 KB

EnvDoctor 报告数据格式(schema 1)

字段名用英文 snake_case。面向人看的说明文字用中文。内存地址是十六进制字符串。没有值的字段写 null,不要省略。

顶层

{
  "schema": 1,
  "tool": { "name": "envdoctor", "version": "0.1.0" },
  "generated_at": "2026-11-10T15:04:05+08:00",
  "command": "all",                      // 用户执行的命令
  "arguments": ["--name", "foo.exe"],    // 原始参数
  "sections": { "<段名>": Section, ... },
  "findings": [ Finding, ... ]
}

Section(由 runSection 生成)

{
  "status": "ok" | "error" | "timeout",
  "elapsed_ms": 1234,
  "error": null | "错误说明",
  "data": { ... } | null                 // 各段内容见下。data 里可以有 notes 和 needs_admin
}

每段的 data 都可以带两个通用字段:notes(字符串数组,局部失败或提示)和 needs_admin(bool,因权限不足缺数据)。

Finding(由 analyze 生成)

{ "level": "high" | "warn" | "info", "area": "安全产品", "title": "一句话结论", "detail": "补充说明,可为空串", "section": "minifilters" }

FileRecord(由 describeFile 生成,各段通用)

{
  "path": "C:\\Program Files\\X\\x.dll",
  "exists": true,
  "company": "", "product": "", "description": "", "version": "1.2.3.4",   // 版本资源,没有则为空串
  "sig": { "status": "valid" | "invalid" | "unsigned" | "error", "signer": "", "catalog": false, "code": 0 },
  "vendor": "",                 // 归属方,尽力而为,取不到为空串
  "is_microsoft": false,        // 签名有效且签名者是微软系统签名
  "security_vendor": null,      // 命中已知安全厂商关键字时为厂商显示名
  "installed_product": null     // 路径落在某个已安装软件的安装目录下时,为该软件的显示名
}

exists 为 false 时其余字段给空值(sig.status 为 "error")。

vendor 的取法:签名者是微软代第三方签的那几类(如 "Microsoft Windows Hardware Compatibility Publisher")时取版本资源里的公司名;否则取签名者;没有签名取公司名。

各段的 data

system

{
  "computer_name": "", "user_name": "", "domain": "", "domain_joined": false,
  "os": { "product_name": "Windows 10 Pro", "display_version": "22H2", "edition": "Professional",
          "major": 10, "minor": 0, "build_number": 19045, "ubr": 3803, "arch": "x64" },
  "elevated": false, "remote_session": false, "secure_boot": true | false | null,
  "acp": 936, "locale": "zh-CN", "timezone": "", "uptime_minutes": 0,
  "memory_mb": 0, "cpu_count": 0, "cpu_name": "",
  "tool_path": "",
  "volumes": [ { "root": "C:\\", "type": "fixed" | "removable" | "remote" | "cdrom" | "ramdisk" | "unknown",
                 "fs": "NTFS", "label": "", "total_gb": 0.0, "free_gb": 0.0, "device": "\\Device\\HarddiskVolume3" } ]
}

products

{
  "security_center_available": true,     // 服务器系统没有这个 WMI 命名空间
  "security_center": [ { "category": "antivirus" | "firewall" | "antispyware", "name": "", "exe_path": "",
                         "state_raw": "0x061100", "enabled": true, "up_to_date": true } ],
  "installed": [ { "name": "", "publisher": "", "version": "", "install_location": "", "install_date": "",
                   "scope": "machine64" | "machine32" | "user", "security_vendor": null } ]
}

drivers

{
  "total_drivers": 0, "total_services": 0,
  "microsoft_hidden": 0,                 // 因是微软签名而未列出的数量(--all-drivers 时为 0)
  "items": [ { "name": "", "display_name": "", "kind": "kernel_driver" | "fs_driver" | "service",
               "start": "boot" | "system" | "auto" | "demand" | "disabled",
               "state": "running" | "stopped" | "start_pending" | "stop_pending" | "paused" | "unknown",
               "pid": 0, "raw_image_path": "", "file": FileRecord } ]
}

minifilters

{
  "filters": [ { "name": "", "altitude": "328010", "altitude_class": "FSFilter Anti-Virus", "altitude_class_zh": "杀毒",
                 "legacy": false, "frame": 0, "instances": 3,
                 "volumes": [ "\\Device\\HarddiskVolume3" ],
                 "file": FileRecord | null } ]
}

高度值分类按微软公布的区间表。常用的中文名:320000–329999 杀毒,140000–149999 加密,360000–389999 行为监控,260000–269999 内容筛选,280000–289999 持续备份,180000–189999 分层存储,160000–169999 压缩,130000–139999 虚拟化,80000–89999 安全增强,40000–49999 底层。其余区间给英文类名,中文写"其他"。

network

{
  "wfp": { "providers": [ { "key": "{guid}", "name": "", "description": "", "service_name": "", "persistent": false } ],
           "callouts":  [ { "key": "{guid}", "name": "", "description": "", "provider_key": "{guid}" | null,
                            "layer": "{guid}", "layer_name": "ALE_AUTH_CONNECT_V4" | null } ],
           "filter_count": 0,
           "filters_by_provider": [ { "provider_key": "{guid}" | null, "provider_name": "", "count": 0 } ] },
  "lsp": { "entries": [ { "catalog_id": 1001, "protocol": "", "chain_len": 1, "kind": "base" | "layered" | "chain",
                          "file": FileRecord } ],
           "non_microsoft": 0 },
  "ndis": { "filters":   [ { "component_id": "", "description": "", "filter_class": "", "service": "", "inf": "", "is_ms": true } ],
            "protocols": [ { "component_id": "", "description": "", "is_ms": true } ] },
  "firewall": { "domain": true, "private": true, "public": true },     // 各配置文件是否启用,读不到为 null
  "proxy": { "wininet": { "auto_detect": false, "pac_url": "", "proxy": "", "bypass": "" },
             "winhttp": { "access_type": "direct" | "named", "proxy": "", "bypass": "" },
             "env": { "HTTP_PROXY": "", "HTTPS_PROXY": "", "ALL_PROXY": "", "NO_PROXY": "" } },   // 只列有值的
  "adapters": [ { "name": "", "description": "", "status": "up" | "down", "type": "ethernet" | "wifi" | "tunnel" | "ppp" | "loopback" | "other",
                  "ipv4": [], "ipv6": [], "dns": [], "gateway": [] } ],
  "hosts": { "path": "", "count": 0, "entries": [ "1.2.3.4 example.com" ] }      // 去掉注释和空行,最多 200 条
}

is_ms 的判定:component_id 以 ms_ 开头。

certs

{
  "total_roots": 0,
  "extra_count": 0,
  "roots": [ { "store": "LocalMachine" | "CurrentUser", "subject": "", "issuer": "", "sha1": "",
               "not_before": "2020-01-01", "not_after": "2030-01-01",
               "in_authroot": false, "is_microsoft": false, "security_vendor": null } ]
}

roots 只列"额外"的根证书:不在 AuthRoot(微软根证书计划分发)里,且主题不是微软自己的。

injection

{
  "appinit": [ { "view": "64" | "32", "dlls": "", "load_enabled": false, "require_signed": false, "files": [ FileRecord ] } ],
  "appcert_dlls": [ { "name": "", "file": FileRecord } ],
  "ifeo": [ { "image": "foo.exe", "view": "64" | "32", "debugger": "" , "verifier_dlls": "", "global_flag": "" } ],
  "shims": { "custom": [ "foo.exe" ], "installed_sdb": [ { "guid": "", "path": "", "description": "" } ] }
}

ifeo 只列带 Debugger、VerifierDlls 或 GlobalFlag 的项。

policy

{
  "defender": { "available": true,
                "status": { ... MSFT_MpComputerStatus 的字段原样 ... } | null,
                "preferences": { ... MSFT_MpPreference 的字段原样 ... } | null },
  "applocker": { "configured": false,
                 "collections": [ { "type": "Exe" | "Dll" | "Script" | "Msi" | "Appx",
                                    "enforcement": "not_configured" | "audit" | "enforce", "rule_count": 0 } ] },
  "device_guard": { ... Win32_DeviceGuard 的字段原样 ... } | null,
  "srp": { "configured": false, "default_level": "" },
  "uac": { "enable_lua": true, "consent_admin": 5 }
}

defender.status 至少取:AMRunningMode、AMServiceEnabled、AntivirusEnabled、RealTimeProtectionEnabled、BehaviorMonitorEnabled、IoavProtectionEnabled、OnAccessProtectionEnabled、IsTamperProtected、AMProductVersion、AMEngineVersion、AntivirusSignatureVersion。

defender.preferences 至少取:ExclusionPath、ExclusionProcess、ExclusionExtension、EnableControlledFolderAccess、ControlledFolderAccessProtectedFolders、ControlledFolderAccessAllowedApplications、AttackSurfaceReductionRules_Ids、AttackSurfaceReductionRules_Actions、EnableNetworkProtection、DisableRealtimeMonitoring。

processes(proc 命令)

{
  "query": { "names": [ "foo.exe" ], "pids": [] },
  "matched": 0,
  "processes": [ ProcessRecord ]
}

ProcessRecord

{
  "pid": 0, "ppid": 0, "name": "foo.exe", "path": "", "command_line": "",
  "bitness": 64 | 32, "session": 1, "start_time": "2026-11-10 15:04:05",
  "file": FileRecord | null,
  "access_error": null | "打开进程失败:拒绝访问。(5)",
  "modules": [ { "base": "0x7ffa12340000", "size": 0,
                 "category": "self" | "microsoft" | "third_party" | "unknown",
                 "file": FileRecord } ],
  "module_summary": { "total": 0, "self": 0, "microsoft": 0, "third_party": 0, "unknown": 0 },
  "unlisted_images": [ { "base": "0x...", "path": "" } ],        // 映射为镜像但不在加载器模块表里
  "private_exec": { "regions": 0, "bytes": 0 },                  // 已提交、私有、可执行的内存区
  "hooks": Hooks | null                                          // --no-hooks 或无法读取时为 null
}

模块分类:

  • self:模块路径在进程主程序所在目录之下(含子目录)。
  • microsoft:file.is_microsoft 为 true。
  • third_party:有有效的非微软签名,或者版本资源里有公司名。
  • unknown:其余。

判断顺序是 self、microsoft、third_party、unknown。

Hooks

{
  "scanned_modules": [ "ntdll.dll" ],
  "functions_checked": 0,
  "hooked": [ { "module": "ntdll.dll", "function": "NtCreateFile",
                "kind": "jmp_rel32" | "jmp_indirect" | "mov_jmp" | "push_ret" | "short_jmp",
                "bytes": "e9 12 34 56 78",
                "target": "0x...",                       // 沿跳转链走到底的最终地址
                "target_module": "C:\\...\\x.dll" | null, // 最终地址落在哪个模块;落在私有内存为 null
                "target_file": FileRecord | null } ],
  "modified_unknown": 0,        // 与磁盘文件不一致、但不是可识别跳转的函数数量(只对 64 位目标统计)
  "error": null
}

probe_canary

{
  "children": [ { "kind": "console" | "gui" | "net", "ok": true, "error": null,
                  "create_ms": 0.0, "exit_code": 0,
                  "process": ProcessRecord | null } ],
  "injected": [ { "file": FileRecord, "seen_in": [ "console", "gui" ] } ],   // 各子进程里 third_party 和 unknown 模块的并集
  "hooked_functions": 0,
  "hook_owners": [ { "target_module": "" | null, "count": 0 } ]
}

诱饵子进程就是工具自身带隐藏参数重新启动,所以它的 self 模块只有工具本体,其余应全是微软模块。

probe_file

{
  "dir": "", "work_dir": "",                       // 没给 --dir 时两者为空串,extensions 为空数组,small_files 为 null
  "volume": { "fs": "NTFS", "type": "fixed" } | null,
  "extensions": [ { "ext": ".docx",
                    "steps": [ { "step": "create_write" | "read_back" | "mmap_read" | "rename" | "replace_save" | "attributes" | "delete",
                                 "ok": true, "error_code": 0, "error": "", "ms": 0.0, "detail": "" } ] } ],
  "small_files": { "count": 200, "size": 4096, "total_ms": 0.0, "avg_ms": 0.0, "errors": 0 } | null,
  "samples": [ { "path": "", "size": 0, "ext": ".docx",
                 "expected_magic": "50 4b 03 04" | null, "magic_ok": true | false | null,
                 "head_hex": "", "head_text": "", "entropy": 0.0,
                 "attributes": [ "encrypted_efs", "compressed", "sparse", "offline", "reparse_point", "readonly", "hidden", "system" ],
                 "streams": [ ":Zone.Identifier:$DATA" ],          // 除主数据流以外的命名流
                 "verdict": "match" | "mismatch_random" | "mismatch" | "unknown" | "error",
                 "verdict_zh": "", "error": null } ],
  "cleanup_ok": true
}

read_back 和 mmap_read 要逐字节比对写入的内容,不一致时 ok 为 false,detail 说明首个不一致的偏移。

probe_net

{
  "targets": [ {
    "url": "", "scheme": "https", "host": "", "port": 443, "path": "/",
    "proxy_for_url": { "mode": "direct" | "proxy" | "error", "proxy": "", "source": "none" | "manual" | "pac" | "auto_detect",
                       "ms": 0.0, "error": null },
    "dns": { "ok": true, "ms": 0.0, "error_code": 0, "error": "",
             "addresses": [ { "ip": "", "family": 4 | 6, "note": null | "保留地址段 198.18.0.0/15,常见于代理或安全网关的虚拟地址" } ] },
    "tcp": [ { "ip": "", "port": 443, "ok": true, "ms": 0.0, "error_code": 0, "error": "" } ],
    "http_direct": HttpResult,
    "http_proxy": HttpResult | null,          // 系统配置了代理时才做
    "curl": HttpResult | null                 // 构建时启用了 libcurl 才有
  } ]
}

HttpResult

{
  "ok": true, "status": 200, "ms": 0.0, "error_code": 0, "error": "", "bytes": 0,
  "via_proxy": "" ,
  "headers": { "server": "", "via": "", "content-type": "" },      // 只列这几个,没有则不出现
  "tls": null | {
    "validated": true, "validation_error": "",
    "chain": [ { "subject": "", "issuer": "", "sha1": "", "sha256": "", "not_before": "", "not_after": "" } ],   // 叶子在前
    "root_subject": "", "root_in_authroot": true | false | null,
    "intercept_suspected": false               // 根证书在本机受信任但不在 AuthRoot 里
  }
}

probe_ipc

{
  "tests": [ { "name": "loopback_tcp_v4" | "loopback_tcp_v6" | "named_pipe" | "shared_memory" | "create_process" | "open_process",
               "ok": true, "ms": 0.0, "error_code": 0, "error": "", "detail": "" } ],
  "process_create": { "runs": 5, "self_avg_ms": 0.0, "cmd_avg_ms": 0.0 }
}