Thursday, March 28, 2013

Ubuntu 12.04 LTS 64bit + Apache2 + Mod Security

Copy from: http://www.jangestre.com/2012/04/ubuntu-1204-lts-64bit-apache2-mod.html
download the latest stable release from http://www.modsecurity.org/download/direct.html; it's version 2.5.12 as of this writing. In order to compile ModSecurity, install the following:
$ sudo apt-get install automake g++ apache2-threaded-dev dpkg-dev libxml2 libxml2-dev
Once done, proceed compiling ModSecurity.
$ cd /apache2 $ ./configure $ make $ sudo make install
Next would be to create the configuration file so that Apache will be able to use the ModSecurity module. Create the /etc/apache2/mods-available/mod_security.load, mod_security.conf file, and insert the following: mod_security.load
LoadFile /usr/lib/x86_64-linux-gnu/libxml2.so.2 LoadModule security2_module /usr/lib/apache2/modules/mod_security2.so
mod_security.conf
error_mod_security_is_not_loaded Include /etc/apache2/modsecurity_crs/*.conf
Afterwards, create the /etc/apache2/modsecurity_crs directory, and copy all core rule sets to the newly created directory.
$ sudo mkdir /etc/apache2/modsecurity_crs $ sudo cp -R modsecurity-apache_2.5.12/rules/*.conf /etc/apache2/modsecurity_crs/ $ sudo cp -R modsecurity-apache_2.5.12/rules/base_rules/* /etc/apache2/modsecurity_crs/
It's now time to enable the new ModSecurity module, restart Apache enables it.
$ sudo a2enmod mod_security My additional $ sudo a2enmod unique_id $ sudo service apache2 restart
Don't forget to check ModSecurity if it's really working. Create /var/www/testsecurity.php file with the following content:
< ?php $secret_file = $_GET['secret_file']; include ( $secret_file); ? >
Open your favorite browser and type http://localhost/testsecurity.php?secret_file=/etc/passwd , you should see the following: Forbidden You don't have permission to access /testsecurity.php on this server. Otherwise, the content of /etc/passwd file will be displayed which means that ModSecurity is not working.

Monday, January 21, 2013

Exchange 2010 Log โตเร็วผิดปกติ

ปัญหานี้เกิดหลังจากการ Backup Exchange agent ของ BackupExec ไม่สมบูรณ์ หรือเกิดปัญหาทำให้ต้อง Cancel ไป หลังจากนั้นจะสังเกตุ Transaction Log ของ Exchange จะโตเร็วกว่าปกติมาก
ถ้าปล่อยไว้อย่างนี้อาจจะเป็นภัยในอนาคตเป็นแน่ จึงพยายามหาสาเหตุที่เกิดปัญหา เพื่อจะได้แก้ไขเป็นเวลา 2 วันจนได้มาพบกับ Blog ของ Hermannmaurer ไม่อยากจะเชื่อว่ามันเป็นเพราะ Bug ของ Exchange ActiveSync Protocol นี้เอง มันสร้าง Log ขึ้นมาได้มหาศาลเลยที่เดียว เพื่อจะหาว่า Mobile device ของ User ท่านใดทำให้เกิดปัญหานี้ เราต้องใช้ Tools 2 ตัวด้วยกันคือ จากนั้นก็ Copy IIS log จากเครื่อง Exchange CAS role มาเครื่องที่ run LPS แล้วเปิด Log นี้ด้วย LPS Query "ActiveSync Report [Top 20]" ดูภาพตัวอย่างได้จาก Blog ของ Hermannmaurer ดูจะพบว่าคนแรกมีจำนวน Hits และ Ping สูงมาก ให้จัดการกับ Device ที่ต่อกับ account นั้นครับ เท่านี้ชีวิตก็เป็นสุขแล้ว