HTB 学习笔记 【中/英】《前端 vs. 后端》P3

发布于:2025-03-17 ⋅ 阅读:(23) ⋅ 点赞:(0)

📌 这篇文章讲了什么?

  • 介绍了 前端(客户端)后端(服务器端) 的区别。
  • 解释了 全栈开发(Full Stack Development),即前端+后端开发。
  • 介绍了 前端和后端常用的技术
  • 讨论了 常见的安全风险 以及 OWASP Top 10 漏洞。
  • 列举了 开发人员常犯的 20 个安全错误,导致 Web 应用存在漏洞。

💡 需要记住的重点

1. 前端(客户端)开发

  • 前端是用户可见、可交互的部分,包括界面、按钮、文本、动画等。
  • 主要使用 HTML(结构)、CSS(样式)、JavaScript(功能) 进行开发。
  • 代码在 浏览器中执行,需适配不同设备、浏览器和屏幕尺寸。
  • 前端优化不佳会导致网页卡顿、加载慢,影响用户体验。

📌 关键点:前端负责 用户体验(UI/UX),但前端代码也可能被攻击者利用进行漏洞利用(如 XSS)。


2. 后端(服务器端)开发

  • 负责 处理业务逻辑、数据存储、用户身份验证、API 调用 等核心功能。
  • 代码运行在 服务器上,用户无法直接访问后端代码。
  • 后端的 4 个核心组件:
组件 描述
后端服务器 托管 Web 应用的硬件和操作系统(如 Linux、Windows)。
Web 服务器 处理 HTTP 请求(如 Apache、Nginx、IIS)。
数据库 存储和检索数据(如 MySQL、PostgreSQL、MongoDB)。
开发框架 开发 Web 应用的工具(如 Laravel、Django、Express.js)。

📌 关键点:后端是 Web 应用的大脑,管理所有数据、权限和核心逻辑,但如果未正确保护,则容易成为攻击目标。


3. Web 安全风险与攻击方式

尽管后端代码不可见,但攻击者仍然可以通过漏洞进行攻击。常见的 Web 安全漏洞包括:

攻击类型 描述
SQL 注入(SQLi) 通过注入恶意 SQL 代码来访问或修改数据库数据。
命令注入 利用输入验证漏洞执行服务器端操作系统命令。
本地文件包含(LFI) 读取服务器上的敏感文件。
跨站脚本攻击(XSS) 在网页中插入恶意 JavaScript 代码,窃取用户数据。
访问控制破坏(Broken Access Control) 越权访问其他用户数据或管理功能。

📌 关键点:即使攻击者无法直接访问后端代码,他们仍可以通过 输入漏洞、权限错误、配置问题 等进行攻击。


4. 常见的 Web 开发安全错误

许多漏洞的根本原因是 开发人员的错误,以下是最常见的 20 个安全错误:

错误 描述
存储明文密码 不加密存储密码,容易被黑客盗取。
允许无效数据进入数据库 可能导致 SQL 注入攻击。
过度依赖客户端验证 攻击者可以篡改前端数据绕过安全限制。
使用弱加密方法 易被破解,导致数据泄露。
硬编码敏感数据 在代码中写死密码、API Key 等,增加被盗风险。
配置错误 Web 防火墙(WAF) 允许未授权的请求绕过安全检查。

📌 关键点:大多数安全问题源于 开发人员的失误,而非代码本身的 bug。


5. OWASP Top 10 Web 安全漏洞

OWASP(开放 Web 应用安全项目)列出了 Web 应用最常见的 10 大安全漏洞

排名 漏洞 影响
1 访问控制破坏 攻击者可访问未经授权的数据或功能。
2 加密失败 不安全的数据存储或传输导致数据泄露。
3 注入攻击 SQL/命令注入可导致服务器被入侵。
4 不安全的设计 设计缺陷导致安全风险。
5 错误的安全配置 默认密码、开放端口等问题使得攻击更容易。
6 使用过时或漏洞组件 旧版本软件存在已知安全漏洞。
7 身份验证失败 弱密码或认证逻辑错误导致账户被盗。
8 软件和数据完整性失败 未验证软件更新或篡改数据导致恶意代码执行。
9 日志记录和监控失败 监控不足,使攻击无法被检测到。
10 服务器端请求伪造(SSRF) 服务器被攻击者利用去访问内部网络资源。

📌 关键点OWASP Top 10 是渗透测试和 Web 安全测试的基础,必须掌握!


🚫 不需要重点关注的内容

前端和后端编程语言的详细语法(我们关注安全,而不是开发)。
所有开发框架的具体使用方式(了解它们的作用即可)。
Web 服务器(如 Apache、Nginx)的详细配置(除非你专注于 Web 服务器安全)。


✅ 未来行动计划

理解前端和后端的区别,以及它们的安全风险。
熟悉常见 Web 漏洞及其攻击方式(如 SQLi、XSS)。
深入学习 OWASP Top 10,并掌握如何利用和修复这些漏洞。
在 Hack The Box、TryHackMe 或 DVWA 上进行实际渗透测试练习。

掌握 Web 应用安全 是成为 高级渗透测试员 的关键技能。如果你能发现、利用并修复 Web 漏洞,你将在网络安全行业占据极大优势!🔥🚀


Summary and Notes on "Front End vs. Back End"


📌 What Is This About?

  • Explains the difference between Front End (Client-Side) and Back End (Server-Side) development.
  • Discusses Full Stack Development, which includes both front-end and back-end.
  • Covers common technologies used in front-end and back-end development.
  • Introduces common security risks and the OWASP Top 10 vulnerabilities related to web applications.
  • Highlights 20 common web developer mistakes that lead to security issues.

💡 Key Points to Memorize

1. Front End (Client-Side) Development
  • Everything users see and interact with in a web application.
  • Built with HTML (structure), CSS (design), JavaScript (functionality).
  • Runs in the browser and must be optimized for different devices, browsers, and screen sizes.
  • Poorly optimized front-end code can cause slow and unresponsive web applications.
  • Other front-end tasks:
    • UI Design: Creating visual elements.
    • UX Design: Ensuring a good user experience.

📌 Key Takeaway: The front end is the visible and interactive part of a web application, responsible for user experience.


2. Back End (Server-Side) Development
  • Handles the core functionalities of a web application.
  • Runs on a server, processes requests, and interacts with databases.
  • Users do not directly see or interact with back-end components.
Component Description
Back-End Server The hardware and OS (Linux, Windows) that hosts the web app.
Web Server Handles HTTP requests (e.g., Apache, NGINX, IIS).
Database Stores and retrieves data (e.g., MySQL, PostgreSQL, MongoDB).
Development Frameworks Tools to build back-end applications (e.g., Laravel, Django, Express.js).
  • Back-end security is crucial since poorly secured servers and databases can lead to major breaches.
  • Common back-end tasks:
    • Implementing business logic.
    • Managing databases and storing data securely.
    • Developing APIs for front-end communication.
    • Securing user authentication and access control.

📌 Key Takeaway: The back end is the invisible but essential part of a web application, handling data, logic, and security.


3. Common Security Risks in Web Development

Even if users cannot see the back-end code, it can still be vulnerable to attacks. Common web security flaws include:

Attack Type Description
SQL Injection Injecting malicious SQL queries to access or modify the database.
Command Injection Exploiting poorly validated input to execute system commands.
Local File Inclusion (LFI) Exploiting file inclusion vulnerabilities to access sensitive files.
Cross-Site Scripting (XSS) Injecting malicious scripts into web pages to steal user data.
Broken Access Control Exploiting access control flaws to gain unauthorized privileges.

📌 Key Takeaway: Even if we don’t see the back-end code, it can still be exploited through injections, misconfigurations, and poor validation.


4. Common Web Developer Mistakes That Lead to Security Issues

Many vulnerabilities arise because of bad coding practices. Common mistakes include:

Mistake Description
Storing passwords in plaintext No encryption makes it easy for attackers to steal credentials.
Allowing invalid data in databases Poor validation can lead to SQL injection.
Relying too much on client-side security Attackers can bypass front-end protections using browser tools.
Using weak cryptographic methods Poor encryption can be easily cracked.
Hardcoding sensitive data Storing credentials in source code increases risk.
Misconfiguring Web Application Firewalls (WAF) Leaving firewalls poorly configured allows attacks to bypass security.

📌 Key Takeaway: Many security issues are caused by bad development practices, not just bugs.


5. The OWASP Top 10 Web Application Vulnerabilities

These are the most critical security risks in web applications:

No. Vulnerability Impact
1 Broken Access Control Attackers can access unauthorized resources.
2 Cryptographic Failures Poor encryption leads to data leaks.
3 Injection Attacks SQL/Command injection can allow full system compromise.
4 Insecure Design Flaws in architecture make the app inherently weak.
5 Security Misconfiguration Default credentials, open ports, or weak settings make attacks easier.
6 Vulnerable and Outdated Components Using old libraries or software introduces known security holes.
7 Authentication Failures Weak login security leads to account takeovers.
8 Software and Data Integrity Failures Unverified software updates or modifications allow malicious code execution.
9 Security Logging and Monitoring Failures Lack of monitoring allows attacks to go unnoticed.
10 Server-Side Request Forgery (SSRF) Attackers force the server to make requests on their behalf.

📌 Key Takeaway: The OWASP Top 10 is a must-know for penetration testers. These vulnerabilities appear in most real-world applications.


🚫 What You Don’t Need to Focus On Too Much

Learning how to code front-end/back-end from scratch (this is about security, not development).
Memorizing all development frameworks (just understand the general role of frameworks).
Overly detailed server configurations (you’ll learn security configurations when needed).


✅ Next Steps & Action Plan

Understand the key differences between front-end and back-end development.
Familiarize yourself with common security risks and vulnerabilities.
Start practicing web penetration testing techniques (e.g., SQL injection, XSS).
Learn the OWASP Top 10 vulnerabilities and how to exploit/mitigate them.
Perform hands-on practice on platforms like Hack The Box, TryHackMe, or DVWA.

Understanding the fundamentals of front-end and back-end security is crucial for becoming a skilled penetration tester. Mastering these concepts will help you identify, exploit, and secure web applications like a pro! 🚀