Skip to main content

Posts

Showing posts from March, 2024

Python = Code for functional Firewal

  import os import subprocess import socket import requests blocked_ips = {} blocked_websites = {} blocked_applications = {} def add_ip_to_block ( ip , port ): if ( ip , port ) in blocked_ips : print ( f "IP { ip } with port { port } is already blocked" ) return if is_ip_port_in_hosts ( ip , port ): print ( f "IP { ip } with port { port } is already in block list." ) return blocked_ips [( ip , port )] = True print ( f "Added { ip } with port { port } to blocked IPs" ) def remove_ip_from_block ( ip , port ): if ( ip , port ) in blocked_ips : del blocked_ips [( ip , port )] print ( f "Unblocked { ip } with port { port } " ) else : print ( f "IP { ip } with port { port } is not blocked" ) def add_website_to_block ( website ): if website in blocked_websites : print ( f " { website } is already blocked...