安全测试从入门到精通-安全测试世界观

第1章:安全测试世界观

本章目标:建立对安全测试的完整认知 ------ 理解它是什么、为什么重要、有哪些类型,并开始培养安全思维。


1.1 安全测试到底是什么?

🎬 开篇小故事

想象你是一家餐厅的老板。你花了大价钱装修,请了顶级大厨,菜单精美,服务周到。开业第一天,生意火爆。

但第二天早上,你发现:

  • 🚪 后门根本没锁
  • 🪟 厨房窗户是坏的,任何人可以翻进来
  • 🗑️ 垃圾桶里扔了客人写有信用卡号的收据
  • 🔑 所有员工的钥匙都挂在收银台旁边

这就是没有做安全测试的软件------表面光鲜,内部千疮百孔。

安全测试 ,就是扮演一个"友善的坏人":在真正的坏人动手之前,主动找到所有可能被攻破的入口

🧠 核心定义

复制代码
安全测试 = 评估信息系统安全性 + 发现潜在漏洞 + 验证防护措施有效性
谁在做 做什么 为什么
安全测试工程师 模拟攻击者行为 在漏洞被利用前发现它
白帽黑客 尝试各种入侵手法 帮助组织修复安全缺陷
开发团队 在代码中查找安全问题 提高软件安全性
QA团队 在测试用例中加入安全场景 防止安全回归

🆚 安全测试 vs 功能测试

渲染错误: Mermaid 渲染失败: Parse error on line 4: ...完成操作] A3关注"能不能用" end s ----------------------^ Expecting 'SQE', 'DOUBLECIRCLEEND', 'PE', '-)', 'STADIUMEND', 'SUBROUTINEEND', 'PIPE', 'CYLINDEREND', 'DIAMOND_STOP', 'TAGEND', 'TRAPEND', 'INVTRAPEND', 'UNICODE_TEXT', 'TEXT', 'TAGSTART', got 'STR'

维度 功能测试 安全测试
🎯 关注点 功能是否按照预期工作 功能是否被滥用
🤔 思维方式 "用户会怎么用这个功能?" "攻击者会怎么破坏这个功能?"
📝 测试用例 正常流程、边界值、异常输入 恶意输入、绕过逻辑、权限提升
🛠️ 工具 Selenium, JUnit, Postman Burp Suite, SQLMap, Nmap
👥 视角 用户视角 攻击者视角
🚨 失败后果 功能不可用 数据泄露、系统被控

1.2 CIA三元组 --- 安全的三大基石

这是安全领域最重要的概念,没有之一。所有安全测试的目的,归根结底都是为了保护这三点。
#mermaid-svg-Pzjnw3okc8bdBvfj{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-Pzjnw3okc8bdBvfj .error-icon{fill:#552222;}#mermaid-svg-Pzjnw3okc8bdBvfj .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Pzjnw3okc8bdBvfj .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Pzjnw3okc8bdBvfj .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Pzjnw3okc8bdBvfj .marker.cross{stroke:#333333;}#mermaid-svg-Pzjnw3okc8bdBvfj svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Pzjnw3okc8bdBvfj p{margin:0;}#mermaid-svg-Pzjnw3okc8bdBvfj .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster-label text{fill:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster-label span{color:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster-label span p{background-color:transparent;}#mermaid-svg-Pzjnw3okc8bdBvfj .label text,#mermaid-svg-Pzjnw3okc8bdBvfj span{fill:#333;color:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj .node rect,#mermaid-svg-Pzjnw3okc8bdBvfj .node circle,#mermaid-svg-Pzjnw3okc8bdBvfj .node ellipse,#mermaid-svg-Pzjnw3okc8bdBvfj .node polygon,#mermaid-svg-Pzjnw3okc8bdBvfj .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Pzjnw3okc8bdBvfj .rough-node .label text,#mermaid-svg-Pzjnw3okc8bdBvfj .node .label text,#mermaid-svg-Pzjnw3okc8bdBvfj .image-shape .label,#mermaid-svg-Pzjnw3okc8bdBvfj .icon-shape .label{text-anchor:middle;}#mermaid-svg-Pzjnw3okc8bdBvfj .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-Pzjnw3okc8bdBvfj .rough-node .label,#mermaid-svg-Pzjnw3okc8bdBvfj .node .label,#mermaid-svg-Pzjnw3okc8bdBvfj .image-shape .label,#mermaid-svg-Pzjnw3okc8bdBvfj .icon-shape .label{text-align:center;}#mermaid-svg-Pzjnw3okc8bdBvfj .node.clickable{cursor:pointer;}#mermaid-svg-Pzjnw3okc8bdBvfj .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-Pzjnw3okc8bdBvfj .arrowheadPath{fill:#333333;}#mermaid-svg-Pzjnw3okc8bdBvfj .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Pzjnw3okc8bdBvfj .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Pzjnw3okc8bdBvfj .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Pzjnw3okc8bdBvfj .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-Pzjnw3okc8bdBvfj .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Pzjnw3okc8bdBvfj .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster text{fill:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj .cluster span{color:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Pzjnw3okc8bdBvfj .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-Pzjnw3okc8bdBvfj rect.text{fill:none;stroke-width:0;}#mermaid-svg-Pzjnw3okc8bdBvfj .icon-shape,#mermaid-svg-Pzjnw3okc8bdBvfj .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Pzjnw3okc8bdBvfj .icon-shape p,#mermaid-svg-Pzjnw3okc8bdBvfj .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-Pzjnw3okc8bdBvfj .icon-shape .label rect,#mermaid-svg-Pzjnw3okc8bdBvfj .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Pzjnw3okc8bdBvfj .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-Pzjnw3okc8bdBvfj .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-Pzjnw3okc8bdBvfj :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 安全三要素
机密性

Confidentiality
完整性

Integrity
可用性

Availability
只有授权的人能看
数据加密、访问控制
🔒 像保险箱
数据不被篡改
校验机制、数字签名
📦 像防伪封条
系统随时可用
负载均衡、容灾备份
🏪 像24小时便利店

📖 一一详解

🔒 机密性 (Confidentiality)

一句话:不该看的人看不到。

通俗例子

  • 你给女朋友写的情书,只有她能看 → ✅ 机密性
  • 情书被邮递员拆开看了 → ❌ 机密性被破坏

技术场景

  • 用户密码存在数据库里,但数据被拖库 → 机密性被破坏
  • HTTPS加密传输 → 保护机密性
  • SQL注入读取了其他用户的私密信息 → 机密性被破坏

安全测试关注

  • 是否存在未授权访问
  • 敏感信息是否加密存储和传输
  • 是否存在信息泄露的风险点
📦 完整性 (Integrity)

一句话:数据没有被改过。

通俗例子

  • 你收到快递,防伪封条完好 → ✅ 完整性
  • 收到快递,箱子被人打开又封上了 → ❌ 完整性被破坏

技术场景

  • 银行转账100元被篡改为100000元 → 完整性被破坏
  • 数字签名验证 → 保证完整性
  • 中间人攻击修改HTTP响应内容 → 完整性被破坏

安全测试关注

  • 数据传输过程中能否被篡改
  • 关键操作是否有防篡改机制
  • 数据完整性校验是否到位
🏪 可用性 (Availability)

一句话:你想用的时候能用。

通俗例子

  • 你家楼下的便利店24小时营业 → ✅ 可用性
  • 便利店被一群小混混堵住门口不许进 → ❌ 可用性被破坏

技术场景

  • DDoS攻击导致网站打不开 → 可用性被破坏
  • 勒索软件加密文件 → 可用性被破坏
  • 服务器硬盘故障未备份 → 可用性被破坏

安全测试关注

  • 系统是否存在拒绝服务漏洞
  • 是否有足够的容灾和备份能力
  • 关键资源是否有访问限制

🧪 小测验:识别CIA

判断以下场景破坏了CIA中的哪一个?

场景 答案
黑客删除了数据库中的所有记录 A(可用性)
攻击者通过SQL注入窃取了用户手机号 C(机密性)
中间人修改了网页上的转账金额 I(完整性)
DDoS攻击导致网站无法访问 A(可用性)
员工离职后还能登录公司邮箱 C(机密性)
用户A看到了用户B的订单记录 C(机密性)

1.3 攻击者思维 vs 防御者思维

🤺 思维模式对比

#mermaid-svg-R2pIhpbcKbGBlP7Y{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-R2pIhpbcKbGBlP7Y .error-icon{fill:#552222;}#mermaid-svg-R2pIhpbcKbGBlP7Y .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-R2pIhpbcKbGBlP7Y .marker{fill:#333333;stroke:#333333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .marker.cross{stroke:#333333;}#mermaid-svg-R2pIhpbcKbGBlP7Y svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-R2pIhpbcKbGBlP7Y p{margin:0;}#mermaid-svg-R2pIhpbcKbGBlP7Y .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster-label text{fill:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster-label span{color:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster-label span p{background-color:transparent;}#mermaid-svg-R2pIhpbcKbGBlP7Y .label text,#mermaid-svg-R2pIhpbcKbGBlP7Y span{fill:#333;color:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .node rect,#mermaid-svg-R2pIhpbcKbGBlP7Y .node circle,#mermaid-svg-R2pIhpbcKbGBlP7Y .node ellipse,#mermaid-svg-R2pIhpbcKbGBlP7Y .node polygon,#mermaid-svg-R2pIhpbcKbGBlP7Y .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .rough-node .label text,#mermaid-svg-R2pIhpbcKbGBlP7Y .node .label text,#mermaid-svg-R2pIhpbcKbGBlP7Y .image-shape .label,#mermaid-svg-R2pIhpbcKbGBlP7Y .icon-shape .label{text-anchor:middle;}#mermaid-svg-R2pIhpbcKbGBlP7Y .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .rough-node .label,#mermaid-svg-R2pIhpbcKbGBlP7Y .node .label,#mermaid-svg-R2pIhpbcKbGBlP7Y .image-shape .label,#mermaid-svg-R2pIhpbcKbGBlP7Y .icon-shape .label{text-align:center;}#mermaid-svg-R2pIhpbcKbGBlP7Y .node.clickable{cursor:pointer;}#mermaid-svg-R2pIhpbcKbGBlP7Y .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .arrowheadPath{fill:#333333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-R2pIhpbcKbGBlP7Y .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-R2pIhpbcKbGBlP7Y .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-R2pIhpbcKbGBlP7Y .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster text{fill:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y .cluster span{color:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-R2pIhpbcKbGBlP7Y .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-R2pIhpbcKbGBlP7Y rect.text{fill:none;stroke-width:0;}#mermaid-svg-R2pIhpbcKbGBlP7Y .icon-shape,#mermaid-svg-R2pIhpbcKbGBlP7Y .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-R2pIhpbcKbGBlP7Y .icon-shape p,#mermaid-svg-R2pIhpbcKbGBlP7Y .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-R2pIhpbcKbGBlP7Y .icon-shape .label rect,#mermaid-svg-R2pIhpbcKbGBlP7Y .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-R2pIhpbcKbGBlP7Y .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-R2pIhpbcKbGBlP7Y .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-R2pIhpbcKbGBlP7Y :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 防御者思维
资产是什么
谁可能攻击
怎么防
被攻破了怎么办
攻击者思维
找入口
找弱点
想办法进去
拿到想要的东西

🎯 攻击者思维的"三步走"

当你做安全测试时,你需要切换到这个模式:

复制代码
Step 1: 信息收集
        ↓
    "这个网站用了什么技术?有哪些入口?"
        ↓
Step 2: 寻找弱点
        ↓
    "这个登录框有没有SQL注入?这个搜索框有没有XSS?"
        ↓
Step 3: 尝试利用
        ↓
    "能不能拿到admin权限?能不能读取数据库?"

💡 真实案例:两种思维的碰撞

场景:一个用户信息修改页面,需要输入"原密码"才能修改。

防御者思维:"我加了密码验证,很安全。"

攻击者思维:"这个修改密码的API是不是返回了过多信息?能不能绕过前端验证直接调接口?能不能用session中的用户ID修改别人的密码?"

结果 :攻击者发现前端虽然要求输入原密码,但后端API只是把请求中的user_id改为另一个用户的ID就能修改别人密码------IDOR漏洞(不安全的直接对象引用)

🛡️ 防御者思维的关键原则

  1. 最小权限原则(Principle of Least Privilege)

    只给一个人完成工作所需的最小权限。

    👉 就像机场只给清洁工进入候机厅的权限,而不是驾驶舱的权限。

  2. 纵深防御(Defense in Depth)

    不要依赖单层防御。

    👉 就像城堡有护城河、城墙、吊桥、卫兵------一层被突破还有下一层。

  3. 永不信任用户输入

    所有用户的输入都是"有罪的",直到被证明是安全的。

    👉 就像安检:每一位乘客都要被检查,不管看起来多友善。

  4. 默认安全(Secure by Default)

    系统的默认配置应该是最安全的配置。

    👉 就像新手机的默认设置就是锁屏的。


1.4 安全测试类型全景图

安全测试是一个大家族,各成员各有专攻:
#mermaid-svg-xPjajTlyt8jGqmcP{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-xPjajTlyt8jGqmcP .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-xPjajTlyt8jGqmcP .error-icon{fill:#552222;}#mermaid-svg-xPjajTlyt8jGqmcP .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-xPjajTlyt8jGqmcP .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-xPjajTlyt8jGqmcP .marker{fill:#333333;stroke:#333333;}#mermaid-svg-xPjajTlyt8jGqmcP .marker.cross{stroke:#333333;}#mermaid-svg-xPjajTlyt8jGqmcP svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-xPjajTlyt8jGqmcP p{margin:0;}#mermaid-svg-xPjajTlyt8jGqmcP .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-xPjajTlyt8jGqmcP .cluster-label text{fill:#333;}#mermaid-svg-xPjajTlyt8jGqmcP .cluster-label span{color:#333;}#mermaid-svg-xPjajTlyt8jGqmcP .cluster-label span p{background-color:transparent;}#mermaid-svg-xPjajTlyt8jGqmcP .label text,#mermaid-svg-xPjajTlyt8jGqmcP span{fill:#333;color:#333;}#mermaid-svg-xPjajTlyt8jGqmcP .node rect,#mermaid-svg-xPjajTlyt8jGqmcP .node circle,#mermaid-svg-xPjajTlyt8jGqmcP .node ellipse,#mermaid-svg-xPjajTlyt8jGqmcP .node polygon,#mermaid-svg-xPjajTlyt8jGqmcP .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-xPjajTlyt8jGqmcP .rough-node .label text,#mermaid-svg-xPjajTlyt8jGqmcP .node .label text,#mermaid-svg-xPjajTlyt8jGqmcP .image-shape .label,#mermaid-svg-xPjajTlyt8jGqmcP .icon-shape .label{text-anchor:middle;}#mermaid-svg-xPjajTlyt8jGqmcP .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-xPjajTlyt8jGqmcP .rough-node .label,#mermaid-svg-xPjajTlyt8jGqmcP .node .label,#mermaid-svg-xPjajTlyt8jGqmcP .image-shape .label,#mermaid-svg-xPjajTlyt8jGqmcP .icon-shape .label{text-align:center;}#mermaid-svg-xPjajTlyt8jGqmcP .node.clickable{cursor:pointer;}#mermaid-svg-xPjajTlyt8jGqmcP .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-xPjajTlyt8jGqmcP .arrowheadPath{fill:#333333;}#mermaid-svg-xPjajTlyt8jGqmcP .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-xPjajTlyt8jGqmcP .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-xPjajTlyt8jGqmcP .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-xPjajTlyt8jGqmcP .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-xPjajTlyt8jGqmcP .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-xPjajTlyt8jGqmcP .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-xPjajTlyt8jGqmcP .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-xPjajTlyt8jGqmcP .cluster text{fill:#333;}#mermaid-svg-xPjajTlyt8jGqmcP .cluster span{color:#333;}#mermaid-svg-xPjajTlyt8jGqmcP div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-xPjajTlyt8jGqmcP .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-xPjajTlyt8jGqmcP rect.text{fill:none;stroke-width:0;}#mermaid-svg-xPjajTlyt8jGqmcP .icon-shape,#mermaid-svg-xPjajTlyt8jGqmcP .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-xPjajTlyt8jGqmcP .icon-shape p,#mermaid-svg-xPjajTlyt8jGqmcP .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-xPjajTlyt8jGqmcP .icon-shape .label rect,#mermaid-svg-xPjajTlyt8jGqmcP .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-xPjajTlyt8jGqmcP .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-xPjajTlyt8jGqmcP .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-xPjajTlyt8jGqmcP :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 安全测试类型
静态应用安全测试

SAST
动态应用安全测试

DAST
交互式安全测试

IAST
渗透测试

Penetration Testing
风险评估

Risk Assessment
漏洞扫描

Vulnerability Scanning
看源码找问题

白盒测试
运行中测漏洞

黑盒测试
结合代码插桩

灰盒测试
模拟真实攻击

黑客视角
SonarQube, Fortify

Checkmarx
Burp Suite, AppScan

AWVS, OWASP ZAP
手动+工具组合

实战演练
VA_DESC
Nessus, OpenVAS

Nexpose

📊 各类型对比

类型 时机 需要源码? 覆盖度 误报率 自动程度
SAST 开发阶段 ✅ 是
DAST 测试阶段 ❌ 否 中高
IAST 测试阶段 部分
渗透测试 上线前 看类型 取决于人
漏洞扫描 任何阶段 ❌ 否

🧑‍💻 这个教程教你什么?

本教程主要聚焦于 DAST + 渗透测试 方向,因为:

  1. 零基础友好 ------ 不需要编程基础
  2. 实战性强 ------ 学完就能用
  3. 覆盖面广 ------ 覆盖大部分安全测试场景
  4. 就业前景好 ------ 市场对渗透测试工程师需求大

🗣️ 作者说:学完这套教程,你再看任何网站都会自带"安全滤镜"------这是一种超能力,也是一种"诅咒"(因为你会忍不住想测每个功能有没有漏洞😂)。


1.5 安全测试的道德与法律边界

⚠️ 非常重要!

#mermaid-svg-dMybcQFoYmR50j1V{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-dMybcQFoYmR50j1V .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-dMybcQFoYmR50j1V .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-dMybcQFoYmR50j1V .error-icon{fill:#552222;}#mermaid-svg-dMybcQFoYmR50j1V .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-dMybcQFoYmR50j1V .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-dMybcQFoYmR50j1V .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-dMybcQFoYmR50j1V .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-dMybcQFoYmR50j1V .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-dMybcQFoYmR50j1V .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-dMybcQFoYmR50j1V .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-dMybcQFoYmR50j1V .marker{fill:#333333;stroke:#333333;}#mermaid-svg-dMybcQFoYmR50j1V .marker.cross{stroke:#333333;}#mermaid-svg-dMybcQFoYmR50j1V svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-dMybcQFoYmR50j1V p{margin:0;}#mermaid-svg-dMybcQFoYmR50j1V .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-dMybcQFoYmR50j1V .cluster-label text{fill:#333;}#mermaid-svg-dMybcQFoYmR50j1V .cluster-label span{color:#333;}#mermaid-svg-dMybcQFoYmR50j1V .cluster-label span p{background-color:transparent;}#mermaid-svg-dMybcQFoYmR50j1V .label text,#mermaid-svg-dMybcQFoYmR50j1V span{fill:#333;color:#333;}#mermaid-svg-dMybcQFoYmR50j1V .node rect,#mermaid-svg-dMybcQFoYmR50j1V .node circle,#mermaid-svg-dMybcQFoYmR50j1V .node ellipse,#mermaid-svg-dMybcQFoYmR50j1V .node polygon,#mermaid-svg-dMybcQFoYmR50j1V .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-dMybcQFoYmR50j1V .rough-node .label text,#mermaid-svg-dMybcQFoYmR50j1V .node .label text,#mermaid-svg-dMybcQFoYmR50j1V .image-shape .label,#mermaid-svg-dMybcQFoYmR50j1V .icon-shape .label{text-anchor:middle;}#mermaid-svg-dMybcQFoYmR50j1V .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-dMybcQFoYmR50j1V .rough-node .label,#mermaid-svg-dMybcQFoYmR50j1V .node .label,#mermaid-svg-dMybcQFoYmR50j1V .image-shape .label,#mermaid-svg-dMybcQFoYmR50j1V .icon-shape .label{text-align:center;}#mermaid-svg-dMybcQFoYmR50j1V .node.clickable{cursor:pointer;}#mermaid-svg-dMybcQFoYmR50j1V .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-dMybcQFoYmR50j1V .arrowheadPath{fill:#333333;}#mermaid-svg-dMybcQFoYmR50j1V .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-dMybcQFoYmR50j1V .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-dMybcQFoYmR50j1V .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-dMybcQFoYmR50j1V .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-dMybcQFoYmR50j1V .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-dMybcQFoYmR50j1V .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-dMybcQFoYmR50j1V .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-dMybcQFoYmR50j1V .cluster text{fill:#333;}#mermaid-svg-dMybcQFoYmR50j1V .cluster span{color:#333;}#mermaid-svg-dMybcQFoYmR50j1V div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-dMybcQFoYmR50j1V .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-dMybcQFoYmR50j1V rect.text{fill:none;stroke-width:0;}#mermaid-svg-dMybcQFoYmR50j1V .icon-shape,#mermaid-svg-dMybcQFoYmR50j1V .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-dMybcQFoYmR50j1V .icon-shape p,#mermaid-svg-dMybcQFoYmR50j1V .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-dMybcQFoYmR50j1V .icon-shape .label rect,#mermaid-svg-dMybcQFoYmR50j1V .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-dMybcQFoYmR50j1V .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-dMybcQFoYmR50j1V .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-dMybcQFoYmR50j1V :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 是
不是

没有

不是
你想测试一个系统
是你的系统吗?
✅ 放心测
有书面授权吗?
是公开的漏洞赏金

平台吗?
❌ 千万别碰!

这是违法的!

📜 安全测试的"六不准"原则

# 原则 说明
1 不测试未经授权的系统 没拿到 Permission 之前,管好你的手
2 不窃取数据 发现漏洞不是为了拿数据,而是证明存在漏洞
3 不破坏系统 点到为止,能证明漏洞存在就停
4 不越界测试 只在授权范围内测试
5 及时报告 发现漏洞后第一时间通知相关负责人
6 保密协议 不公开披露未修复的漏洞

💀 真实的"踩红线"案例

某安全研究员发现了一个电商网站的漏洞,未授权就进行了深入测试,从服务器下载了用户数据。虽然他的初衷是"证明漏洞的严重性",但最终被以"非法获取计算机信息系统数据罪"起诉,面临数年刑期。

教训:没有授权,再牛的测试也是犯罪。


📝 本章小结

你学到了什么 关键要点
安全测试的定义 主动发现漏洞,扮演友善的"坏人"
CIA三要素 机密性、完整性、可用性
攻击者思维 从"怎么用"到"怎么破坏"的转变
测试类型 SAST/DAST/IAST/渗透测试/漏洞扫描
法律边界 未经授权不测试,这是底线

🔑 本章金句

"安全不是一种产品,而是一种思维方式。"

--- Bruce Schneier(世界著名安全专家)


🧠 思考题

  1. 你正在用的某个APP,如果让你从攻击者角度找问题,你会从哪里入手?
  2. 如果一个功能测试案例和一个安全测试案例冲突了(比如安全方案影响用户体验),你觉得该怎么取舍?
  3. 你能举出生活中三个"安全措施"的例子吗?它们保护的是CIA中的哪一个?

继续下一章 → 搭建你的安全实验室


📎 相关章节:下一章我们开始动手搭建安全测试环境,准备好你的武器库!

相关推荐
Luminbox紫创测控1 天前
GB/T 5137.3 2020标准:汽车安全玻璃耐辐照与耐模拟气候试验方法
人工智能·测试工具·汽车·安全性测试·uv·测试标准
国科安芯2 天前
空间在轨服务机器人通信链路中抗辐射收发器的应用研究
网络·数据库·算法·机器人·安全性测试
国科安芯4 天前
航天器多路并联大功率电源系统设计与ASP4644均流特性分析
单片机·嵌入式硬件·fpga开发·安全性测试
介一安全4 天前
【SRC】基础思路篇10:越权与未授权访问完全指南
web安全·安全性测试·src·越权
水龙吟啸23 天前
机器学习安全:图像多分类任务的测试时对抗样本转移攻击实战(一)
机器学习·图像分类·安全性测试·asr·混淆矩阵·auc·转移攻击
Luminbox紫创测控1 个月前
金属卤素灯工作原理与汽车零部件老化测试应用
测试工具·汽车·安全性测试·测试标准
国科安芯1 个月前
商业航天通信载荷数字处理单元供电架构研究——基于ASP7A84AS的高精度低压差线性稳压器技术分析
前端·单片机·嵌入式硬件·fpga开发·架构·安全性测试
大棉花哥哥1 个月前
Cybellum之Products(产品管理)模块技术详解
安全性测试·车联网
Luminbox紫创测控1 个月前
AM1.5G光谱在LED太阳模拟器中的工程实现:光谱匹配与均匀性优化(A+级指标)
人工智能·测试工具·5g·安全性测试