Computer Security Project

This project consists of the development of a computer security application using Python. The application was designed to explore core concepts of offensive and defensive cybersecurity in controlled and authorized environments.

🔐 Implemented Features

📦 Installation

🖥️ Main Menu

************Computer Security Application**************

A: Available Network Ports
B: UDP flood (DoS)
C: SYN flood (TCP SYN)
D: Encrypted Chat
Q: Quit

🔍 Port Detection and Listing

This feature allows scanning and listing open ports on domains or IP addresses, with configurable port ranges and connectivity levels.


************Computer Security Application**************

               A: Available Network Ports
               B: UDP flood (DoS)
               C: SYN flood (TCP SYN)
               D: Encrypted Chat
               Q: Quit

               Choose the desired option: A
Running available-ports.py...

************************************************************
        Port Scanner
 
        D - Domain Name | I - IP Address        I
         Enter the IP Address to scan: 192.168.1.10
         Enter the start port number    1
         Enter the last port number     99999

Range not OK
Setting last port to 65535
Low connectivity = L | High connectivity = H    H

Scanning in progress...  192.168.1.10
************************************************************
Port Open:-->    9200 -- Elasticsearch — default Elasticsearch port - Unofficial TCP
Port Open:-->    9000 -- qBittorrent embedded torrent tracker default port - Unofficial TCP
Port Open:-->    4444 -- I2P HTTP/S proxy - Unofficial TCP
Port Open:-->    27017 -- MongoDB daemon process (mongod) and routing service (mongos) - No UDP, Unofficial TCP
Port Open:-->    9300 -- IBM Cognos BI [citation needed] - Unofficial TCP
Port Open:-->    12201 -- Graylog Extended Log Format (GELF) [importance?] - Unofficial TCP and UDP
Port Open:-->    1515 -- No known service for port 1515
Exiting main thread
Scanning complete in  0:00:07.054941

💥 UDP Flood (DoS)

Simulation of a UDP Flood attack, allowing the configuration of the target IP, target port, number of packets, and payload message.


************Computer Security Application**************

               A: Available Network Ports
               B: UDP flood (DoS)
               C: SYN flood (TCP SYN)
               D: Encrypted Chat
               Q: Quit

               Choose the desired option: B
Running udp_flood.py...
Enter the target IP address: 192.168.1.10
Enter the target port: 80
Enter the number of packets to send: 50
Enter a message to send to the target: Test

⚡ TCP SYN Flood

Multi-threaded TCP SYN Flood simulation, demonstrating resource exhaustion attacks on TCP services.


************Computer Security Application**************

               A: Available Network Ports
               B: UDP flood (DoS)
               C: SYN flood (TCP SYN)
               D: Encrypted Chat
               Q: Quit

            
               Choose the desired option: C
                
            
Running synflood.py...
                
            
Enter the target IP: 192.168.1.10
Enter the number of packets to send per thread: 100
Enter the number of threads: 5
                
            
Thread sent 100 packets successfully.
Sent 500 packets successfully.

🔒 Secure Messaging Service

A client-server messaging system featuring authentication, encryption of private keys, broadcast messaging, message history reading, and export functionality.

Encrypted Chat Server Initialization Encrypted Chat Authentication

🚪 Port Knocking & SSH / L2TP-IPSec

Implementation of a port knocking mechanism using firewall rules configured with iptables, enabling conditional access to SSH and L2TP/IPSec services.


#!/bin/bash

### Clear existing rules and custom chains


iptables -X
iptables -F
iptables -X INTO-P2
iptables -X INTO-P3
iptables -X INTO-P4


# Accept established and related connections to allow return traffic


iptables -A INPUT -p tcp --dport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -m state --state RELATED -j ACCEPT


# Create new chains to control the program flow


iptables -N INTO-P2
iptables -N INTO-P3
iptables -N INTO-P4


# Rules to move connections from one stage to another, tracking them with names
# P1 - P2 - P3 - P4


iptables -A INTO-P2 -m recent --name P1 --remove
iptables -A INTO-P2 -m recent --name P2 --set
iptables -A INTO-P2 -j LOG --log-prefix "INTO P2: "

iptables -A INTO-P3 -m recent --name P2 --remove
iptables -A INTO-P3 -m recent --name P3 --set
iptables -A INTO-P3 -j LOG --log-prefix "INTO P3: "

iptables -A INTO-P4 -m recent --name P3 --remove
iptables -A INTO-P4 -m recent --name P4 --set
iptables -A INTO-P4 -j LOG --log-prefix "INTO P4: "


# Update the last time the P1 connection was seen


iptables -A INPUT -m recent --update --name P1


# Define the sequence of ports that must be accessed in a specific order
# To allow access to the SSH port
# If the sequence is broken, access rules will be rejected


iptables -A INPUT -p tcp --dport 6666 -m recent --name P1 --set
iptables -A INPUT -p tcp --dport 7777 -m recent --rcheck --seconds 10 --name P1 -j INTO-P2
iptables -A INPUT -p tcp --dport 8888 -m recent --rcheck --seconds 10 --name P2 -j INTO-P3
iptables -A INPUT -p tcp --dport 9999 -m recent --rcheck --seconds 10 --name P3 -j INTO-P4


# If the sequence is complete (P1 → P2 → P3 → P4), the SSH port will be opened


iptables -A INPUT -p tcp --dport 22 -m recent --rcheck --seconds 10 --name P4 -j ACCEPT


# Open L2TP/IPSec port (1701) if the sequence is respected


iptables -A INPUT -p udp --dport 1701 -m recent --rcheck --seconds 10 --name P4 -j ACCEPT


# Default rule to reject new SSH connections if the sequence is not respected


iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j DROP
SSH Access After Port Knocking