2023-01-27 09:47:59 +00:00
|
|
|
"""
|
|
|
|
Get lookup csv from botnet-filter
|
|
|
|
Usage: "| getbotnetfilter | outputlookup override_if_empty=false botnet-filter-splunk.csv"
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from os import path
|
2023-02-15 09:40:37 +00:00
|
|
|
from time import time as unix_time
|
2023-01-27 09:47:59 +00:00
|
|
|
|
2023-02-08 10:06:21 +00:00
|
|
|
sys.path.insert(0, path.join(path.dirname(__file__)))
|
|
|
|
from utils import Utility
|
|
|
|
|
2023-01-27 09:47:59 +00:00
|
|
|
sys.path.insert(0, path.join(path.dirname(__file__), "..", "lib"))
|
|
|
|
from splunklib.searchcommands import Configuration, GeneratingCommand, Option, dispatch
|
|
|
|
|
2023-02-10 20:24:03 +00:00
|
|
|
DOWNLOAD_URLS = (
|
|
|
|
"https://malware-filter.gitlab.io/malware-filter/botnet-filter-splunk.csv",
|
|
|
|
"https://curbengh.github.io/malware-filter/botnet-filter-splunk.csv",
|
|
|
|
"https://curbengh.github.io/botnet-filter/botnet-filter-splunk.csv",
|
|
|
|
"https://malware-filter.gitlab.io/botnet-filter/botnet-filter-splunk.csv",
|
|
|
|
"https://malware-filter.pages.dev/botnet-filter-splunk.csv",
|
|
|
|
"https://botnet-filter.pages.dev/botnet-filter-splunk.csv",
|
2023-01-27 09:47:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration()
|
|
|
|
class GetBotnetFilter(Utility, GeneratingCommand):
|
|
|
|
"""Defines a search command that generates event records"""
|
|
|
|
|
|
|
|
custom_message = Option(name="message")
|
|
|
|
|
|
|
|
def generate(self):
|
2023-02-10 20:24:03 +00:00
|
|
|
dl_csv = self.download(DOWNLOAD_URLS)
|
2023-01-27 09:47:59 +00:00
|
|
|
for row in self.csv_reader(dl_csv):
|
|
|
|
if isinstance(self.custom_message, str) and len(self.custom_message) >= 1:
|
|
|
|
row["custom_message"] = self.custom_message
|
|
|
|
|
2023-02-15 09:40:37 +00:00
|
|
|
yield self.gen_record(_time=unix_time(), **row)
|
2023-01-27 09:47:59 +00:00
|
|
|
|
|
|
|
|
2023-02-08 10:06:21 +00:00
|
|
|
dispatch(GetBotnetFilter, sys.argv, sys.stdin, sys.stdout, __name__)
|