Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Python Projects/Port Scanner/Readme.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SYN Flood Protection Tool
A simple Python script to protect against SYN flood attacks by enabling SYN cookies.

## Overview

This Python script enables SYN cookies to protect against SYN flood attacks. It listens on a specified IP address and port and responds to incoming connections with a customizable message.

**Features:**

- SYN flood protection using SYN cookies.
- Customizable response message.
- Basic error handling and logging.
35 changes: 35 additions & 0 deletions Python Projects/Port Scanner/syn_flood.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import socket
import os

def enable_syn_cookies():
with open("/proc/sys/net/ipv4/tcp_syncookies", "w") as file:
file.write("1")

def protect(target_ip, target_port):
enable_syn_cookies()

# Create a socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the target IP and port
s.bind((target_ip, target_port))

# Listen for incoming connections
s.listen(5)

print(f"Listening on {target_ip}:{target_port}...")

while True:
try:
client_socket, addr = s.accept()
print(f"Received connection from {addr[0]}:{addr[1]}")
client_socket.send("Thank you for connecting.".encode())
client_socket.close()
except socket.error as e:
print(f"Socket error: {str(e)}")

if __name__ == "__main__":
target_ip = "0.0.0.0" # Use the IP address you want to protect
target_port = 80 # Use the port you want to protect

protect(target_ip, target_port)