The interface is localized. Skill descriptions and documents are machine-translated by AI into your language; code, commands, paths and technical terms stay in the original, and the author's document governs.
Explore skills
Productivity · SKILL.md

performing-authenticated-vulnerability-scan

performing-authenticated-vulnerability-scan

认证(凭据)漏洞扫描使用有效的系统凭据登录目标主机,对已安装软件、补丁、配置和安全设置进行深度检查,相比未认证扫描可发现 45-60% 更多漏洞。

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill documentation

GitHub

name: performing-authenticated-vulnerability-scan description: 认证(凭据)漏洞扫描使用有效的系统凭据登录目标主机,对已安装软件、补丁、配置和安全设置进行深度检查,相比未认证扫描可发现 45-60% 更多漏洞。 domain: cybersecurity subdomain: vulnerability-management tags: [vulnerability-management, cve, authenticated-scanning, credentials, nessus, qualys, risk] version: "1.0" author: mahipal license: Apache-2.0

执行认证漏洞扫描

概述

认证(凭据)漏洞扫描(Authenticated Vulnerability Scan)使用有效的系统凭据登录目标主机,对已安装软件、补丁、配置和安全设置进行深度检查。与未认证扫描相比,凭据扫描能检测到多 45-60% 的漏洞,且误报率显著更低,因为可以直接查询已安装软件包、注册表项和文件系统内容。

前置条件

  • 漏洞扫描器(Nessus、Qualys、OpenVAS、Rapid7 InsightVM)
  • 在目标系统上具有适当权限的服务账户
  • 安全凭据存储(优先集成密钥管理库)
  • 扫描器到目标管理端口的网络访问权限
  • 系统负责人的书面授权

核心概念

为何使用认证扫描

未认证扫描只能评估外部可见的服务和 Banner,常导致:

  • 遗漏本地已安装软件中的漏洞
  • 因 Banner 变更导致版本检测不准确
  • 无法检查补丁级别、配置或本地策略
  • 基于推断的检测方式导致误报率偏高

认证扫描通过直接查询目标操作系统来解决上述问题。

各平台凭据类型

Linux/Unix 系统

  • SSH 密钥认证:RSA/Ed25519 密钥对(推荐)
  • SSH 用户名/密码:无密钥认证系统的备选方案
  • Sudo/Su 提权:具有 sudo 权限的非 root 用户
  • 基于证书的 SSH:企业环境的 X.509 证书

Windows 系统

  • SMB(Windows):域管理员或本地管理员凭据
  • WMI:Windows Management Instrumentation(Windows 管理规范)查询
  • WinRM:Windows Remote Management(Windows 远程管理,优先使用 HTTPS)
  • Kerberos:带服务票据的域认证

网络设备

  • SNMP v3:带认证和加密的 USM(AES-256)
  • SSH:用于 Cisco IOS、Juniper JunOS、Palo Alto PAN-OS
  • API 令牌:现代网络平台的 REST API

数据库

  • Oracle:SYS/SYSDBA 凭据或 TNS 连接
  • Microsoft SQL Server:Windows 认证或 SQL 认证
  • PostgreSQL:基于角色的认证
  • MySQL:具有 SELECT 权限的用户名/密码

实施步骤

步骤 1:创建专用服务账户

# Linux:创建扫描服务账户
sudo useradd -m -s /bin/bash -c "Vulnerability Scanner Service Account" nessus_svc
sudo usermod -aG sudo nessus_svc

# 配置特定命令的免密 sudo
echo 'nessus_svc ALL=(ALL) NOPASSWD: /usr/bin/dpkg -l, /usr/bin/rpm -qa, \
/bin/cat /etc/shadow, /usr/sbin/dmidecode, /usr/bin/find' | sudo tee /etc/sudoers.d/nessus_svc

# 生成 SSH 密钥对
sudo -u nessus_svc ssh-keygen -t ed25519 -f /home/nessus_svc/.ssh/id_ed25519 -N ""

# 将公钥分发到目标主机
for host in $(cat target_hosts.txt); do
    ssh-copy-id -i /home/nessus_svc/.ssh/id_ed25519.pub nessus_svc@$host
done
# Windows:通过 PowerShell 创建扫描服务账户
New-ADUser -Name "SVC_VulnScan" `
    -SamAccountName "SVC_VulnScan" `
    -UserPrincipalName "SVC_VulnScan@domain.local" `
    -Description "Vulnerability Scanner Service Account" `
    -PasswordNeverExpires $true `
    -CannotChangePassword $true `
    -Enabled $true `
    -AccountPassword (Read-Host -AsSecureString "Enter Password")

# 通过 GPO 将账户添加到目标主机的本地管理员组:
Add-ADGroupMember -Identity "Domain Admins" -Members "SVC_VulnScan"
# 建议使用专用 GPO 授予本地管理员权限,以实现最小权限原则

# 在目标主机上启用 WinRM
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Service\AllowRemote -Value $true
winrm set winrm/config/service '@{AllowUnencrypted="false"}'

步骤 2:配置扫描器凭据

Nessus 配置

{
  "credentials": {
    "add": {
      "Host": {
        "SSH": [{
          "auth_method": "public key",
          "username": "nessus_svc",
          "private_key": "/path/to/id_ed25519",
          "elevate_privileges_with": "sudo",
          "escalation_account": "root"
        }],
        "Windows": [{
          "auth_method": "Password",
          "username": "DOMAIN\\SVC_VulnScan",
          "password": "stored_in_vault",
          "domain": "domain.local"
        }],
        "SNMPv3": [{
          "username": "nessus_snmpv3",
          "security_level": "authPriv",
          "auth_algorithm": "SHA-256",
          "auth_password": "stored_in_vault",
          "priv_algorithm": "AES-256",
          "priv_password": "stored_in_vault"
        }]
      }
    }
  }
}

步骤 3:验证凭据访问

# 测试 SSH 连通性
ssh -i /path/to/key -o ConnectTimeout=10 nessus_svc@target_host "uname -a && sudo dpkg -l | head -5"

# 测试 WinRM 连通性
python3 -c "
import winrm
s = winrm.Session('target_host', auth=('DOMAIN\\\\SVC_VulnScan', 'password'), transport='ntlm')
r = s.run_cmd('systeminfo')
print(r.std_out.decode())
"

# 测试 SNMP v3 连通性
snmpwalk -v3 -u nessus_snmpv3 -l authPriv -a SHA-256 -A authpass -x AES-256 -X privpass target_host sysDescr.0

步骤 4:执行认证扫描

使用 Nessus API 配置并启动扫描:

# 创建带凭据的扫描任务
curl -k -X POST https://nessus:8834/scans \
  -H "X-Cookie: token=$TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "uuid": "'$TEMPLATE_UUID'",
    "settings": {
      "name": "Authenticated Scan - Production",
      "text_targets": "192.168.1.0/24",
      "launch": "ON_DEMAND"
    },
    "credentials": {
      "add": {
        "Host": {
          "SSH": [{"auth_method": "public key", "username": "nessus_svc", "private_key": "/keys/id_ed25519"}],
          "Windows": [{"auth_method": "Password", "username": "DOMAIN\\SVC_VulnScan", "password": "vault_ref"}]
        }
      }
    }
  }'

步骤 5:验证凭据成功

扫描完成后,检查凭据验证结果:

  • 插件 19506(Nessus 扫描信息):显示凭据状态
  • 插件 21745(操作系统安全补丁评估):确认本地检查
  • 插件 117887(本地安全检查):凭据验证
  • 插件 110385(Nessus 凭据检查):目标级别认证状态

凭据安全最佳实践

  1. 使用密钥管理库(HashiCorp Vault、CyberArk、AWS Secrets Manager)存储凭据
  2. 每 90 天或人员变动后轮换凭据
  3. 最小权限原则 — 仅授予最低必要权限
  4. 审计凭据使用情况 — 监控服务账户登录事件
  5. 传输加密 — 优先使用 SSH 密钥而非密码,优先使用 HTTPS 的 WinRM
  6. 每个扫描器使用独立账户 — 切勿跨工具共享凭据
  7. 尽可能禁用扫描服务账户的交互式登录
  8. 在 SIEM 中记录所有认证事件用于扫描账户审计

常见陷阱

  • 使用域管理员账户而非最小权限服务账户
  • 以明文形式在扫描配置中存储凭据
  • 扫描启动前未测试凭据(导致扫描窗口浪费)
  • 未为 Linux 目标配置 sudo/提权
  • Windows UAC 阻断远程凭据检查
  • 防火墙规则阻断扫描器与目标之间的 WMI/WinRM/SSH
  • 多次认证失败触发凭据锁定

相关技能

  • scanning-infrastructure-with-nessus
  • performing-network-vulnerability-assessment
  • implementing-continuous-vulnerability-monitoring
Saved skills