WebAuthn模拟器

用于渗透测试和自动化测试的WebAuthn软令牌模拟器,无需物理硬件即可模拟安全密钥和密码钥匙。

  • by pccr10001
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 pccr10001/webauthn-mcp

使用说明

WebAuthn MCP

用于渗透测试和自动化测试的WebAuthn软令牌模拟器。此工具允许您模拟WebAuthn身份验证器(安全密钥、密钥)进行测试,而不需要物理硬件。

特性

  • 🔐 生成WebAuthn注册和身份验证响应
  • 🎯 模拟各种身份验证器行为和边缘情况
  • 🔧 自定义身份验证器标志(UV、UP、BE、BS)
  • 🆔 设置自定义AAGUID以模拟特定的身份验证器
  • 🌐 用于轻松集成的HTTP API
  • 🤖 MCP(模型上下文协议)服务器支持
  • 💾 持久令牌存储

快速开始

构建

go build -o webauthn-mcp.exe .

以HTTP服务器运行

./webauthn-mcp.exe

服务器将在端口8080上启动(可通过以下方式配置 config.yaml).

作为MCP服务器运行

./webauthn-mcp.exe mcp

配置

创建或编辑 config.yaml:

server:
  port: 8080

storage:
  path: "./tokens"

security:
  api_key: "your-secret-key"  # Or set WEBAUTHN_MCP_API_KEY env var

HTTP API

许可证管理

创建令牌

POST /api/token
Content-Type: application/json

{
  "name": "My Test Token"
}

列出令牌

GET /api/token

获取令牌信息

GET /api/token/:id

除令牌

DELETE /api/token/:id

凭据管理

列出凭据

GET /api/token/:id/credentials

删除凭据

DELETE /api/token/:id/credentials/:credId

WebAuthn操作

注册

生成WebAuthn注册响应:

POST /api/token/:id/register
Content-Type: application/json

{
  "request": {
    "challenge": "base64url-encoded-challenge",
    "rp": {
      "id": "example.com",
      "name": "Example Corp"
    },
    "user": {
      "id": "base64url-encoded-user-id",
      "name": "user@example.com",
      "displayName": "User Name"
    },
    "attestation": "none",
    "residentKey": "required"
  },
  "overrides": {
    "user_verification": false,
    "backup_eligible": true,
    "aaguid": "84CVQH8UScGos4-BOyJVQQ"
  }
}

替代选项:

  • origin -自定义原点(默认值: https://{rp.id})
  • rp_id -覆盖RP ID
  • user_verification -设置UV标志(默认值:true)
  • user_present -设置UP标志(默认值:true)
  • backup_eligible -设置BE标志(默认值:false)
  • backup_state -设置BS标志(默认值:false)
  • counter -设置签名计数器(默认值:0)
  • aaguid -设置AAGUID(base64url,16字节,默认值:全零)
  • attestation_type -“无”或“打包”(默认值:“无”)
  • transport -传输数组(默认值:[“internal”])
  • invalid_signature -生成无效的测试签名(默认值:false)
  • extensions -客户端扩展结果

认证

生成WebAuthn身份验证响应:

POST /api/token/:id/authenticate
Content-Type: application/json

{
  "credential_id": "base64url-credential-id",
  "request": {
    "challenge": "base64url-encoded-challenge",
    "rpId": "example.com",
    "allowCredentials": [
      {
        "type": "public-key",
        "id": "base64url-credential-id"
      }
    ]
  },
  "overrides": {
    "user_verification": false,
    "counter": 42
  }
}

替代选项:

  • origin -自定义来源
  • rp_id -覆盖RP ID
  • user_verification -设置UV标志
  • user_present -设置UP标志
  • counter -设置签名计数器
  • invalid_signature -生成无效签名
  • wrong_credential -使用错误的凭据ID
  • extensions -客户端扩展结果

MCP工具

当作为MCP服务器运行时,可以使用以下工具:

  • create_token -创建新的软令牌
  • delete_token -删除令牌
  • list_tokens -列出所有令牌
  • get_token_info -获取令牌详细信息
  • list_credentials -列出令牌的凭据
  • delete_credential -删除凭据
  • register -生成注册响应
  • authenticate -生成身份验证响应

用例

渗透测试

测试WebAuthn实现的安全漏洞:

  • 签名处理无效
  • 计数器回滚检测
  • 原产地验证
  • RP ID验证
  • 用户验证旁路

自动化测试

集成到CI/CD管道中,在没有物理身份验证器的情况下测试WebAuthn流。

发展

开发和调试WebAuthn实现,而不需要多个物理安全密钥。

项目结构

.
├── config/              # Configuration management
├── internal/
│   ├── api/            # HTTP API (Gin framework)
│   ├── mcp/            # MCP server implementation
│   ├── token/          # Token and credential storage
│   └── webauthn/       # WebAuthn response generation
├── tokens/             # JSON storage for tokens
├── config.yaml         # Configuration file
└── main.go            # Entry point

安全注意事项

⚠️ 此工具仅用于测试目的!

  • 请勿在生产环境中使用
  • 生成的凭据存储在纯JSON文件中
  • 私钥未加密存储
  • 默认情况下没有速率限制或身份验证
  • 仅适用于受控测试环境

例子

示例1:基本注册

# Create a token
curl -X POST http://localhost:8080/api/token \
  -H "Content-Type: application/json" \
  -d '{"name": "Test Token"}'

# Register a credential
curl -X POST http://localhost:8080/api/token/{token-id}/register \
  -H "Content-Type: application/json" \
  -d '{
    "request": {
      "challenge": "randomChallenge123",
      "rp": {"id": "example.com", "name": "Example"},
      "user": {"id": "user123", "name": "test@example.com", "displayName": "Test User"},
      "attestation": "none",
      "residentKey": "required"
    }
  }'

示例2:模拟硬件安全密钥

# Register with hardware security key characteristics
curl -X POST http://localhost:8080/api/token/{token-id}/register \
  -H "Content-Type: application/json" \
  -d '{
    "request": {
      "challenge": "randomChallenge123",
      "rp": {"id": "example.com", "name": "Example"},
      "user": {"id": "user123", "name": "test@example.com", "displayName": "Test User"},
      "attestation": "none",
      "residentKey": "required"
    },
    "overrides": {
      "user_verification": false,
      "backup_eligible": true,
      "aaguid": "84CVQH8UScGos4-BOyJVQQ"
    }
  }'

示例3:测试无效签名

# Generate authentication with invalid signature
curl -X POST http://localhost:8080/api/token/{token-id}/authenticate \
  -H "Content-Type: application/json" \
  -d '{
    "credential_id": "credential-id-here",
    "request": {
      "challenge": "randomChallenge456",
      "rpId": "example.com"
    },
    "overrides": {
      "invalid_signature": true
    }
  }'

许可证

MIT许可证-有关详细信息,请参阅许可证文件

贡献

欢迎投稿!请随时提交问题或拉取请求。

免责声明

此工具仅用于教育和测试目的。用户有责任确保在使用此工具时遵守适用的法律法规。