feat: config file + database connection / dockerfile

This commit is contained in:
2024-11-18 17:59:10 -05:00
parent dbc65f13bc
commit 2d25387fde
16 changed files with 397 additions and 150 deletions

View File

@ -1,8 +1,12 @@
# Seuils
TIME_WINDOW = 180
NB_SEUIL = 5
def rule(packet, tcp_packets, db):
"""Règle SYNScan:
Un SYNScan va envoyer des requêtes TCP avec le flag SYN
Si le port est ouvert alors le serveur répondra: Syn ACK, puis le client Reset la connexion
Sinon le port est fermé et le serveur répondera: Reset ACK
"""
time_window = db.get_key("synscan_time", 180)
seuil = db.get_key("synscan_count", 5)
def rule(packet, tcp_packets):
if (tcp_packets.count_packet_of_type("RA", TIME_WINDOW) + tcp_packets.count_packet_of_type("SA", TIME_WINDOW)) + tcp_packets.count_packet_of_type("R", TIME_WINDOW) >= NB_SEUIL:
if (tcp_packets.count_packet_of_type("RA", time_window) + tcp_packets.count_packet_of_type("SA", time_window)) + tcp_packets.count_packet_of_type("R", time_window) >= seuil:
print(f"Alerte, seuil dépassés, risque de SynScan")

View File

@ -1,8 +1,11 @@
# Seuils
TIME_WINDOW = 180 # 180 secondes pour avoir X paquets
NB_SEUIL = 5
def rule(packet, tcp_packets, db):
"""Règle TCPConnect Scan:
Un scan TCP connect va effectuer une connexion TCP en entier sur chaque port scanné.
Si le port est ouvert le serveur acceptera la connexion SYN -> SYN ACK -> ACK -> Reset -> ACK
Sinon le port est fermé et le serveur refusera la connexion SYN -> Reset ACK
"""
time_window = db.get_key("tcpconnectscan_time", 180)
seuil = db.get_key("tcpconnectscan_count", 5)
def rule(packet, tcp_packets):
if (tcp_packets.count_packet_of_type("A", TIME_WINDOW) + tcp_packets.count_packet_of_type("RA", TIME_WINDOW)) >= NB_SEUIL:
if (tcp_packets.count_packet_of_type("A", time_window) + tcp_packets.count_packet_of_type("RA", time_window)) >= seuil:
print(f"Alerte, seuils dépassés, risque de TCPConnectScan")