-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Suricata socket support, fix default UA, small things here and there
- Loading branch information
Showing
13 changed files
with
690 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
databaseHost=<server> | ||
databasePort=5432 | ||
databaseUser=fjospidie | ||
database_host=<server> | ||
database_port=5432 | ||
database_user=fjospidie | ||
database_password=pw | ||
database=fjospidie | ||
databasePassword=pw | ||
suricata=False | ||
snort_config=/etc/snort/snort.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import logging | ||
import threading | ||
import socket | ||
import json | ||
import time | ||
import os | ||
from suricata.suricatasc import * | ||
from snort.SnortAlert import SnortAlert | ||
|
||
class SuricataEngine(threading.Thread): | ||
def __init__(self, config, report, connections, suricata_dir, pcap_path, socket): | ||
threading.Thread.__init__(self) | ||
self.socket = socket | ||
self.connections = connections | ||
self.report = report | ||
self.suricata_dir = suricata_dir | ||
self.pcap_path = pcap_path | ||
self.alerts = [] | ||
self.config = config | ||
|
||
def run(self): | ||
logging.info("Starting SuricataEngine") | ||
os.makedirs(self.suricata_dir) | ||
debug = False | ||
if self.config.debug: | ||
debug = True | ||
|
||
sc = SuricataSC(self.socket, verbose=debug) | ||
try: | ||
sc.connect() | ||
except SuricataNetException, err: | ||
logging.error("Unable to connect to socket %s: %s" % (self.socket, err)) | ||
return | ||
except SuricataReturnException, err: | ||
logging.error( "Unable to negotiate version with server: %s" % (err)) | ||
return | ||
|
||
arguments = {} | ||
arguments["filename"] = self.pcap_path | ||
arguments["output-dir"] = self.suricata_dir | ||
|
||
cmdret = sc.send_command("pcap-file", arguments) | ||
if cmdret["return"] == "NOK": | ||
logging.error(json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))) | ||
else: | ||
logging.debug(json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))) | ||
|
||
self.check_ok(sc, 0) | ||
|
||
alert_file = self.suricata_dir + "/fast.log" | ||
with open(alert_file) as f: | ||
for line in f: | ||
alert = SnortAlert(line) | ||
self.alerts.append(alert) | ||
|
||
self.report.add_alerts( self.alerts) | ||
logging.info("Stopping SnortEngine") | ||
|
||
|
||
def check_ok(self, sc, count): | ||
cmdret = sc.send_command("pcap-current") | ||
if cmdret["return"] == "NOK": | ||
logging.error(json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))) | ||
else: | ||
if cmdret["message"] == "None": | ||
logging.debug(json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))) | ||
else: | ||
if count < 60: | ||
time.sleep(0.5) | ||
count +=1 | ||
self.check_ok(sc, count) | ||
else: | ||
logging.error("No result from suricata...") | ||
|
Empty file.
Oops, something went wrong.