|
|
|||||||
ชื่อเรื่อง : การติดตั้ง Snort ร่วมกับ ACID (+MySQL)
ที่มา : http://www.incident.org/snortdb
เรียบเรียงโดย : ภูวดล ด่านระหาญ
เรียบเรียงเมื่อ : 3 สิงหาคม 2544
กล่าวนำ
จากบทความเรื่องการติดตั้ง Snort แบบง่ายนั้น อาจจะไม่ตรงกับความต้องการของผู้ดูแลระบบที่ต้องการรวมศูนย์ข้อมูล
log เช่น ต้องการให้ข้อมูล alert log ทั้งหมดเก็บไว้ในฐานข้อมูลแล้วให้สามารถเรียกดูผ่าน
web browser รวมทั้งสามารถจัดการกับข้อมูลนั้นได้โดยตรง ดังนั้นในบทความฉบับนี้จะนำท่านไปยังการติดตั้ง
Snort ร่วมกับ ACID เพื่อให้ใช้งานได้อย่างสะดวก
ACID คืออะไร
ACID ย่อมาจาก Analysis Console for
Intrusion Databases เป็นผลงานของ CERT/CC
ที่ทำให้กับ AIRCERT Project เป็นเครื่องมือที่ใช้สำหรับวิเคราะห์ข้อมูลจากฐานข้อมูลของ
IDS โดย ACID นี้เขียนขึ้นโดยใช้ PHP
Snort และ Database
Snort สนับสนุนฐานข้อมูล MySQL, Postgresql, unixODBC และ Oracle ในกรณีที่ท่านใช้ฐานข้อมูลอื่น
เช่น DB2, Informix หรืออื่นๆ ท่านสามารถใช้ unixODBC เป็นตัวกลางในการเชื่อมต่อได้
ก่อนการติดตั้ง Snort
การติดตั้ง Snort
ดาวน์โหลด Snort เวอร์ชั่นล่าสุดจาก www.snort.org จากนั้นให้ขยายไฟล์ออก ดังนี้ #tar xzf snort-x.x.x.tar.gz -C /usr/local
ให้ compile โดยเพิ่ม option ดังนี้ --with-mysql-includes=DIR และ --with-mysql-libraries=DIR เช่น #cd /usr/local/snort
#./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libraries=/usr/lib/mysql
#make
#make install
ทั้งนี้ในขณะที่โปรแกรมกำลังคอมไพล์อยู่นั้น ท่านควรจะสังเกตเห็นคำว่า checking for mysql... yes ปรากฏขึ้น จากนั้นให้ก้อปปี้ข้อมูล configuration และ rules files จาก source ของ Snort ไปยัง /etc/snort เพื่อความเป็นระเบียบ #mkdir /etc/snort
#cd /usr/local/src/snort
#cp snort.conf /etc/snort
#cp *.rules /etc.snort
#cp classification.config /etc/snort
สร้างไดเร็คทอรีเพื่อเก็บล็อกไฟล์ของ Snort ทั้งหมดแยกต่างหาก และควรป้องกันไม่ให้บุคคลอื่น access เข้ามาที่ไดเร็คทอรีนั้นๆ โดยปกติแล้วจะสร้างไว้ที่ /var/log/snort #mkdir /var/log/snort
#chmod 700 /var/log/snort
สร้าง database structure สำหรับ Snort
ให้ล็อกอินเข้าไปยัง MySQL และสร้าง database ชื่อ snort ขึ้นมา #mysql -uroot -p
......
mysql>CREATE DATABASE snort;จากนั้นให้สร้าง MySQL account ขึ้นมาเพื่อให้มีสิทธิในการจัดการกับฐานข้อมูล mysql>grant insert,delete,select,create,update on snort.* to snort@localhost;
mysql>flush privileges;จากนั้นก็ต้องสร้าง database structure ตามที่ Snort กำหนดไว้ #cd /usr/local/snort
#vi contrib/create_mysql แล้วเพิ่มคำว่า USE snort; ไว้ที่บรรทัดบนสุด
#mysql < ./contrib/create_mysql -uroot -p*** อย่าลืมตั้งรหัสผ่านของ MySQL account : snort ก่อนการนำไปใช้งานจริง
ติดตั้ง PHPlot, ADODB, ACID
$DBlib_path : full path to the ADODB install เช่น /www/htdocs/adodb
$DBtype : type of the database used ("mysql", "postgres") เช่น mysql
$alert_dbname : MySQL database name where the alerts are stored เช่น snort
$alert_host : host where the database is stored เช่น localhost
$alert_port : port where the database is stored เช่น 3306
$alert_user : username into the database เช่น snort
$alert_password : password for the username
$ChartLib_path : full path to the PHPlot install เช่น /www/htdocs/phplot
Snort Plugin Configuration
ให้แก้ไขไฟล์ /etc/snort/snort.conf เพื่อให้ snort เก็บข้อมูลเข้า database โดยมีลักษณะดังนี้
output database: [log | alert], [type of database], [parameter list]
Arguments:
[log | alert] - ระบุว่าจะเก็บข้อมูลในส่วนของ
alert หรือ log ปกติแล้วจะใช้ log
[type of database] - เช่น mysql, postgresql,
and unixodbc.
[parameter list] - รูปแบบคือ key=value คั่นแต่ละ
key ด้วย space
dbname - the name of the database you are connecting to
host - the host the RDBMS is on
port - the port number the RDBMS is listening on
user - connect to the database as this user
password - the password for given user
sensor_name - specify your own name for this snort
sensor. If you do not specify a name one will be generated automatically.
encoding - มีสามชนิดคือ hex, base64, ascii
detail - รายละเอียดการเก็บข้อมูล มี full และ fast(default)
ตัวอย่างเช่น output database: log, mysql,
dbname=snort user=snort host=localhost password=snortpass
รัน Snort (daemon)
ทดลองรัน /usr/local/bin/snort -c /etc/snort/snort.conf ถ้าไม่มี error ใดๆ แสดงว่าสามารถใช้งานได้
เพียงแต่การใช้งานจริงนั้นจะรันใน daemon mode โดยจะใช้คำสั่งดังนี้
#/usr/local/bin/snort -D -c /etc/snort/snort.conf
ทิ้งท้าย
Snort ไม่สามารถเก็บข้อมูลของ portscan เข้าไปยัง database ได้ในขณะนี้ (snort
current version 1.8p1)
| Home
|| เอกสารเผยแพร่ || IDS
ThaiCERT Disclaimer | Copyright © 2001 ThaiCERT(NECTEC). All rights reserved. |