章节主线
Malicious Code and Application Attacks.
恶意代码与应用攻击。
前半讲恶意软件家族,后半讲应用和 Web 攻击。
Domain 8 与 Domain 7/3 都会交叉出现。
左侧是英文原文摘录、中文直译、小白解释和考点提醒;右侧是对应画报。手机端会先显示画报,点击图片可放大查看。
第 21 章把恶意软件和应用攻击收尾串起来。重点不是死背每个名字,而是理解传播方式、触发条件、载荷、利用点和防护思路。
Malicious Code and Application Attacks.
恶意代码与应用攻击。
前半讲恶意软件家族,后半讲应用和 Web 攻击。
Domain 8 与 Domain 7/3 都会交叉出现。
Malware includes a broad range of threats.
恶意软件包含广泛威胁。
它利用网络、操作系统、软件和人员弱点传播或执行载荷。
Malware is an umbrella term。
Malware categories have blurry lines.
恶意软件类别边界模糊。
同一恶意软件可能同时像木马、蠕虫、勒索软件或后门。
按特征判断,不要只按名称判断。
Viruses have propagation and payload execution.
病毒有传播和载荷执行。
传播说明怎么扩散,载荷说明做什么坏事。
Propagation vs payload 是理解恶意代码的基本框架。
Sources include script kiddies and organized criminals.
来源包括脚本小子和有组织犯罪者。
现代恶意软件也可能来自 APT、犯罪集团、内部人员和供应链。
APT often has resources and may use zero-days。
Attackers exploit sloppy coding practices.
攻击者利用粗糙编码实践。
缓冲区溢出、注入、XSS、CSRF、IDOR 都来自设计或实现缺陷。
Secure coding counters many application attacks。
Use defense-in-depth controls.
使用纵深防御控制。
补丁、反恶意软件、EDR、最小权限、安全编码、WAF、日志都要组合。
没有单一工具能覆盖全部风险。
Understand the technique and countermeasure.
理解技术和对策。
题目通常给症状,让你识别攻击类型或最佳控制。
看到“未验证输入”先想注入、XSS、溢出等。
病毒通常依赖宿主或用户动作传播。考试常考 MBR/Boot、文件感染、宏病毒、服务注入,以及多重感染、隐身、多态和加密病毒。
A virus spreads from system to system.
病毒从系统传播到系统。
它通常附着在宿主文件、启动区或文档宏上。
Major difference: virus needs host/user action; worm self-propagates。
MBR viruses attack the master boot record.
MBR 病毒攻击主引导记录。
它在操作系统加载前取得控制。
TPM 和安全启动类控制可帮助防护。
Boot sector viruses infect boot sectors.
启动区病毒感染启动扇区。
与 MBR 病毒效果相似,影响启动流程。
MBR and boot sector are boot-process virus topics。
File infectors affect executable files.
文件感染病毒影响可执行文件。
它修改或替换程序文件来复制自身。
Hash comparison can detect modified executable files。
Macro viruses use application macros.
宏病毒使用应用宏。
Office 文档宏曾是常见传播途径。
Macro virus spreads through documents。
Service injection hides within trusted processes.
服务注入隐藏在受信任进程中。
恶意代码注入浏览器、播放器等进程,试图逃避检测。
Keep web content viewing software patched。
Polymorphic and encrypted viruses evade signatures.
多态和加密病毒逃避签名。
多态改变自身代码,加密病毒改变磁盘存储形态。
Signature-based detection may struggle, but vendors adapt。
Stealth and multipartite viruses hide or use multiple methods.
隐身和多重感染病毒会隐藏或使用多种方法。
隐身欺骗检测,多重感染结合文件、启动区等方式。
Multipartite = more than one propagation method。
逻辑炸弹按条件触发,木马伪装成有用程序,RAT 提供远程控制,蠕虫可自我传播,僵尸网络把大量主机纳入攻击者控制。
Logic bombs lie dormant until triggered.
逻辑炸弹休眠直到被触发。
触发条件可能是时间、程序启动、登录或特定事件。
Logic bomb often planted by insiders/developers。
A Trojan appears benevolent but carries a payload.
木马看似善意但携带恶意载荷。
用户以为在安装有用软件,其实安装了恶意功能。
Trojan does not self-replicate like a worm。
Rogue antivirus tricks users.
流氓杀软欺骗用户。
伪装成安全软件,诱导付款或窃取信息。
Rogue AV is a Trojan category。
RATs open backdoors for remote control.
RAT 打开后门供远程控制。
攻击者可远程管理受感染系统。
Remote access Trojan = backdoor/control。
Botnets are computers under attacker control.
僵尸网络是受攻击者控制的计算机集合。
受控主机可用于 DDoS、垃圾邮件、挖矿或凭据攻击。
Botmaster controls botnet。
Worms spread themselves.
蠕虫会自我传播。
不需要附着到宿主文件,能在网络中快速扩散。
Worm vs virus 是本章高频。
Patches can stop worm outbreaks.
补丁可阻止蠕虫爆发。
Code Red 等蠕虫利用未打补丁漏洞,及时补丁可显著降低风险。
Patch management is a malware prevention control。
Stuxnet caused physical damage.
Stuxnet 造成物理损害。
恶意软件不仅影响数据,也可能影响工业控制和现实设施。
Stuxnet is a sophisticated worm/APT example。
现代恶意软件更强调勒索、脚本自动化、内存驻留和零日利用。防护要靠备份、最小权限、补丁、行为检测、应用控制和响应准备组合。
Spyware spies on user activity.
间谍软件监视用户活动。
它可能窃取账号、密码、浏览行为或敏感数据。
Spyware and adware are often PUPs。
Adware displays advertisements.
广告软件显示广告。
更恶意版本可能跟踪购物行为或重定向访问。
Adware differs by purpose but may still be unwanted。
Ransomware weaponizes cryptography.
勒索软件武器化密码学。
它加密关键文件并索要赎金,有时还威胁公开数据。
Backups are critical for ransomware resilience。
Payment does not guarantee recovery.
付款不保证恢复。
支付还可能违反制裁或激励后续攻击,应咨询法律团队。
Do not assume paying ransom is correct。
APT groups automate activity with scripts.
APT 组织用脚本自动化活动。
脚本可自动执行权限提升、持久化和横向移动等重复任务。
Scripts increase attacker efficiency。
Fileless attacks never write files to disk.
无文件攻击不写文件到磁盘。
载荷可能在内存中运行,传统依赖磁盘文件检测的工具较难发现。
Behavior/EDR controls help detect fileless malware。
Zero-days are flaws not yet addressed.
零日是尚未被修复的缺陷。
厂商和防护工具还没准备好,存在窗口期。
Window of vulnerability 是关键术语。
Use overlapping security controls.
使用重叠安全控制。
补丁、反恶意软件、应用控制、内容过滤、配置管理和最小权限一起用。
Zero-day drives defense-in-depth。
现代防护不只靠传统签名。反恶意软件、启发式检测、沙箱、文件完整性监控、EDR、MDR 和 UEBA 共同提供检测、阻断、隔离和响应能力。
Signature-based detection uses known characteristics.
签名检测使用已知特征。
工具用病毒定义库寻找已知恶意软件特征。
Definitions must be frequently updated。
Disinfect, quarantine, or delete infected files.
清除、隔离或删除感染文件。
能修复就消毒,不能修复就隔离,危险时可删除。
Antivirus response actions are testable。
Heuristics analyze behavior.
启发式分析行为。
查找提权、隐藏痕迹、修改系统文件等可疑行为。
Behavior detection helps with unknown malware。
Suspicious files may run in isolation.
可疑文件可在隔离环境运行。
观察其行为,再更新全组织防护。
Sandboxing supports malware analysis。
Centralized monitoring and control.
集中监控和控制。
管理员可统一策略、监控告警和配置终端保护。
Enterprise anti-malware should be centrally managed。
File integrity monitoring compares hashes.
文件完整性监控比较哈希。
关键文件变化且无批准变更时,可能是恶意修改。
Hash value changes indicate file modification。
EDR protects endpoints; MDR is managed service.
EDR 保护终端;MDR 是托管服务。
EDR 检测响应,MDR 由供应商提供安装、配置和监控。
MDR = managed detection and response。
UEBA profiles user and entity behavior.
UEBA 建立用户和实体行为画像。
它关注用户/实体偏离正常行为,EDR 更关注终端。
UEBA focus: user/entity; EDR focus: endpoint。
很多应用攻击源于边界检查不足、状态切换窗口、隐藏入口或权限控制缺陷。防护靠安全编码、补丁、最小权限和审查。
Buffer overflow occurs with oversized input.
输入过大可能造成缓冲区溢出。
超出变量空间的输入会破坏附近内存,严重时可能影响执行流程。
Defense: bounds checking and input validation。
Check length, type, and allowed range.
检查长度、类型和允许范围。
数字字段不能接收字母,5 字符缓冲区不能接受 10 字符输入。
Parameter checking prevents many flaws。
Time of check differs from time of use.
检查时间与使用时间不同。
攻击者在检查通过后、真正使用前替换资源。
TOCTTOU is a race condition/state attack。
Backdoors bypass normal access restrictions.
后门绕过正常访问限制。
未公开入口可能来自开发调试、恶意植入或被感染系统。
Undocumented command sequence is backdoor clue。
Privilege escalation expands access.
提权扩大访问。
攻击者从普通用户提升到管理员或 root。
Least privilege limits impact。
Rootkits help gain or hide privileged access.
Rootkit 帮助获得或隐藏特权访问。
它可能修改系统行为,隐藏进程、文件或账号。
Patch management defends against many rootkits。
Apply security patches consistently.
一致地应用安全补丁。
很多提权和 rootkit 利用已知系统漏洞。
Patch management is a simple but critical precaution。
Address state attacks in security models.
在安全模型中处理状态攻击。
资源检查与使用之间的窗口要通过锁、事务或重新验证缩小。
Race conditions attack timing and transitions。
注入攻击把用户输入当作代码或命令执行。SQL 注入会绕过应用控制直接影响数据库,破坏机密性、完整性和可用性。
Injection sends code as input.
注入把代码作为输入发送。
如果应用把输入拼进后端命令,攻击者可改变执行含义。
Injection is improper input handling。
Examples include SQL, LDAP, XML, and command injection.
示例包括 SQL、LDAP、XML 和命令注入。
名称通常说明被利用的后端系统或载荷类型。
Injection is not only SQL。
SQL injection manipulates database queries.
SQL 注入操纵数据库查询。
攻击者可读取、修改、删除或影响数据库。
SQL injection affects C/I/A。
Blind SQL injection works without direct output.
盲 SQL 注入没有直接输出也能工作。
通过页面内容变化或响应时间差推断结果。
Content-based and timing-based blind SQL。
Parameter pollution sends duplicate variables.
参数污染发送重复变量。
利用平台处理重复参数的不一致来绕过过滤。
Patch platforms and normalize input handling。
Validate input on the server side.
在服务器端验证输入。
客户端验证能被绕过,服务器端必须按白名单验证。
Server-side allowlist is strongest validation。
Parameterized queries treat input as data.
参数化查询把输入当作数据。
查询结构和用户数据分离,避免输入变成代码。
Best database-level control for SQL injection。
WAF and least privilege add layers.
WAF 和最小权限增加层次。
WAF 不能替代安全编码,数据库账号也不该拥有过大权限。
Use multiple controls, not WAF alone。
Web 应用常通过参数、路径和文件处理访问资源。若缺少对象级授权、路径规范化和上传隔离,就会出现 IDOR、目录遍历、文件包含和 Web Shell 风险。
Insecure direct object reference lacks authorization checks.
不安全直接对象引用缺少授权检查。
用户能猜到对象编号,不代表有权访问对应对象。
Object-level authorization is the core defense。
Arguments may reference backend objects.
参数可能引用后端对象。
应用必须对每次请求检查身份和权限。
Authentication alone is insufficient; need authorization。
Directory traversal navigates file paths.
目录遍历操纵文件路径。
路径处理不当可能越过 Web 目录访问其他文件。
Canonicalization/normalization helps defense。
File inclusion executes unexpected files.
文件包含会执行意外文件。
应用把用户控制的文件包含到执行流程中,会非常危险。
Local and remote file inclusion are variants。
Web shells provide command access through web ports.
Web Shell 通过 Web 端口提供命令入口。
攻击者可借 Web 层维持控制,流量更难区分。
Upload controls and execution isolation are important。
Restrict file uploads and execution.
限制上传和执行。
控制文件类型、大小、存储位置、扫描和执行权限。
Uploaded files should not be executable by default。
Use least privilege for web processes.
Web 进程使用最小权限。
即使应用被攻破,也限制它能读取或执行的范围。
Least privilege reduces impact。
Monitor object and file access logs.
监控对象和文件访问日志。
异常对象遍历、上传和路径访问都应被记录和告警。
Detection complements prevention。
XSS、CSRF、SSRF 和会话劫持都在滥用信任关系:用户信任网站、网站信任已登录用户、服务器信任输入 URL 或应用信任会话令牌。
XSS inserts attacker HTML into a page.
XSS 把攻击者 HTML 插入页面。
网站反射或存储了不安全输入,浏览器把它当页面内容处理。
XSS exploits user's trust in website。
Reflected XSS reflects input in a response.
反射型 XSS 在响应中反射输入。
恶意输入通常通过链接或表单进入页面。
Reflected input is a clue。
Stored XSS remains on the server.
存储型 XSS 保留在服务器上。
留言板、评论、资料等存储内容会影响后续访问者。
Persistent XSS = stored on server。
DOM XSS modifies the browser DOM.
DOM XSS 修改浏览器 DOM。
不一定出现在服务器返回的 HTML 里。
DOM-based XSS is sneaky。
CSRF abuses trust in a user's browser.
CSRF 滥用对用户浏览器的信任。
用户已登录,攻击者诱导其浏览器向受信站点发送请求。
CSRF uses trust remote site has in user。
SSRF tricks a server into visiting a URL.
SSRF 诱导服务器访问 URL。
服务器可能能访问攻击者不能直接访问的内部资源。
Use server-side URL allowlists。
Session hijacking takes over an authorized session.
会话劫持接管授权会话。
攻击者窃取或滥用会话信息来冒充用户。
Cookies, TLS, anti-replay, expiration matter。
Use validation, encoding, tokens, and cookie controls.
使用验证、编码、令牌和 Cookie 控制。
输出编码防 XSS,CSRF token 和 SameSite 降低 CSRF,会话过期降低劫持风险。
Match control to attack type。
应用防护不是单一 WAF。服务器端输入验证、输出编码、参数化查询、存储过程、WAF、数据库最小权限和安全密码存储都要协同。
Input validation is the most important control.
输入验证是最重要的控制。
任何允许用户输入的应用都应验证输入。
Allowlisting is the most effective validation。
Validation should occur server-side.
验证应发生在服务器端。
客户端控制容易被绕过,服务器必须自己验证。
Server-side validation is required。
Allowlisting describes expected input.
允许列表描述期望输入。
例如年龄字段只允许合理范围整数。
Allowlist beats blocklist when feasible。
Blocklisting lists malicious input.
阻止列表列出恶意输入。
它可能漏掉变形输入,也可能误伤合法字符。
Blocklist is less complete。
Output encoding transforms dangerous content.
输出编码转换危险内容。
把用户输入安全显示,而不是让浏览器执行。
HTML/URL/JavaScript/CSS encoding contexts differ。
A WAF sits in front of a web server.
WAF 位于 Web 服务器前。
它检查发往应用的请求,阻止明显恶意流量。
WAF is layered defense, not a replacement for secure code。
Parameterized queries pass variables safely.
参数化查询安全传递变量。
用户输入作为数据进入预定义查询。
Common SQL injection defense。
Databases storing personal data create risk.
存储个人数据的数据库会带来风险。
密码应加盐哈希,敏感数据应最小化、加密和限制访问。
Rainbow table resistance comes from salts/strong hashes。
发布安全关注代码来源、完整性、第三方组件、仓库控制和常见编程缺陷。代码签名能证明来源和完整性,但不证明代码一定安全。
Code signing verifies authenticity and integrity.
代码签名验证真实性和完整性。
浏览器或系统可确认代码来自签名者且未被修改。
Code signing does not prove code is nonmalicious。
Third-party libraries share code.
第三方库共享代码。
库和 SDK 节省开发时间,但漏洞也会被继承。
Know where third-party code is used。
Outsourced code needs the same testing.
外包代码需要同等测试。
不是内部开发不代表可以少测。
Subject outsourced code to same level of testing。
Code repositories store source files centrally.
代码仓库存储源文件。
仓库支持版本控制、回滚、协作和复用。
Access control and secret scanning matter。
Hashes verify approved code.
哈希验证已批准代码。
发布到生产的代码哈希应匹配批准版本。
Code integrity measurement detects modification。
Scalability and elasticity support growth.
可扩展性和弹性支持增长。
扩展性增加资源;弹性可按需扩上扩下。
Elasticity includes scaling down。
Comments can reveal design details.
注释可能泄露设计细节。
源代码可保留注释,部署版本不应泄露敏感注释。
Comments may give attackers a road map。
Hard-coded credentials and memory errors create risk.
硬编码凭据和内存错误带来风险。
硬编码密码、内存泄漏、NULL 指针、过度详细错误信息都要避免。
Verbose errors and hard-coded credentials are common flaws。