Network A/D Notes
The content is excerpted from the instructor's PPT. Apart from correcting obvious factual errors (such as changing /etc/password
to /etc/passwd
), it does not represent personal opinions.
Network Attack Techniques
(Key Points) Criteria and Categories of Attack Classification
Criteria: Mutual exclusivity, comprehensiveness, non-ambiguity, repeatability, acceptability, and practicality.
Categories: From the attacker's perspective, attacks can be classified into physical (local) attacks, active attacks, passive attacks, and man-in-the-middle attacks.
(Key Points) Attack Steps and Methods, Detailed Understanding of Each Step
Attack Steps:
- Information Gathering (Collect as much relevant information about the target as possible to establish a foundation for subsequent "precise" attacks)
- Privilege Acquisition (Gain access to target system permissions such as RWX)
- Backdoor Installation (Install backdoor programs in the target system to monitor it in a more convenient and covert manner)
- Expanding Impact (Use the target system as a "springboard" to attack other hosts within the target's network, maximizing the effect of the attack)
- Covering Tracks (Erase traces of the attack to maintain long-term control over the target and avoid detection and tracking)
Physical Attacks and Social Engineering
Definition of Physical Attack: A method of attack that bypasses physical security protection systems through various technical means to gain access to protected facilities or equipment resources, thereby obtaining or destroying protected information stored in the physical media of information systems.
Definition of Social Engineering: The art and science of exploiting human folly to manipulate individuals into performing desired actions or divulging confidential information.
Information Gathering Techniques
Definition, Content, Classification, and Necessity of Open Source Intelligence (OSINT) Gathering
Information Gathering: Refers to all reconnaissance activities conducted by hackers before or during an attack to carry out attacks more effectively.
Content: Domain names and IP addresses, security measures, internal network structure, domain organization, user emails, OS types, open ports, system architecture, sensitive files and directories, application types, etc.
Necessity:
- For attackers (first-mover advantage, gathering target information for attacks)
- For defenders (conducting information gathering on attackers for attribution and tracing)
Classification:
- Active (direct access, may obtain more information but risks recording operations)
- Passive (using third-party services for access, collects relatively less information, actions remain undetected)
(Key Points) Types of Network Scanning (Host, Port, System Type Scanning) and Principles
Scanning Types:
- Host Scanning: Uses the ping command to send an ICMP Echo Request (Type 8) packet to the target host and waits for an ICMP Echo Reply (Type 0) packet in response.
- Port Scanning: Includes TCP SYN, TCP null, Xmas, TCP Window, TCP ACK, FTP Proxy, idle, and IP fragmentation scanning.
- System Type Scanning: Involves detecting specific open ports, application banners, and TCP/IP stack fingerprinting.
Purpose, Principles, Components, and Methods of Vulnerability Scanning
Vulnerability detection involves inspecting critical computer information systems to identify weaknesses that could be exploited by hackers. This technology generally employs two strategies: passive and active.
- The passive strategy is host-based detection, which examines inappropriate settings, weak passwords, and other objects within the system that violate security policies.
- The active strategy is network-based detection, which executes script files to simulate attacks on the system and records its responses to uncover vulnerabilities.
The main methods of vulnerability detection include: direct testing, inference, and credentialed testing.
Network Topology Discovery (Topology Detection, Network Device Identification, Geolocation of Network Entity IPs)
Topology Detection: traceroute, SNMP
Device Identification: shodan, zoomeye, FTP, SSH, telnet, HTTP
IP Geolocation: Query-based Geolocation, Network Measurement-based Geolocation
Password Attacks
Definition and Function of Passwords (Operating System Passwords)
A password is a code or phrase typically composed of letters, numbers, or symbols, used to identify and verify the identity of an individual or system. Its main functions include: identity authentication, security assurance, privacy protection, data encryption, and access control.
Attack Methods Against Password Strength
Dictionary, Brute Force, Combination, Credential Stuffing, Rainbow Table
Storage Methods
Linux:
- Basic password file:
/etc/passwd
- Hashed password file:
/etc/shadow
- Password field consists of three parts (algorithm used, salt, password hash)
Windows:
- Located in the
%systemroot%\system32\config
directory SAM._
file in the%SystemRoot%\repair
directory- Registry key:
HKEY_LOCAL_MACHINE\SAM
- In the memory block of
Winlogon.exe
- Locked, hidden, and unreadable; uses the NTLM authentication protocol
Transmission Methods
- Sniffing Attacks (Network cards operating in promiscuous mode)
- Keylogging
- Phishing
- Replay Attacks
Methods to Prevent Password Attacks
- Choose Secure Passwords
- Prevent Password Guessing Attacks
- Implement Security Policies
Software Vulnerabilities
Definition of Vulnerability
Refers to errors, flaws, and oversights in the design or implementation of information system hardware, software, operating systems, network protocols, databases, etc., that can be exploited by attackers.
In simpler terms, a vulnerability is a weakness in a system that can be taken advantage of by an attack.
Common Vulnerability Types
Common vulnerability types:
- Stack Overflow (CWE-121)
- Heap Overflow (CWE-122)
- Format String (CWE-134)
- Integer Overflow (CWE-190)
- Use after Free (CWE-416)
(Key Points) Principles of Stack Overflow Vulnerability Exploitation (Memory Distribution, Memory Changes During Exploitation, Push/Pop Operations, and Stack Overflow Principles)
The content of the PPT is difficult to summarize concisely. Using GPT-4, a brief summary is provided as follows:
A stack overflow occurs when data exceeds the memory space allocated for the stack. In memory, the stack is responsible for storing local variables and function call information. When too much data is pushed onto the stack (adding data), exceeding its boundaries, adjacent memory regions can be overwritten. This overflow can be exploited to tamper with the stack's control information (such as the return address), leading to the execution of unintended code.
For detailed steps, refer to this article. Reading up to the section on shellcode is sufficient.
(Key Points) Principles of Overflow Vulnerability Exploitation (Basic Process, Key Techniques: Overflow Point Location, Overwriting Execution Control Addresses, Overwriting Exception Handling Structures, Determining Jump Addresses, Shellcode Location and Jumping)
Basic Process: Where to inject the "overflow" data? How long should the data be to overwrite the return address? What content should be used to overwrite the return address? What kind of attack code should be executed?
- Overflow Point Location: Probing methods (using
cyclic
andcyclic_find
in pwndbg), disassembly analysis. - Execution Control Addresses Include: Overwriting the return address, overwriting function pointer variables, overwriting exception handling structures.
- Determining Jump Addresses: Instruction selection (jmp, call), instruction search range (user space, system DLLs, process code segments, PEB, TEB).
- Shellcode Location and Jumping:
nop sled + decoder + real_shellcode
.
Definition, Purpose, Steps for Writing, Considerations, and General Methods for Writing Shellcode
Definition: Shellcode is a piece of machine code that can perform specific functions and be executed directly by a computer. It is typically represented in hexadecimal form.
Purpose: Establishing reverse connections, uploading (or downloading) and executing Trojan horses or viruses, among other tasks.
Steps for Writing: Typically written in assembly language.
Considerations: Ensure proper exit, handle null bytes, and load DLLs.
General Methods for Writing Shellcode: List the function addresses corresponding to each version of the Windows operating system and use different addresses for different OS versions. The steps for dynamically locating function addresses (i.e., using GetProcAddress
and LoadLibrary
functions to dynamically obtain the addresses of other functions) are as follows:
- First, dynamically obtain the address of
GetProcAddress
(via brute-force searching, using the PEB to retrieve the kernel base address, SEH to obtain the kernel base address, or hashing to find all function addresses). - Use
GetProcAddress
to obtain the addresses of other functions (e.g.,LoadLibrary
,socket
). - Then call the addresses of other functions.
Principles of Environment Variable Attacks, Set-UID Concepts, and Attack Case Analysis
Principle: The hidden use of environment variables is dangerous. Since users can set environment variables, they become part of the attack surface for Set-UID programs.
Set-UID Concept: Allows users to temporarily run a program with the (elevated) permissions of the program's owner.
Case Analysis:
- Dynamic Linker (
LD_PRELOAD
,LD_LIBRARY_PATH
,DYLD_PRINT_TO_FILE
) - External Programs (
exec
family of functions,system
) - External Libraries (
locale
,gettext
,catopen
, etc.) - Application Code
Web Application Attacks
Fundamentals of Web Applications (Architecture, Basic Content)
Web servers (web pages, databases), Web clients, HTTP protocol
- Web pages are hosted on Web servers and are used to display information. They are typically written in HTML (Hypertext Markup Language).
- Web servers: Apache, IIS, Tomcat, Nginx, etc.
- Web clients (browsers): Chrome, Firefox, IE (Edge), etc.
- HTTP protocol: Request message format and response message format (please refer to external sources for details).
(Key Points) XSS Attack (Definition, Same-Origin Policy, Risks, Code Vulnerability Analysis and Exploitation Methods, Types, Preventive Measures)
Definition: XSS attacks occur due to insufficient filtering of user input by web applications, allowing attackers to input specific data that is interpreted as JavaScript scripts or HTML code.
Same-Origin Policy: This policy means that cookies set by webpage A cannot be accessed by webpage B unless the two webpages are "same-origin." "Same-origin" refers to "three samenesses" (same protocol, same domain, same port).
Risks: Phishing, extraction of client-side information, DDoS attacks, privilege escalation, worm propagation, etc.
Types: Reflected (non-persistent, parameter-based, appended to URLs), Stored (persistent, comments, databases), DOM-based XSS (JavaScript-based, does not require server interaction), etc.
Preventive Measures: HttpOnly, secure coding practices
SQL Injection Attack (Definition, Types, Injection Steps, Privilege Escalation Methods, Definition of Database Exposure, Prevention Measures)
Definition: Submitting carefully crafted SQL query statements to a website, causing it to return critical data information.
Attack Types: Character-based, Numeric, Error-based, Blind SQL Injection
Injection Steps: Discover injection points, identify database type, guess table names, guess field names, extract content, access the admin page to upload malicious files.
Privilege Escalation Methods: For example, cracking pcAnywhere .cif files, exploiting Serv-U for privilege escalation (local overflow, VBS scripts).
Definition of Database Exposure: Using technical means or program vulnerabilities to obtain the database address and illegally download data to a local machine.
Prevention Measures: Escape special characters, input validation and filtering, parameterized queries.
HTTP Session Attacks and Defense (Session ID Prediction, Session ID Theft, Session ID Control, CSRF Attacks, Preventive Measures)
To prevent session ID prediction attacks, it is recommended to use built-in session management mechanisms provided by programming languages, such as those in PHP and Java.
To counter session ID theft attacks, different preventive measures should be taken based on the specific methods used for theft. For instance, session ID theft attacks carried out via XSS can be mitigated by using the HttpOnly attribute.
To defend against session fixation attacks, it is advisable to avoid session-adopting web environments whenever possible or implement safeguards against session adoption methods.
To prevent session persistence attacks, the primary defense is to ensure that session IDs are not valid for extended periods. This can be achieved through measures such as forced session destruction or changing the session ID after user login.
To defend against CSRF attacks, the following measures can be taken:
- Use POST instead of GET
- Verify the HTTP Referer
- Use CAPTCHA
- Implement tokens
Fake Message Attacks
(Key Points) Principles and Attack Strategies of Packet Sniffing and Spoofing (TCP Communication Code and Process, IP Spoofing Attacks and Prevention)
Packet sniffing can be achieved using raw sockets (creating raw sockets, capturing all types of packets, enabling promiscuous mode, waiting for packets), or by using the pcap API and Scapy for packet sniffing.
When certain critical information in a packet is forged, it is referred to as packet spoofing. Packet spoofing involves two main steps: constructing the packet (filling in the ICMP header and IP header) and sending the packet out.
(Key Points) What is the TCP Protocol, How the TCP Protocol Works, Principles and Steps of SYN Flooding Attacks, Principles and Steps of TCP Reset Attacks, Principles and Steps of TCP Session Hijacking Attacks
The Transmission Control Protocol (TCP) is a core protocol of the Internet protocol suite, operating at the transport layer on top of the IP layer. It provides host-to-host communication services for applications. There are two transport layer protocols: TCP (connection-oriented, reliable) and UDP (connectionless, unreliable, lower overhead).
How the TCP Protocol Works: SYN, SYN-ACK, ACK
- When the server receives the initial SYN packet, it uses a TCB (Transmission Control Block) to store information about the connection.
- This is called a half-open connection because only the client-to-server connection is acknowledged.
- The server stores the TCB in a queue dedicated to half-open connections.
- After the server receives the ACK packet, it removes this TCB from the queue and stores it elsewhere.
- If the ACK does not arrive, the server will resend the SYN+ACK packet. After a certain period, the TCB will eventually be discarded.
Principle of SYN Flooding Attack: To fill the queue storing half-open connections so that there is no space to store TCBs for any new half-open connections, essentially preventing the server from accepting any new SYN packets.
Steps to Implement SYN Flooding: Continuously send a large number of SYN packets to the server. This consumes space in the queue by inserting TCB records without completing the third step of the handshake.
Principle of TCP Reset Attack: The goal is to disconnect the TCP connection between A and B. A forged RST packet must have the correct source IP address, source port, destination address, destination port, and sequence number (within the receiver's window).
Steps of TCP Reset Attack: Use Wireshark on the attacker's machine to sniff traffic and retrieve the target port, source port number, and sequence number.
Principle of TCP Session Hijacking Attack: The goal is to inject data into an established connection. A forged TCP packet must be set up with the same parameters as in a reset attack.
Steps of TCP Session Hijacking Attack: Same as the TCP reset attack.
(Key Points) DNS Attacks (Domain Name Structure, Query Process, Types and Principles of DNS Attacks (Local DNS Cache Poisoning Attack, Remote DNS Cache Poisoning Attack, Malicious DNS Server Response Spoofing Attack), Prevention Measures)
Domain Name Structure: Root domain, top-level domain, authoritative domain, etc.
Query Process: Iterative query and recursive query
Types and Principles of DNS Attacks:
- Local DNS Cache Poisoning Attack: This attack exploits the trust mechanism of DNS servers. The attacker forges a DNS response after observing a query from the local DNS server.
- Remote DNS Cache Poisoning Attack: Unlike local attacks, remote DNS attacks require guessing the source port number and transaction ID. However, the latter can be prevented by querying different (non-existent) subdomains each time to avoid answer caching. Spoofed answers are provided in the authority section.
- Malicious DNS Cache Poisoning Attack: When a user visits a website (e.g., attacker32.com), the DNS query will eventually reach the authoritative name server for the attacker32.com domain. In addition to providing an IP address in the answer section of the response, the DNS server can also provide information in the authority and additional sections. Attackers can use these sections to supply fraudulent information.
Prevention Measures: DNSSEC provides authentication and integrity checks for DNS data. All answers from DNSSEC-protected zones are digitally signed. By verifying the digital signature, DNS resolvers can ensure the authenticity of the information. DNS cache poisoning will be defeated by this mechanism, as any forged data will be detected and fail the signature verification. (Strong machine translation tone)
Meltdown and Spectre Attacks
CPU Cache Principles
Based on the principle of locality (computer programs tend to repeatedly access the same data and instruction sets within a short period of time), since cache access is faster than memory access, using a cache can significantly improve the average execution performance of programs.
(Key Point) Principle of Side-Channel Attacks
However, if the CPU attempts to access data that is not present in the cache, a time delay will occur, as the target data must be reloaded from memory into the cache. Measuring this time delay may allow an attacker to determine the occurrence and frequency of cache access failures.
(Key Points) Meltdown Attack Concept
Meltdown attacks exploit the out-of-order execution feature of modern processors to bypass memory isolation. Although certain memory addresses should not be accessible, they are cached due to out-of-order execution. When the program accesses these addresses again, the access time is significantly reduced. This timing difference can be used to infer the original values stored in those memory addresses.
(Key Points) Spectre Attack Concept
Apart from leveraging the branch prediction feature of modern processors, the core idea of the Spectre attack is similar to that of the Meltdown attack.
Traceability Technology
Overview of Traceability and Attribution
Objective: To identify the attacker's identity, the location of the attack point, and the attack path, among other information.
Based on the depth of traceability, it can be categorized into:
- Attack host traceability
- Control host traceability
- Attacker traceability
- Attack organization traceability
Typical scenarios: Within a domain, cross-domain.
Challenges in Traceability
The challenges include:
- Sender anonymity through the use of proxies or relays
- Anonymous communication systems inherently conceal the identities of both parties
- Lack of authentication mechanisms in the TCP/IP protocol and the stateless nature of Internet infrastructure
- Inadequate personal privacy protection and imperfect legal regulations
- Emergence of new technologies (e.g., VPN, NAT)
Typical Techniques for Traceability and Source Tracking
Common techniques include:
- IP Tracing Technology
- Traceability Techniques for Stepping-stone Attacks
- Tracing and Source Tracking in Anonymous Communication Systems
Development Trends in Traceability Technology
The development trends include:
- Source localization techniques in large-scale networks
- Software gene-based cyber attack traceability technology
- Big data-driven cyber attack traceability technology
- Multi-method integrated traceability techniques