1. 程式人生 > >基於Windows7下snort+apache+php 7 + acid(或者base) + adodb + jpgraph的入侵檢測系統的搭建(圖文詳解)(博主推薦)

基於Windows7下snort+apache+php 7 + acid(或者base) + adodb + jpgraph的入侵檢測系統的搭建(圖文詳解)(博主推薦)

為什麼,要寫這篇論文?

   是因為,目前科研的我,正值研三,致力於網路安全、大資料、機器學習、人工智慧、區域鏈研究領域!

  論文方向的需要,同時不侷限於真實物理環境機器實驗室的攻防環境、也不侷限於真實物理機器環境實驗室的大資料叢集平臺。在此,為了需要的博友們,能在自己虛擬機器裡(我這裡是CentOS6.5)來搭建部署snort+barnyard2+base的入侵檢測系統。分享與交流是進步的階梯!

  同時,本人還嘗試過在Ubuntu14.04裡搭建這入侵檢測系統的環境。同時,還嘗試過在win7\win10裡搭建這入侵檢測系統的環境。

   同時,也歡迎做報警資料方向的菸酒僧留言評論加好友交流。歡迎指正!謝謝。

   告誡:大家能在Linux環境下,就儘量別安裝在windows裡。

   我的系統情況是

 base和acid的關係

   在Ubuntu和CentOS裡,用base居多。

   在windows裡,用acid居多。但是,我這篇部落格,acid和base都演示。(反而我更喜歡用base)

   Apache的安裝

  Mysql的安裝

  winpcap的安裝

   這裡不多說,太簡單了。

 

   PHP的安裝

   Snort的安裝

   下載下來,隨便先放在哪裡,因為,我們最後預設是安裝在C:\Snort。

 

 

 

 

  其實啊,Snort是個命令列軟體,所以,不要感覺到畏懼。

  win+r 輸入cmd,然後輸入路徑cd c:\snort\bin       由於snort 是基於linux設計的,所以在 c:\snort\ect\snort.con 檔案是要用notepad++修改成window 的格式才能工作的。      可以用“snort -?”可以檢視相關的命令
c:\Snort\bin>snort -?

   ,,_     -*> Snort! <*-
  o"  )~   Version 2.8.6-ODBC-MySQL-FlexRESP-WIN32 GRE (Build 38)
   ''''    By Martin Roesch & The Snort Team: http://www.snort.org/snort/snort-t
eam
           Copyright (C) 1998-2010 Sourcefire, Inc., et al.
           Using PCRE version: 7.4 2007-09-21
           Using ZLIB version: 1.2.3

USAGE: snort [-options] <filter options>
       snort /SERVICE /INSTALL [-options] <filter options>
       snort /SERVICE /UNINSTALL
       snort /SERVICE /SHOW
Options:
        -A         Set alert mode: fast, full, console, test or none  (alert file alerts only)
        -b         Log packets in tcpdump format (much faster!)
        -B <mask>  Obfuscated IP addresses in alerts and packet dumps using CIDR  mask
        -c <rules> Use Rules File <rules>
        -C         Print out payloads with character data only (no hex)
        -d         Dump the Application Layer
        -e         Display the second layer header info
        -E         Log alert messages to NT Eventlog. (Win32 only)
        -f         Turn off fflush() calls after binary log writes
        -F <bpf>   Read BPF filters from file <bpf>
        -G <0xid>  Log Identifier (to uniquely id events for multiple snorts)
        -h <hn>    Home network = <hn>
        -H         Make hash tables deterministic.
        -i <if>    Listen on interface <if>
        -I         Add Interface name to alert output
        -k <mode>  Checksum mode (all,noip,notcp,noudp,noicmp,none)
        -K <mode>  Logging mode (pcap[default],ascii,none)
        -l <ld>    Log to directory <ld>
        -L <file>  Log to this tcpdump file
        -n <cnt>   Exit after receiving <cnt> packets
        -N         Turn off logging (alerts still work)
        -O         Obfuscate the logged IP addresses
        -p         Disable promiscuous mode sniffing
        -P <snap>  Set explicit snaplen of packet (default: 1514)
        -q         Quiet. Don't show banner and status report
        -r <tf>    Read and process tcpdump file <tf>
        -R <id>    Include 'id' in snort_intf<id>.pid file name
        -s         Log alert messages to syslog
        -S <n=v>   Set rules file variable n equal to value v
        -T         Test and report on the current Snort configuration
        -U         Use UTC for timestamps
        -v         Be verbose
        -V         Show version number
        -W         Lists available interfaces. (Win32 only)
        -X         Dump the raw packet data starting at the link layer
        -x         Exit if Snort configuration problems occur
        -y         Include year in timestamp in the alert and log files
        -Z <file>  Set the performonitor preprocessor file path and name
        -?         Show this information
<Filter Options> are standard BPF options, as seen in TCPDump
Longname options and their corresponding single char version
   --logid <0xid>                  Same as -G (即snort -G)
   --perfmon-file <file>           Same as -Z   (即snort -Z)
   --pid-path <dir>                Specify the directory for the Snort PID file
   --snaplen <snap>                Same as -P   (即snort -P)
   --help                          Same as -?   (即snort -?--version                       Same as -V  (即snort -V)
   --alert-before-pass             Process alert, drop, sdrop, or reject before pass, default is pass before alert, drop,...
   --treat-drop-as-alert           Converts drop, sdrop, and reject rules into alert rules during startup
   --process-all-events            Process all queued events (drop, alert,...),default stops after 1st action group
   --dynamic-engine-lib <file>     Load a dynamic detection engine
   --dynamic-engine-lib-dir <path> Load all dynamic engines from directory
   --dynamic-detection-lib <file>  Load a dynamic rules library
   --dynamic-detection-lib-dir <path> Load all dynamic rules libraries from directory
   --dump-dynamic-rules <path>     Creates stub rule files of all loaded rules l
ibraries
   --dynamic-preprocessor-lib <file>  Load a dynamic preprocessor library
   --dynamic-preprocessor-lib-dir <path> Load all dynamic preprocessor libraries from directory
   --pcap-single <tf>              Same as -r.   (即snort -r)
   --pcap-file <file>              file that contains a list of pcaps to read -read mode is implied.
   --pcap-list "<list>"            a space separated list of pcaps to read - read mode is implied.
   --pcap-loop <count>             this option will read the pcaps specified on command line continuously.
                                   for <count> times.  A value of 0 will read until Snort is terminated.
   --pcap-reset                    if reading multiple pcaps, reset snort to post-configuration state before reading next pcap.
   --pcap-show                     print a line saying what pcap is currently being read.
   --exit-check <count>            Signal termination after <count> callbacks from pcap_dispatch(), showing the time it
                                   takes from signaling until pcap_close() is called.
   --conf-error-out                Same as -x  (即snort -x)
   --enable-mpls-multicast         Allow multicast MPLS
   --enable-mpls-overlapping-ip    Handle overlapping IPs within MPLS clouds
   --max-mpls-labelchain-len       Specify the max MPLS label chain
   --mpls-payload-type             Specify the protocol (ipv4, ipv6, ethernet) that is encapsulated by MPLS
   --require-rule-sid              Require that all snort rules have SID specified.

c:\Snort\bin>

  snort所需mysql的配置

  建立Snort執行必需的Snort庫和Snort_archive庫:

C:\Users\Administrator>mysql -uroot -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 28 to server version: 5.0.22-community-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database snort; Query OK, 1 row affected (0.00 sec) mysql> create database snort_archive; Query OK, 1 row affected (0.04 sec) mysql>
      然後,注意,這裡的
CREATE TABLE signature ( sig_id       INT          UNSIGNED NOT NULL AUTO_INCREMENT,
                         sig_name     VARCHAR(255) NOT NULL,
                         sig_class_id INT          UNSIGNED NOT NULL,
                         sig_priority INT          UNSIGNED,
                         sig_rev      INT          UNSIGNED,
                         sig_sid      INT          UNSIGNED,
                         sig_gid      INT          UNSIGNED,
                         PRIMARY KEY (sig_id),
                         INDEX   sign_idx (sig_name(20)),
                         INDEX   sig_class_id_idx (sig_class_id));
  大家,自行根據自己的安裝目錄去。  
C:\Users\Administrator>cd /d D:\

D:\>cd D:\SoftWare\MySQL Server\MySQL Server 5.0\bin

D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>mysql -D snort -u root -p < c:\Snort\schemas\create_mysql
Enter password: ****

D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>mysql -D snort_archive -u root -p < c:\Snort\schemas\create_mysql
Enter password: ****

D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>
  執行完create_mysql指令碼後,使用者可以通過在mysql提示符下執行sql語句show tables來驗證配置的正確性。    
D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31 to server version: 5.0.22-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+-----------------------+
| Database              |
+-----------------------+
| information_schema    |
| elsa_web              |
| mysql                 |
| securityonion_db      |
| snort                 |
| snort_archive         |
| syslog                |
| test                  |
| weka                  |
| wholedatabasesanddata |
+-----------------------+
11 rows in set (0.00 sec)

mysql> use snort;
Database changed
mysql> show tables;
+------------------+
| Tables_in_snort  |
+------------------+
| data             |
| detail           |
| encoding         |
| event            |
| icmphdr          |
| iphdr            |
| opt              |
| reference        |
| reference_system |
| schema           |
| sensor           |
| sig_class        |
| sig_reference    |
| signature        |
| tcphdr           |
| udphdr           |
+------------------+
16 rows in set (0.00 sec)

mysql> use snort_archive;
Database changed
mysql> show tables;
+-------------------------+
| Tables_in_snort_archive |
+-------------------------+
| data                    |
| detail                  |
| encoding                |
| event                   |
| icmphdr                 |
| iphdr                   |
| opt                     |
| reference               |
| reference_system        |
| schema                  |
| sensor                  |
| sig_class               |
| sig_reference           |
| signature               |
| tcphdr                  |
| udphdr                  |
+-------------------------+
16 rows in set (0.00 sec)

mysql>
   然後,   必需在Apache伺服器主機(暫定為localhost)上建立ACID和Snort使用者,併為它們分配相關許可權和訪問密碼,使ACID能正常訪問後臺資料庫mysql中Snort相關的資料檔案。  
mysql> grant usage on *.* to "acid"@"localhost" identified by "acid";
Query OK, 0 rows affected (0.01 sec)

mysql> grant usage on *.* to "snort"@"localhost" identified by "snort";
Query OK, 0 rows affected (0.00 sec)
 
mysql> grant select,insert,update,delete,create,alter on snort .* to "snort"@"localhost";
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,insert,update,delete,create,alter on snort .* to "acid"@"localhost";
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,insert,update,delete,create,alter on snort_archive .* to "acid"@"localhost";
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,insert,update,delete,create,alter on snort_archive .* to "snort"@"localhost";
Query OK, 0 rows affected (0.00 sec)

mysql>
  然後,接著
mysql> set password for "snort"@"localhost"=password('snort');
Query OK, 0 rows affected (0.00 sec)

mysql> set password for "acid"@"localhost"=password('acid');
Query OK, 0 rows affected (0.00 sec)

mysql>
  至此,配置完成!

     snort配置檔案snort.conf的配置

  首先,來認識下snort.conf     答:snort.conf是封包的簽章檔案,裡邊定義了掃描的規則、規則存放的目錄     classification.configreference.config是兩個被主配置檔案snort.conf引用的配置檔案。     classification.config檔案包括了關於snort規則分類的資訊。     reference.config檔案中羅列了一些關於報警資訊的參考網站的URL,這些參考將在snort規則中引用。     它們通常存放在於snort.conf相同的目錄中。     在snort.conf檔案中將指定這些檔案的目錄。如果它們的存放位置發生了改變,也可以通過將主配置檔案snort.conf中的相對路徑改為絕對路徑來進行調整:         改為

 

  注意:由於snort軟體的配置檔案snort.conf預設的路徑針對的是LINUX,在windows下面必須要改路徑,而且是絕對路徑。   錯誤:ERROR:c:\snort\etc\snort.conf<45> Unknow rule type:ipvar    解決辦法:把檔案中的ipvar改為var,改好後儲存一下。   注意:現在,這個錯誤已經沒了。現在的snort配置檔案,都是var了。   錯誤:ERROR: c:\snort\etc\snort.conf(247) Could not stat dynamic module path "/usr/local/lib/snort_dynamicpreprocessor/": No such file or directory.   解決辦法:由於snort軟體的配置檔案snort.conf預設的路徑針對的是LINUX,在windows下面必須要改路徑,而且是絕對路徑。

 

 

 

  注意:“dynamicpreprocessor directory C:\Snort\lib\snort_dynamicpreprocessor”中一定不要在最後加上一個反斜槓“\”,這是snort的一個bug。      然後,

 

  改為   然後,   注意:snort\lib下面新建一個snort_dynamicrules資料夾,不然還會報錯。         改為      然後,   設定Snort輸出alert到mysql server   改為      修改路徑變數

   改為

   然後,這個保持預設就好

 

   然後,

   改為

preprocessor http_inspect: global iis_unicode_map C:\Snort\etc\unicode.map 1252 compress_depth 65535 decompress_depth 65535

  因為在windows下unicode.map這個檔案在etc資料夾下。

  配置好後,儲存。

Snort下的snort2860規則庫包的安裝和配置

  因為,我的snort版本是2.8.6,所以得要下載對應的規則包。  

  別問能科學上網,這個大家自行去解決。又不難。

http://val.bmstu.ru/unix/snort/
     

  這是因為windows下安裝好snort後預設是沒有規則庫,需要自己下載。

   

 複製裡面的doc、rules、so_rules到c:\Snort下

  這裡有些資料說,如http://www.cnblogs.com/kathmi/archive/2010/08/09/1795405.html

  • snortrules-snapshot-2860.tar.gz(規則庫,解壓到Snort的安裝目錄,如果提示重複檔案,可以選擇不覆蓋)

  其實,我覺得,就只需要將snortrules-snapshot-2860.tar.gz裡的doc、rules、so_rules到c:\Snort下即可。

  為什麼呢。首先rules本來是空的,so_rules是沒有的,至於嘛,doc更別提了。

   最後目錄結構為

   

  配置動態規則

  acid的安裝和配置(其實,我更傾向於在windows裡使用base)       ACID是一種通過Web介面來分析察看Snort資料的工具。它是用PHP編寫的,與Snort和MySQL資料庫一同工作。               修改acid_conf.php檔案為下列格式          然後,      或者
$alert_dbname   = "snort";
$alert_host     = "localhost";
$alert_port     = "3306";
$alert_user     = "snort";
$alert_password = "snort";


$archive_dbname   = "snort_archive";
$archive_host     = "localhost";
$archive_port     = "3306";
$archive_user     = "acid";
$archive_password = "acid";
  然後,   配置完成後要重新啟動apache。   base的安裝與配置  

進行重新命名,改為base-1.4.5,為base。

   大家,然後,這裡也可以跟acid一樣,手動去這個配置檔案裡去修改配置。(但是呢。我這裡介面化來配置,更加的形象)

 

   1、用windows裡的谷歌瀏覽器或者火狐瀏覽器或者IE瀏覽器都行。,開啟http://localhost/base/setup/index.php

2.選擇顯示語言,設定adodb路徑

3.配置資料庫

 

 

4.設定admin使用者和密碼(這裡應該是設定admin的使用者和密碼,我這裡是admin)

5.點選“Createe BASE AG”

  adodb的安裝與配置(搭配PHP 7)   注意:我這裡的PHP是7版本,所以,得找對應版本才是。
http://adodb.org/dokuwiki/doku.php?id=v5:php7_status
 

 

 

  我這裡為了方便,進行改名,將adodb5重新命名為adodb。

   證明,能讀取到。

   jpgraph的安裝與配置    

 

  我這裡,為了方便,改名,將jpgraph-2.1.4重新命名為

 

 

  證明,能讀取到。

  這裡,大家也可以去看一些質量比較好的論文,如

   基於Snort的混合入侵檢測系統的研究與實現_李文龍(2011年)

歡迎大家,加入我的微信公眾號:大資料躺過的坑        人工智慧躺過的坑

同時,大家可以關注我的個人部落格

   http://www.cnblogs.com/zlslch/   和     http://www.cnblogs.com/lchzls/      http://www.cnblogs.com/sunnyDream/   

   詳情請見:http://www.cnblogs.com/zlslch/p/7473861.html

  人生苦短,我願分享。本公眾號將秉持活到老學到老學習無休止的交流分享開源精神,匯聚於網際網路和個人學習工作的精華乾貨知識,一切來於網際網路,反饋回網際網路。
  目前研究領域:大資料、機器學習、深度學習、人工智慧、資料探勘、資料分析。 語言涉及:Java、Scala、Python、Shell、Linux等 。同時還涉及平常所使用的手機、電腦和網際網路上的使用技巧、問題和實用軟體。 只要你一直關注和呆在群裡,每天必須有收穫

      對應本平臺的討論和答疑QQ群:大資料和人工智慧躺過的坑(總群)(161156071) 

 

相關推薦

基於Windows7snort+apache+php 7 + acid或者base + adodb + jpgraph入侵檢測系統搭建圖文推薦

為什麼,要寫這篇論文?    是因為,目前科研的我,正值研三,致力於網路安全、大資料、機器學習、人工智慧、區域鏈研究領域!   論文方向的需要,同時不侷限於真實物理環境機器實驗室的攻防環境、也不侷限於真實物理機器環境實驗室的大資料叢集平臺。在此,為了需要的博友們,能在自己虛擬機器裡(我這裡

基於CentOS6.5snort+barnyard2+base入侵檢測系統搭建圖文推薦

為什麼,要寫這篇論文?    是因為,目前科研的我,正值研三,致力於網路安全、大資料、機器學習研究領域!   論文方向的需要,同時不侷限於真實物理環境機器實驗室的攻防環境、也不侷限於真實物理機器環境實驗室的大資料叢集平臺。在此,為了需要的博友們,能在自己虛擬機器裡(我這裡是CentOS

全網最詳細的基於Ubuntu14.04/16.04 + Anaconda2 / Anaconda3 + Python2.7/3.4/3.5/3.6安裝Tensorflow詳細步驟圖文推薦

  不多說,直接上乾貨! 前言   建議參照最新的tensorflow安裝步驟(Linux,官方網站經常訪問不是很穩定,所以給了一個github的地址):          https://github.com/tensorflow/tensorflow/blob/master/t

CentOS 7系統安裝配置圖文

安裝CentOS一、安裝CentOS 7成功引導系統後,會出現下面的界面界面說明:Install CentOS Linux 7 #安裝CentOS 7 Test this media & install CentOS Linux 7 #測試安裝文件並安裝CentOS7 Troublesh

Ubuntu14.04Neo4j圖資料庫官網安裝部署步驟圖文推薦

  不多說,直接上乾貨! 說在前面的話    首先,檢視下你的作業系統的版本。  [email protected]:~# cat /etc/issue Ubuntu 14.04.4 LTS \n \l [email protected]:~#

Ubuntu14.04完美安裝cloudermanage多種方式圖文推薦

說在前面的話   我的機器是總共4臺,分別為ubuntucmbigdata1、ubuntucmbigdata2、ubuntucmbigdata3和ubuntucmbigdata4。   ClouderaManager官網 https://www.cloudera.com/docume

基於JDBC的跨平臺資料庫管理工具DbVisualizer安裝步驟圖文推薦

   首先,關於跨平臺資料庫管理工具DbVisualizer是什麼?這個不多說,大家自行去看。      這個工具可以自定義連線其他沒有驅動的資料庫。       公司的專案牽扯到的資料庫有mysql,sqlserver,oracle,mongda,postgresql,hive等。

Ubuntu16.04Neo4j圖資料庫官網安裝部署步驟圖文推薦

 不多說,直接上乾貨! 說在前面的話    首先,檢視下你的作業系統的版本。  [email protected]virtual-machine:~# cat /etc/issue Ubuntu 16.04.1 LTS \n \l [email p

centos 6.5編譯安裝php-7.1.6和 php memcached擴展

php 編譯安裝 memcached 0,安裝 php-7.1.6 依賴包# yum groupinstall "Development tools" "Desktop Platform Development" # yum -y install openssl-devel libcurl-dev

ubuntu安裝Apache+PHP+Mysql

安全性 直接 刪除 但是 roo 交互 安裝apache 現在 col 電影《社交網絡》中,facebook創始人馬克.紮克失戀後入侵哈佛大學宿舍樓服務器,竊取數據庫資料,並在兩個小時內完成了一個給校內女生評分的交互網站,該網站一天內點擊數過10W,直接導致學校服務器崩潰。

健忘隨發 win10部署Apache+php+mysql

.exe conf ati php.ini grant ins del 多模塊 pan   win10系統重裝,忽然接到開發任務。想著直接在雲服務器上直接調試,結果發現對於我等菜鳥來講,實在有太多磕磕碰碰會影響整個開發進度。偷懶不可取,所以健忘的我把整個wamp部署再記下來

ECS裡Centos7.2編譯安裝PHP-7.2.11(PHP-FPM)

centos7下編譯安裝php-7.2.11(PHP-FPM) 一、下載php7原始碼包 1 http://php.net/downloads.php 如:php-7.2.11.tar.gz 二、安裝所需依賴 > yu

Linux環境配置Apache+PHP

1、安裝apache 1.1、安裝apr wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz tar -zxvf apr-1.6.3.tar.gz cd apr-1.6.3 ./configu

Windows7 如何給PHP 5.6.X 安裝 memcached 擴充套件?

看到標題的童鞋,讓你們失望了,這個問題我也沒有解決。 本地PHP環境如下: 關鍵引數: 1.PHP Version 5.6.15 2.Architecture    :x86 3.PHP Extension Build    :API2

window安裝Apache+PHP+MySQL

四、安裝PHP 進入php下載執行緒安全二進位制解壓包http://php.net/downloads.php 在Apache的httpd.conf檔案中加入 #LoadModule watchdog_module modules/mod_watchdog.so #LoadModule xml2e

deepin安裝apache+php+mysql

安裝apache 開啟終端輸入 sudo apt-get install apache2 安裝完成本地開啟瀏覽器訪問127.0.0.1檢視是否安裝完成 安裝php5 開啟終端輸入 sudo apt-get install php5 libapache2-mod-php5 安裝mysql

CentOS檢視apache,php,mysql版本資訊

    uname -a;   more /etc/issue;    cat /proc/version; 2. 檢視apache的版本資訊,如果是通過yum,或者是rpm安裝的,可以使用rpm -qa |gerp httpd 來檢視; 還可以通過httpd -v來查詢; 當然,安裝好

windows Server 2003 安裝Apache+Php+Mysql+Zend Optimizer

zend optimizer下載 現在的zend optimizer已變更成zend guard loader 選擇對應的PHP執行時環境版本的zend guard loader,這裡選擇runtime for php5.4。 配置zend guard loader 1.把zend guard loader壓

Linuxcentos7+apache tomcat 7 配置專案只輸入IP即登陸到專案並且強制啟用Https的配置方法

生成可用的keystore  在windows下,開啟cmd命令列,執行keytool -genkey -alias tomcat -keyalg RSA -keystore d:\tomcatSSL.keystore命令,其中-alias後面的引數是你keystore的別

Windows 7作業系統Apache的安裝與配置圖文

This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See <UR