日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

OSSIM开源安全信息管理系统(十七)

發(fā)布時(shí)間:2023/12/14 windows 65 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OSSIM开源安全信息管理系统(十七) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2021SC@SDUSC




七、Agent部分源代碼分析

1、Agent 簡(jiǎn)介

OSSIM Agent中所有腳本采用 Python 編寫,負(fù)責(zé)從安全設(shè)備采集相關(guān)信息(比如報(bào)警日志等),并將采集到的各類信息統(tǒng)一格式,最后將這些數(shù)據(jù)傳至 Server。從采集方式上看,Agent 屬于主動(dòng)采集,可以形象理解為由OSSIM Server 安插在各個(gè)監(jiān)控網(wǎng)段的“耳目”,由它們收集數(shù)據(jù),并主動(dòng)推送到 Collector 中,然后 Collector 又連接著消息隊(duì)列系統(tǒng)、緩存系統(tǒng)及存儲(chǔ)系統(tǒng)。

Agent 相關(guān)目錄在 /etc/ossim/agent/ ,代理插件目錄在 /etc/ossim/agent/plugins/ ,配置文件路徑:/etc/ossim/agent/config.cfg ,OSSIM系統(tǒng)的代理信息查看方法,通過(guò) Analysis→Detection 下的 HIDS 標(biāo)簽中 Agents 查看。

Agent 結(jié)構(gòu):



Agent 的主要功能是接收或抓取 Plugins 發(fā)送過(guò)來(lái)或者生成的日志,經(jīng)過(guò)歸一化處理,然后有序地傳送到 OSSIM的 Server,它的功能很復(fù)雜,因?yàn)樗脑O(shè)計(jì)要考慮到如果 Agent 和 Server 之間的網(wǎng)絡(luò)中斷、擁堵、丟包等情況。

Agent 會(huì)主動(dòng)連接兩個(gè)端口與外界通信,一個(gè)是連接 Server 的40001端口,而另一個(gè)是連接數(shù)據(jù)庫(kù)的3306端口。如圖所示。


Agent 將原始日志分成若干段并填充到相應(yīng)的域中,相關(guān)字段如下:

  • date、sensor、interface、plugin_id、plugin_sid、priority、protocol、src_ip、src_port、dst_ip、dst_port

  • username、password、filename、userdata1、userdata2、userdata3、userdata4、userdata5、userdata6、userdata7、userdata8、userdata9


2、Agent.py 源碼分析

首先導(dǎo)入一些必要的模塊

import os import sys import time import signal import threading import socket import codecs import uuid import yaml import subprocess as sub

然后導(dǎo)入本地模塊

Conf 類繼承自 ConfigParser

from Config import Conf, Plugin, Aliases, CommandLineOptions from ConfigParser import Error as BaseConfigError from ParserLog import ParserLog from ParserJson import ParserJson from Watchdog import Watchdog from Logger import Logger from Output import Output from Stats import Stats from Conn import ServerConn, IDMConn, FrameworkConn from Exceptions import AgentCritical from ParserDatabase import ParserDatabase from ParserWMI import ParserWMI from ParserSDEE import ParserSDEE from ParserRemote import ParserRemote from ParserUtil import HostResolv from ParserFtp import ParserFTP from ParserFormattedSnort import SnortEventsParser

定義全局變量:

Logger 類:用于日志記錄的靜態(tài)類。用于輸出運(yùn)行日志,可以設(shè)置輸出日志的等級(jí)、日志保存路徑、日志文件回滾等。

logger = Logger.loggerSTAT_SIGNALS = {'clients': 40, 'plugins': 41, 'all': 50} DEFAULT_SYSTEM_FILE = "/etc/ossim/agent/agentuuid.dat" DEFAULT_PULSE_PLUGIN_PATH = '/etc/ossim/agent/av_pulse.cfg'

接下來(lái)就是具體類 Agent 的代碼部分。

1、初始化方法 __init__

def __init__(self):# 調(diào)用CommandLineOptions的get_options()方法,解析命令行選項(xiàng)self.options = CommandLineOptions().get_options()# 讀取相關(guān)配置self.conf = Conf()if self.options.config_file:self.__conffile = self.options.config_file#如果options中未通過(guò)“-c”命令行指定配置文件,則采用Conf類中默認(rèn)的配置文件#DEFAULT_CONFIG_FILE = "/etc/ossim/agent/config.cfg"else:self.__conffile = self.conf.DEFAULT_CONFIG_FILE#通過(guò)類Conf的read方法以latin1編碼方式讀取配置文件#Latin1是一種編碼方式,為ISO-8859-1的別名self.conf.read([self.__conffile], 'latin1')# 插件列表self.__plugins = []#其中的規(guī)則總數(shù)self.__nrules = 0#從/etc/ossim/agent/host_cache.dic中加載緩存HostResolv.loadHostCache()self.detector_objs = []self.watchdog = Noneself.shutdown_running = Falseself.__outputServerConnection = Noneself.__outputIDMConnection = Noneself.__frameworkConnection = Noneself.__keep_working = Trueself.__checkThread = Noneself.__stop_server_counter = 9999self.__pluginStopEvent = threading.Event()self.__sensorID = ""self.__systemUUIDFile = ""

配置文件格式:





本篇文章部分內(nèi)容參考或轉(zhuǎn)載自下列文章及書籍。侵權(quán)即刪。

參考書籍:

  • 《開(kāi)源安全運(yùn)維平臺(tái)OSSIM疑難解析(入門篇)》——李晨光著
  • 《開(kāi)源安全運(yùn)維平臺(tái)OSSIM疑難解析(提高篇)》——李晨光著
  • 《開(kāi)源安全運(yùn)維平臺(tái):OSSIM最佳實(shí)踐》——李晨光著

參考文章:

  • https://blog.51cto.com/chenguang/2426473
  • https://blog.csdn.net/lcgweb/article/details/101284949
  • https://blog.51cto.com/chenguang/1665012
  • https://www.cnblogs.com/lsdb/p/10000061.html
  • https://blog.51cto.com/chenguang/1691090
  • https://blog.51cto.com/chenguang/category10.html
  • https://blog.51cto.com/topic/ossim.html
  • https://blog.csdn.net/isinstance/article/details/53694361
  • https://blog.51cto.com/chenguang/1332329
  • https://www.cnblogs.com/airoot/p/8072727.html
  • https://blog.51cto.com/chenguang/1738731
  • https://blog.csdn.net/security_yj/article/details/120153992

上一篇:
下一篇:

總結(jié)

以上是生活随笔為你收集整理的OSSIM开源安全信息管理系统(十七)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。