SID generation for crowdsourced rules

This commit is contained in:
sda 2022-11-07 08:56:22 +01:00
parent fc11af0e24
commit a1bb1eeb1d

View File

@ -7,6 +7,7 @@ from app.classes.network import Network
from os import mkdir, path, chmod from os import mkdir, path, chmod
import sys import sys
import re
import json import json
import random import random
@ -151,7 +152,14 @@ class Capture(object):
Returns: Returns:
bool: operation status. bool: operation status.
""" """
rules = [r[0] for r in get_iocs("snort")] sid = 1000000
rules = []
for rule in get_iocs("snort"):
sid = sid + 1
rule = re.sub("sid:[0-9a-zA-Z]+", f"sid:{sid}", rule[0] )
rules.append(rule)
try: try:
with open(self.rules_file, "w+") as f: with open(self.rules_file, "w+") as f:
f.write("\n".join(rules)) f.write("\n".join(rules))