CentOS7はSnort3.0をインストールします



Centos 7 Installs Snort 3



1.Snortの紹介

Snortは無料ですNetwork Intrusion Prevention System(NIPS)そしてNetwork Intrusion Detection System (NIDS)データトラフィックを分析し、ネットワークデータパケットに対してプロトコル分析処理を実行する機能を備えたソフトウェア。柔軟でカスタマイズ可能なルールベース(Rule)により、処理されたメッセージコンテンツを検索して照合し、さまざまな攻撃を検出できます。そして、リアルタイムの警告。

Snort 3.0(Snort ++)は、Snortの更新バージョンです。主な機能の一部を次に示します。



  • マルチパケット処理スレッドのサポート

  • 共有プロファイルとプロパティシートを使用する



  • 単純なスクリプト構成ファイルを使用する

  • 主要コンポーネントを接続します

  • ポートレス構成の自動検出サービス



  • スティッキーバッファはルールでサポートされています

  • 参照ドキュメントを自動的に生成する

  • より良いクロスプラットフォームサポートを提供する

  • 簡単なコンポーネントテスト

将来的に含まれるその他の機能:

  • 共有Webマップを使用する

  • パイプライン処理をサポートする

  • ハードウェアオフロードとデータプレーン統合のサポート

  • プロキシモードをサポート

  • Windowsをサポートする

2、インストールepel-release

最初のインストールepel-release、その後のインストールluajitluajit-develcmake3パッケージ使用時に使用します。

yum install -y epel-release

3、パッケージキャッシュを更新します

パッケージキャッシュを更新し、システムを更新します。この手順は必要ありません。個人的なニーズを参照してください。

yum clean all yum makecache yum -y update

4、必須ではないソフトウェア

主に後続の構成を容易にするためのその他の不要なツール、使い慣れたvifind注文がスキップされるのを待つ

yum install -y mlocate vim

5、新しいコンパイルディレクトリを作成します

ルートパスの下にsnortビルドディレクトリを作成し、ここからソースコードをダウンロードします。

mkdir /snort_src

6、インストールpkg-config

インストールとコンパイルpkg-config使用する必要のあるパッケージ

yum install -y wget gcc-c++

ダウンロードpkg-configソースコード、コンパイル、インストール

cd /snort_src wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.1.tar.gz -O pkg-config-0.29.1.tar.gz tar -zxvf pkg-config-0.29.1.tar.gz cd pkg-config-0.29.1

コンパイル時に追加--with-internal-glib解決するパラメータconfigure: error: pkg-config and 'glib-2.0 >= 2.16' not found, please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure間違い

./configure --with-internal-glib make make install

7、必要な環境変数を追加します

使用export今回のみ追加

export PKG_CONFIG=/usr/local/bin/pkg-config export PKG_CONFIG_PATH=/usr/share/pkgconfig:/usr/lib64/pkgconfig

恒久的に追加する必要があります~/.bashrc

sh -c 'echo 'export PKG_CONFIG=/usr/local/bin/pkg-config' >> ~/.bashrc' sh -c 'echo 'export PKG_CONFIG_PATH=/usr/share/pkgconfig:/usr/lib64/pkgconfig' >> ~/.bashrc' source ~/.bashrc

8、依存関係パッケージをインストールします

Snortのコンパイルに使用される依存関係をインストールします

yum install -y libdnet libdnet-devel hwloc hwloc-devel luajit luajit-devel openssl openssl-devel libpcap libpcap-devel pcre pcre-devel flex bison cmake3 lzma xz-devel

9、ダイナミックリンクライブラリを更新します

ダイナミックリンクライブラリをシステムで共有します。新しいダイナミックリンクライブラリをインストールするときは、手動で実行する必要があります。

ldconfig

ldconfigデフォルトの検索/lib /usr/libでそして設定ファイル/etc/ld.so.confリストされているディレクトリ内のライブラリファイル/usr/local/libその中にはなく、手動で追加する必要があります

export LD_LIBRARY_PATH=/usr/local/lib

または

sh -c 'echo 'export LD_LIBRARY_PATH=/usr/local/lib' >> ~/.bashrc' source ~/.bashrc

10、インストールNFQ

NFQを使用してSnortをインラインモードで実行する場合、または使用するかどうかわからない場合は、このパッケージをインストールする必要があります。 IDSモードまたはafpacketを使用したインラインモードではインストールは必要ありません。

yum install -y libnetfilter_queue libnetfilter_queue-devel

11、コンパイルしてインストールdaq

cd /snort_src wget https://www.snort.org/downloads/snortplus/daq-2.2.2.tar.gz -O daq-2.2.2.tar.gz tar -zxvf daq-2.2.2.tar.gz cd daq-2.2.2 ./configure make make install

12、ダイナミックリンクライブラリを検索

ダイナミックリンクライブラリで後続のコンパイルを検索します

ldconfig -v

13、コンパイルしてインストールsnort

ここでは、cmakeのバージョンが3.4より大きい必要があります。CentOS7のデフォルトバージョンは2.8.12です。cmake3を使用してください。

cd /snort_src wget https://www.snort.org/downloads/snortplus/snort-3.0.0-243-cmake.tar.gz -O snort-3.0.0-243-cmake.tar.gz tar -zxvf snort-3.0.0-243-cmake.tar.gz cd snort-3.0.0-/ cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local make clean make make install

14、コンパイルしてインストールsnort_extra

cd /snort_src wget https://www.snort.org/downloads/snortplus/snort_extra-1.0.0-243-cmake.tar.gz -O snort_extra-1.0.0-243-cmake.tar.gz tar -zxvf snort_extra-1.0.0-243-cmake.tar.gz cd snort_extra-1.0.0-a4 cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local make clean make make install

15、環境変数を追加します

sh -c 'echo 'export LUA_PATH=/usr/local/include/snort/lua/?.lua\' >> ~/.bashrc' sh -c 'echo 'export SNORT_LUA_PATH=/usr/local/etc/snort' >> ~/.bashrc' source ~/.bashrc

または

export LUA_PATH=/usr/local/include/snort/lua/?.lua\ export SNORT_LUA_PATH=/usr/local/etc/snort export LD_LIBRARY_PATH=/usr/local/lib

16、snortをテストします

snort -V

コミュニティルールを解凍してルールディレクトリにコピーします

cd /snort_src wget https://www.snort.org/downloads/community/snort3-community-rules.tar.gz -O snort3-community-rules.tar.gz tar -xvf snort3-community-rules.tar.tar mkdir /usr/local/etc/snort/rules/ cp snort3-community-rules/snort3-community.rules /usr/local/etc/snort/rules/ cp snort3-community-rules/sid-msg.map /usr/local/etc/snort/rules/

パスが欠落していることに注意してくださいsnort_config.lua必要なファイル/usr/local/include/snort/lua/過去にコピー

cp /usr/local/include/snort/lua/snort_config.lua /usr/local/etc/snort/

コミュニティルールをテストする

snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/snort/rules/snort3-community.rules

17、ダウンロードしてインストールopenappid

知っておく必要があるのはopenappid/7611テスト後にバグを見つけました。とりあえず使っています。openappid/6239

cd /snort_src wget https://www.snort.org/downloads/openappid/6329 -O snort-openappid.tar.gz tar -zxvf snort-openappid.tar.gz

抽出したファイルを/ usr / local / libディレクトリにコピーします

cp -R odp /usr/local/lib

snort構成ファイルを変更して追加app_detector_dir

vim /usr/local/etc/snort/snort.lua appid = { app_detector_dir = '/usr/local/lib', }

appidを追加した後にテストする

snort -c /usr/local/etc/snort/snort.lua --warn-all snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/snort/rules/snort3-community.rules --warn-all

テストするルールをカスタマイズする

touch /usr/local/etc/snort/rules/local.rules vim /usr/local/etc/snort/rules/local.rules alert tcp any any -> any any (msg:'Baidu trafic Seen' appids:'Baidu' sid:10000001) snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/snort/rules/local.rules --warn-all snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/snort/rules/local.rules -i ens33 -A alert_fast -k none

18、公式の課金ルールをダウンロードしてインストールします

公式の課金ルールはウェブサイトから直接ダウンロードすることはできません。登録と支払いが必要です

cd /snort_src wget https://www.snort.org/downloads/registered/snortrules-snapshot-3000.tar.gz tar -zxvf snortrules-snapshot-3000.tar.gz mv etc /usr/local/etc/snort/ mv preproc_rules /usr/local/etc/snort/ mv so_rules /usr/local/etc/snort/ mv rules /usr/local/etc/snort/

使用される構成ファイルは/usr/local/etc/snort/etc/であることに注意してください。ディレクトリの下にも、ここにはありません。snort_config.lua必要なファイル/usr/local/include/snort/lua/過去にコピーし、追加する必要がありますapp_detector_dir

cp /usr/local/include/snort/lua/snort_config.lua /usr/local/etc/snort/etc/ vim /usr/local/etc/snort/etc/snort.lua appid = { app_detector_dir = '/usr/local/lib', }

19、アラーム出力

構成ファイルを変更する/usr/local/etc/snort/etc/snort.lua次のセクション、when file = trueアラームが対応するファイルに出力されている場合、アラームログを保存する必要があるときにこれを開く必要があります。出力フォーマットをカスタマイズし、プロンプト情報に従って変更する必要があります。

--------------------------------------------------------------------------- -- 8. configure outputs --------------------------------------------------------------------------- -- event logging -- you can enable with defaults from the command line with -A -- uncomment below to set non-default configs alert_csv = { file = true, fields = { timestamp, pkt_num, proto, pkt_gen, pkt_len, dir, src_ap, dst_ap, rule, action }, -- fields = timestamp pkt_num proto pkt_gen pkt_len dir src_ap dst_ap rule action: selected fields will be output in -- given order left to right src_ap -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } -- separator = ,: separate fields with this character sequence } alert_fast = { file = true, packet = true, -- file = false: output to alert_fast.txt instead of stdout -- packet = false: output packet dump with alert -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } } alert_full = { file = true, -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } } --alert_sfsocket = { -- file: name of unix socket file -- rules[].gid = 1: rule generator ID { 1: } -- rules[].sid = 1: rule signature ID { 1: } --} --alert_syslog = { -- facility = auth: part of priority applied to each message local7 -- level = info: part of priority applied to each message alert -- options: used to open the syslog connection perror --} unified2 = { legacy_events = false, nostamp = true, -- legacy_events = false: generate Snort 2.X style events for barnyard2 compatibility -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } -- nostamp = true: append file creation time to name (in Unix Epoch format) } -- use --plugin-path to load plugin --alert_json = { -- file = false: output to alert_json.txt instead of stdout -- fields = timestamp pkt_num proto pkt_gen pkt_len dir src_ap dst_ap rule action: selected fields will be output in -- given order left to right icmp_type -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } -- separator = , : separate fields with this character sequence --} --alert_ex = { -- upper = false: true/false → convert to upper/lower case --} -- packet logging -- you can enable with defaults from the command line with -L --log_codecs = { -- file = false: output to log_codecs.txt instead of stdout -- msg = false: include alert msg --} --log_hext = { -- file = false: output to log_hext.txt instead of stdout -- raw = false: output all full packets if true, else just TCP payload -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } -- width = 20: set line width (0 is unlimited) { 0: } --} --log_pcap = { -- limit = 0: set maximum size in MB before rollover (0 is unlimited) { 0: } --} -- additional logs --packet_capture = { } --file_log = { }

注意を払う必要があります、使用alert_jsonalert_exalert_unixsocklog_null使用する必要があります--plugin-pathプラグインパスを指定し、必要に応じて使用します-lログファイルの保存パスを指定します

snort -c /usr/local/etc/snort/etc/snort.lua --plugin-path /usr/local/lib/snort_extra -i ens33 -l /var/log/snort -A alert_json -k none

20、パラメータ情報リスト

この時点で、snort3.0がインストールされています。以下は、snort3.0でサポートされているパラメーター情報のリストです。

-? output matching command line option quick help (same as --help-options) (optional) -A set alert mode: none, cmg, or alert_* -B obfuscated IP addresses in alerts and packet dumps using CIDR mask -C print out payloads with character data only (no hex) -c use this configuration -D run Snort in background (daemon) mode -d dump the Application Layer -e display the second layer header info -f turn off fflush() calls after binary log writes -G (same as --logid) (0:65535) -g run snort gid as group (or gid) after initialization -H make hash tables deterministic -i ... list of interfaces -k checksum mode default is all (all|noip|notcp|noudp|noicmp|none) -L logging mode (none, dump, pcap, or log_*) -l log to this directory instead of current directory -M log messages to syslog (not alerts) -m set umask = (0:) -n stop after count packets (0:) -O obfuscate the logged IP addresses -Q enable inline mode operation -q quiet mode - Don't show banner and status report -R include this rules file in the default policy -r ... (same as --pcap-list) -S set config variable x equal to value v -s (same as --snaplen) default is 1514 (68:65535) -T test and report on the current Snort configuration -t chroots process to after initialization -U use UTC for timestamps -u run snort as or after initialization -V (same as --version) -v be verbose -W lists available interfaces -X dump the raw packet data starting at the link layer -x same as --pedantic -y include year in timestamp in the alert and log files -z maximum number of packet threads (same as --max-packet-threads) 0 gets the number of CPU cores reported by the system default is 1 (0:) --alert-before-pass process alert, drop, sdrop, or reject before pass default is pass before alert, drop,... --bpf are standard BPF options, as seen in TCPDump --c2x output hex for given char (see also --x2c) --create-pidfile create PID file, even when not in Daemon mode --daq select packet acquisition module (default is pcap) --daq-dir tell snort where to find desired DAQ --daq-list list packet acquisition modules available in optional dir, default is static modules only --daq-var specify extra DAQ configuration variable --dirty-pig don't flush packets on shutdown --dump-builtin-rules [] output stub rules for selected modules (optional) --dump-dynamic-rules output stub rules for all loaded rules libraries --dump-defaults [] output module defaults in Lua format (optional) --dump-version output the version, the whole version, and only the version --enable-inline-test enable Inline-Test Mode Operation --gen-msg-map dump builtin rules in gen-msg.map format for use by other tools --help list command line options --help-commands [] output matching commands (optional) --help-config [] output matching config options (optional) --help-counts [] output matching peg counts (optional) --help-module output description of given module --help-modules list all available modules with brief help --help-options [] output matching command line option quick help (same as -?) (optional) --help-plugins list all available plugins with brief help --help-signals dump available control signals --id-offset offset to add to instance IDs when logging to files (0:65535) --id-subdir create/use instance subdirectories in logdir instead of instance filename prefix --id-zero use id prefix / subdirectory even with one packet thread --list-buffers output available inspection buffers --list-builtin [] output matching builtin rules (optional) --list-gids [] output matching generators (optional) --list-modules [] list all known modules of given type (optional) --list-plugins list all known plugins --lua extend/override conf with chunk may be repeated --logid log Identifier to uniquely id events for multiple snorts (same as -G) (0:65535) --markup output help in asciidoc compatible format --max-packet-threads configure maximum number of packet threads (same as -z) (0:) --mem-check like -T but also compile search engines --nostamps don't include timestamps in log file names --nolock-pidfile do not try to lock Snort PID file --pause wait for resume/quit command before processing packets/terminating --parsing-follows-files parse relative paths from the perspective of the current configuration file --pcap-file file that contains a list of pcaps to read - read mode is implied --pcap-list a space separated list of pcaps to read - read mode is implied --pcap-dir a directory to recurse to look for pcaps - read mode is implied --pcap-filter filter to apply when getting pcaps from file or directory --pcap-loop read all pcaps times 0 will read until Snort is terminated (-1:) --pcap-no-filter reset to use no filter when getting pcaps from file or directory --pcap-reload if reading multiple pcaps, reload snort config between pcaps --pcap-show print a line saying what pcap is currently being read --pedantic warnings are fatal --plugin-path where to find plugins --process-all-events process all action groups --rule to be added to configuration may be repeated --rule-to-hex output so rule header to stdout for text rule on stdin --rule-to-text output plain so rule header to stdout for text rule on stdin --run-prefix prepend this to each output file --script-path to a luajit script or directory containing luajit scripts --show-plugins list module and plugin versions --skip skip 1st n packets (0:) --snaplen set snaplen of packet (same as -s) (68:65535) --stdin-rules read rules from stdin until EOF or a line starting with END is read --treat-drop-as-alert converts drop, sdrop, and reject rules into alert rules during startup --treat-drop-as-ignore use drop, sdrop, and reject rules to ignore session traffic when not inline --version show version number (same as -V) --warn-all enable all warnings --warn-conf warn about configuration issues --warn-daq warn about DAQ issues, usually related to mode --warn-flowbits warn about flowbits that are checked but not set and vice-versa --warn-hosts warn about host table issues --warn-plugins warn about issues that prevent plugins from loading --warn-rules warn about duplicate rules and rule parsing issues --warn-scripts warn about issues discovered while processing Lua scripts --warn-symbols warn about unknown symbols in your Lua config --warn-vars warn about variable definition and usage issues --x2c output ASCII char for given hex (see also --c2x) --x2s output ASCII string for given byte code (see also --x2c)