banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận bảo mật sử dụng OSSEC để theo dõi process  XML
  [Article]   sử dụng OSSEC để theo dõi process 10/06/2014 13:30:40 (+0700) | #1 | 280809
vd_
Member

[Minus]    0    [Plus]
Joined: 06/03/2010 03:05:09
Messages: 124
Offline
[Profile] [PM]
OSSEC (ossec.net) là một hệ thống khá hiệu quả để phát hiện và phòng chống thâm nhập. Tui tóm tắt 1 cách sử dụng hơi khác với cách cài đặt truyền thống như sau:

Case:
- Máy windows có chạy 1 ứng dụng. Mục tiêu là cần phải theo dõi service đó coi có đang chạy hay không.
- Phân tích: ứng dụng chạy thì sẽ phải ghi dữ liệu. Do vậy có thể viết script để theo dõi coi ứng dụng có mở file ra để ghi dữ liệu vào hay không -> cần có:
+ handle.exe trong bộ Sysinternals để in ra các file mà 1 process mở (tương ứng trong Linux là lsof)
+ .cmd (.bat) để chạy handle và lọc in ra thông tin
+ ossec agent chạy tại máy để gửi về ossec server phân tích thông tin và xử lý (gửi mail hoặc active response)

- Cấu hình:
+ File path_to_cmd_file:
c:\sysinternals\handle.exe -p processname filename | find /c "type: File"

Ý nghĩa: đếm số filename do processname mở. Các bạn có thể thêm prefix/suffix để matching trong rule 100002 bên dưới dễ dàng.

+ Ossec agent ossec.conf, phần <ossec_config>, thêm vào bên trong:
<localfile>
<log_format>full_command</log_format>
<command>path_to_cmd_file</command>
<alias>files_check</alias>
<frequency>900</frequency>
</localfile>

Ý nghĩa: ossec agent sẽ chạy path_to_cmd_file, output của path_to_cmd_file sẽ được gửi về OSSEC server phân tích và xử lý. 900 giây sẽ chạy 1 lần. Mỗi lần report kết quả về sẽ có prefix là "ossec: output: 'files_check'"

+ Ossec server rules/local_rules.xml
<rule id="100001" level="1">
<if_sid>530</if_sid>
<match>ossec: output: 'files_check</match>
<description>File event</description>
</rule>
<rule id="100002" level="12" ignore="900">
<if_sid>100001</if_sid>
<regex>output_of_cmd_file</regex>
<description>Description</description>
<options>alert_by_email</options>
</rule>

Ý nghĩa: sau khi agent chạy full_command 'files_check' (rule 100001 sẽ match sau rule 530), nếu kết quả có string 'output_of_cmd_file' thì phát sinh event 100002 và gửi mail

+ Ossec server ossec.conf, bên trong <ossec_config>, thêm:
<email_alerts>
<email_to>emails</email_to>
<rule_id>100002</rule_id>
<do_not_delay/>
<do_not_group/>
</email_alerts>

Ý nghĩa: nếu rule 100002 thì gửi mail ngay lập tức đến emails

Bắt được event 100002 trên Ossec server thì tùy nghi bạn xử lý.

Lưu ý:
+ Phải dùng psexec để chạy handle.exe với quyền system trước khi gắn vào ossec, tại vì sysinternals có màn hình accept end user agreement.
+ Localfile dùng full_command PHẢI ĐƯỢC để trong ossec.conf của agent, không phải ở ossec.conf của server
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|