출처: http://jentalkstoomuch.blogspot.kr/2010/09/writing-custom-ossec-rules-for-your.html
http://ossec-docs.readthedocs.org/en/latest/manual/rules-decoders/create-custom.html
디코더 설정전
# /var/ossec/bin/ossec-logtest
2013/11/01 10:39:07 ossec-testrule: INFO: Reading local decoder file.
2013/11/01 10:39:07 ossec-testrule: INFO: Started (pid: 32109).
ossec-testrule: Type one log per line.
2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1
**Phase 1: Completed pre-decoding.
full event: '2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1'
hostname: 'arrakis'
program_name: 'ossec-exampled'
log: 'test connection from 192.168.1.1 via test-protocol1'
**Phase 2: Completed decoding.
No decoder matched.
디코더 설정후
/var/ossec/etc/decoder.xml
위 파일에 디코더 룰 설정해야 함
<decoder name="ossec-exampled">
<program_name>ossec-exampled</program_name>
</decoder>
2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1
**Phase 1: Completed pre-decoding.
full event: '2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1'
hostname: 'arrakis'
program_name: 'ossec-exampled'
log: 'test connection from 192.168.1.1 via test-protocol1'
**Phase 2: Completed decoding.
decoder: 'ossec-exampled'
디코더 상세 설정 후
<decoder name="ossec-exampled-test-connection">
<parent>ossec-exampled</parent>
<prematch offset="after_parent">^test connection </prematch> <!-- offset="after_parent" makes OSSEC ignore anything matched by the parent decoder and before -->
<regex offset="after_prematch">^from (\S+) via (\S+)$</regex> <!-- offset="after_prematch" makes OSSEC ignore anything matched by the prematch and earlier-->
<order>srcip, protocol</order>
</decoder>
다음과 같이 수정 후 로그를 보면.. 다음과 같다.
# /var/ossec/bin/ossec-logtest
2013/11/01 11:03:25 ossec-testrule: INFO: Reading local decoder file.
2013/11/01 11:03:25 ossec-testrule: INFO: Started (pid: 6290).
ossec-testrule: Type one log per line.
2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1
**Phase 1: Completed pre-decoding.
full event: '2013-11-01T10:01:04.600374-04:00 arrakis ossec-exampled[9123]: test connection from 192.168.1.1 via test-protocol1'
hostname: 'arrakis'
program_name: 'ossec-exampled'
log: 'test connection from 192.168.1.1 via test-protocol1'
**Phase 2: Completed decoding.
decoder: 'ossec-exampled'
srcip: '192.168.1.1'
proto: 'test-protocol1'
'프로젝트 관련 조사 > 시스템 구축' 카테고리의 다른 글
[ubuntu] rpm 패키지 파일을 우분투에서 설치하는 방법 (0) | 2016.09.08 |
---|---|
[vmware] 64bit 시작 오류 (0) | 2015.12.23 |
[OSSEC] JSON output으로 syslog 던지기 (0) | 2015.12.09 |
[OSSEC] OSSEC DB 구조 (0) | 2015.12.04 |
[리눅스]자주 사용하는 유닉스(리눅스) 명령어 (0) | 2015.11.28 |