Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packet defender #251

Merged
merged 1 commit into from
Dec 16, 2024
Merged

packet defender #251

merged 1 commit into from
Dec 16, 2024

Conversation

vijayleo31
Copy link
Contributor

The Simple Network Packet Filter is a C++ application designed to simulate the functionality of a basic network packet filtering tool. The program defines a Packet class to represent network packets, which includes attributes for source IP, destination IP, and port number.

The core functionality is encapsulated in the PacketFilter class, which maintains a list of blocked IP addresses. It provides methods to add IPs to the block list and to check if incoming packets should be blocked based on their source IP.

In the main function, the program initializes the packet filter, adds a few blocked IPs, and processes a predefined list of packets. For each packet, it outputs whether the packet is allowed or blocked based on the filtering criteria.

Key Features:
Packet Representation: Models network packets with essential attributes.
IP Blocking: Allows the addition of IP addresses to a block list.
Packet Processing: Simulates the processing of packets and outputs the filtering results.
Use Case:
This tool serves as a foundational example for understanding packet filtering concepts and can be expanded into a more complex application with actual network packet capturing and filtering capabilities using libraries like libpcap.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting your first pull request! 🎉 Your effort and contribution are greatly appreciated. Our maintainers will review your changes soon. In the meantime, please ensure your submission aligns with our Contribution Guidelines Let me know if you have any questions. Welcome aboard! 🙌 | Omar Santos @santosomar

Copy link
Contributor

@santosomar santosomar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙏

This C++ code defines two classes, Packet and PacketFilter, to demonstrate a simple packet filtering logic based on blocked IP addresses. Here’s what the code accomplishes step-by-step:
1. Packet Representation:
The Packet class holds basic information about a network packet:
• sourceIP: The IP address of the packet’s sender.
• destinationIP: The IP address of the intended recipient.
• port: The destination port number.
2. Packet Filtering Logic:
The PacketFilter class maintains a list of blocked source IP addresses. It provides functionality to:
• addBlockedIP: Add an IP address to the internal blocked list.
• isBlocked: Check whether a given packet’s source IP is on the blocked list.
• processPacket: Print whether a packet is allowed or blocked based on its source IP.
3. Execution Flow (main function):
• A PacketFilter object is created, and a couple of IP addresses are marked as blocked.
• A vector of Packet objects is initialized. Some packets originate from blocked IPs, and others do not.
• Each packet is processed by filter.processPacket(), which prints out the appropriate message.

In essence, the code simulates a basic firewall-like behavior, allowing some packets and blocking others based on their source IP addresses.

@santosomar santosomar merged commit 9ea8595 into The-Art-of-Hacking:master Dec 16, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants