# ホスト型 IDS Tripwire とネットワーク型 IDS Snort の導入 with CentOS 6

## ホスト型 IDS Tripwire とネットワーク型 IDS Snort の導入 (CentOS 6)

### Tripwire

```
# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# yum install --enablerepo=epel tripwire
# tripwire-setup-keyfiles
```

/etc/tripwire/以下にサイトキーファイル(site.key)や平文のポリシーファイル(twpol.txt)が生成される。

ポリシーファイルの作成

```
# twadmin --create-polfile --site-keyfile /etc/tripwire/site.key /etc/tripwire/twpol.txt
```

データベースの初期化

```
# tripwire --init
```

整合性チェック

```
# tripwire --check
```

/var/lib/tripwire/report/以下にtwrファイルが生成される。

レポートの確認

```
# twprint --print-report --report-level 4 --twrfile /var/lib/tripwire/report/dc56dd103a9c-20180917-103119.twr
```

/etc/tripwire/twcfg.txt には平文のシステム設定ファイルがある。

```
ROOT                   =/usr/sbin
POLFILE                =/etc/tripwire/tw.pol
DBFILE                 =/var/lib/tripwire/$(HOSTNAME).twd
REPORTFILE             =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
SITEKEYFILE            =/etc/tripwire/site.key
LOCALKEYFILE           =/etc/tripwire/$(HOSTNAME)-local.key
EDITOR                 =/bin/vi
LATEPROMPTING          =false
LOOSEDIRECTORYCHECKING =false
MAILNOVIOLATIONS       =true
EMAILREPORTLEVEL       =3
REPORTLEVEL            =3
MAILMETHOD             =SENDMAIL
SYSLOGREPORTING        =false
MAILPROGRAM            =/usr/sbin/sendmail -oi -t
```

### Snort

```
# yum install -y wget
# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
# rpm --import RPM-GPG-KEY-EPEL-6
# vi /etc/yum.repos.d/epel.repo
# yum install -y libnet-devel libdnet-devel --enablerepo=epel
# yum install -y  https://forensics.cert.org/centos/cert/6/x86_64/daq-2.0.6-2.el6.x86_64.rpm
# yum install -y https://forensics.cert.org/centos/cert/6/x86_64/snort-2.9.11.1-2.el6.x86_64.rpm
```

epel.repo

```
[epel]
name=EPEL RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/fedora/epel/6/$basearch/
gpgcheck=1
enabled=0
```

設定ファイル作成

```
# vi /etc/snort/snort-sample.conf 
```

snort-sample.conf

```
alert tcp any any -> any 80 (msg:"web detection test"; content:"DETECTION-TEST";nocase; sid:1000000;)
```

起動

```
# snort -i eth0 -c /etc/snort/snort-sample.conf 
```

## 参考

* Tripwire\
  <https://www.tripwire.com/>
* Snort - Network Intrusion Detection - Prevention System\
  <https://www.snort.org/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hayashier.gitbook.io/article/others/tripwire-snort-get-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
