Friday, June 25, 2010

Install Nessus server in Debian - part 2

หลังจากที่เราสร้าง Nessus server ด้วย nessus เวอร์ชั่นใหม่ ๆ ไปแล้ว เรามาลองใช้เวอร์ชั่นเก่า ๆ ดูบ้างไหม




สำหรับคนที่ติดกับการใช้ nessus client เหมือนผม คงจะยอมรับไม่ได้แน่ ๆ หากจะต้องไปทำงานผ่าน web browser เนื่องจากข้อดีของการใช้ nessus client ที่ผมนึกออกคือ

1. สามารถ export report ของ nessus ออกมาในรูปแบบของ .nessus file เพื่อเก็บไว้ และสามารถ import เข้าไปเพื่อดูผ่านโปรแกรม nessus client ได้


2. สามารถเลือกรูปแบบการออก report ได้ ว่า จะให้ report ออกมาในรูปแบบไหน



ในเวอร์ชั่นใหม่ หากเราจะทำให้ได้แบบนี้ คงต้องเสียเงินซื้อ License1 แบบ professional feed ล่ะครับ

เมื่อเราเห็นข้อดีเหล่านี้แล้ว ลองมาติดตั้งกันดูเลยครับ โดยจะมีขั้นตอนการติดตั้ง nessus ดังนี้

Login ด้วยสิทธิ์ของ root หรือจะใช้ sudo ก็ได้

ไป download เวอร์ชั่นของ nessus ที่เป็นเวอร์ชั่นต่ำกว่า 4.0.2 (ของผมใช้เวอร์ชั่น 4.0.1)

เริ่ม ติดตั้ง โดยใช้คำสั่ง dpkg -i Nessus-4.0.1-debian5_i386.deb

หลังจากติดตั้งเรียบร้อย ก็เปิดใช้งาน โดยใช้คำสั่ง /etc/init.d/nessusd start

ไปขอรหัสลงทะเบียนใช้งาน nessus ที่ http://www.nessus.org/plugins/index.php?view=register
เมื่อ เข้าไประบบจะให้กรอก e-mail แล้วทาง nessus จะส่ง e-mail รหัสในการลงทะเบียนมาให้

เมื่อได้รหัสมาแล้ว ซึ่งรหัสจะเป็นชุดตัวอักษรผสมตัวเลข อยู่ 5 ชุด ให้เรา พิมพ์คำสั่งนี้ลงไป

/opt/nessus/bin/nessus-fetch --register xxxx-xxxx-xxxx-xxxx-xxxx

ระบบจะขึ้นข้อความว่า

Your activation code has been registered properly - thank you.
Now fetching the newest plugin set from plugins.nessus.org...
Your Nessus installation is now up-to-date.
If auto_update is set to 'yes' in nessusd.conf, Nessus will
update the plugins by itself.


ซึ่งเมื่อเราเข้าไปดูที่ /opt/nessus/etc/nessus/nessusd.conf จะเห็นว่า auto_update เป็น yes อยู่แล้ว แสดงว่าระบบจะ Update ให้เราอัตโนมัติอยู่แล้ว ไม่ต้องไปแก้ไขอะไร

เพื่อเป็นการป้องกันไม่ ให้ใครเข้ามาใช้ Nessus นี้ เราต้องระบุ user ที่เข้าใช้งาน โดยใช้คำสั่ง

/opt/nessus/sbin/nessus-adduser

Login : user1
Login password : ********
Login password (again) : ********
Do you want this user to be a Nessus 'admin' user ? (can upload plugins, etc...) (y/n) [n]: กด n

User rules
----------
nessusd has a rules system which allows you to restrict the hosts
that user1 has the right to test. For instance, you may want
him to be able to scan his own host only.
Please see the nessus-adduser manual for the rules syntax
Enter the rules for this user, and enter a BLANK LINE once you are done :
(the user can have an empty rules set)
กด Enter

Login : user1
Password : ***********
Rules :

Is that ok ? (y/n) [y] กด y
User added

จากนั้นให้เรา Update Plugins ล่าสุด โดยใช้คำสั่ง

/opt/nessus/sbin/nessusd -R

รอจนกระทั่ง Update เรียบร้อย ให้ restart เครื่อง

หลังจาก restart แล้ว ให้เริ่มใช้งานโดยใช้คำสั่ง

/etc/init.d/nessusd start


วิธี ตรวจสอบว่า service ยังทำงานอยู่หรือเปล่า ให้เราใช้คำสั่ง netstat -anp | grep nessus

จะขึ้น รายละเอียดมาประมาณนี้

scan:~# netstat -anp | grep nessus
tcp 0 0 0.0.0.0:1241 0.0.0.0:* LISTEN 2333/nessusd
tcp6 0 0 :::1241 :::* LISTEN 2333/nessusd
unix 2 [ ACC ] STREAM LISTENING 5573 2333/nessusd /opt/nessus//var/nessus/nessusd.sock

เท่านี้ ก็สามารถใช้งานได้แล้วครับ

PS สำหรับใครที่อ่านบทความนี้แล้ว อยากลองทำดูบ้าง แต่ไปหา Download version ของ nessus 4.0.1 ไม่ได้ ส่งเมล์มาหาผมเลย จะจัดส่งให้ครับ

ที่มา : www.nessus.org

Monday, June 21, 2010

Google รองรับการค้นหาแบบเข้ารหัสแล้ว




Google ได้เพิ่มความสามารถในการ search ให้มีความปลอดภัยมากขึ้น โดยใช้การเข้ารหัสแบบ SSL ในการค้นหาข้อมูลผ่าน google ซึ่งปัจจุบัน ยังอยู่ในช่วงทดลองให้เข้าใช้งาน โดยผู้ที่ต้องการใช้งานการค้นหาข้อมูลแบบเข้ารหัสนี้ สามารถเข้าไปใช้งานได้ที่ https://www.google.com/

การค้นหาข้อมูลแบบเข้ารหัสดีอย่างไร

เมื่อมองจากมุมมองในเรื่องของ Privacy เราคงไม่อยากให้บุคคลอื่น ๆ มารับรู้ว่า เราเข้าไปค้นหาข้อมูลที่เวบไหนบ้าง หรือใช้ keyword อะไรในการค้นหาข้อมูล แล้วได้ผลลัพธ์อะไรออกมา ซึ่งหากไม่มีการเข้ารหัสข้อมูล ก็สามารถที่จะตรวจจับได้ โดยผ่านทาง Sniffer program แต่ถ้ามีการเข้ารหัสแล้ว Sniffer program ก็ไม่สามารถที่จะมองเห็นสิ่งที่เราค้นหาได้นั่นเอง ซึ่งทำให้เราสามารถใช้งานได้อย่างปลอดภัยและมีความเป็นส่วนตัวมากขึ้น

Wednesday, June 16, 2010

Install Nessus server in Debian

หลังจากที่เราสร้าง Linux Server เปล่า ๆ ขึ้นมาแล้ว ถ้าจะทำให้เป็น vulnerability scanning server
Application แรก ๆ ที่เรานึกถึง คือ Nessus

ซึ่งเราจะมีขั้นตอนการติดตั้ง nessus ดังนี้

Login ด้วยสิทธิ์ของ root หรือจะใช้ sudo ก็ได้

ไป download version ล่าสุดของ nessus ที่ http://www.nessus.org/download/nessus_download.php
เริ่มติดตั้ง โดยใช้คำสั่ง dpkg -i Nessus-4.2.2-debian5_i386.deb

หลังจากติดตั้งเรียบร้อยก็เปิดใช้งาน โดยใช้คำสั่ง /etc/init.d/nessusd start

ไปขอรหัสลงทะเบียนใช้งาน nessus ที่ http://www.nessus.org/plugins/index.php?view=register
เมื่อเข้าไประบบจะให้กรอก e-mail แล้วทาง nessus จะส่ง e-mail รหัสในการลงทะเบียนมาให้

เมื่อได้รหัสมาแล้ว ซึ่งรหัสจะเป็นชุดตัวอักษรผสมตัวเลข อยู่ 5 ชุด ให้เรา พิมพ์คำสั่งนี้ลงไป

/opt/nessus/bin/nessus-fetch --register xxxx-xxxx-xxxx-xxxx-xxxx

ระบบจะขึ้นข้อความว่า

Your activation code has been registered properly - thank you.
Now fetching the newest plugin set from plugins.nessus.org...
Your Nessus installation is now up-to-date.
If auto_update is set to 'yes' in nessusd.conf, Nessus will
update the plugins by itself.


ซึ่งเมื่อเราเข้าไปดูที่ /opt/nessus/etc/nessus/nessusd.conf จะเห็นว่า auto_update เป็น yes อยู่แล้ว แสดงว่าระบบจะ Update ให้เราอัตโนมัติอยู่แล้ว ไม่ต้องไปแก้ไขอะไร

เพื่อเป็นการป้องกันไม่ให้ใครเข้ามาใช้ Nessus นี้ เราต้องระบุ user ที่เข้าใช้งาน โดยใช้คำสั่ง

/opt/nessus/sbin/nessus-adduser

Login : user1
Login password : ********
Login password (again) : ********
Do you want this user to be a Nessus 'admin' user ? (can upload plugins, etc...) (y/n) [n]: กด n

User rules
----------
nessusd has a rules system which allows you to restrict the hosts
that user1 has the right to test. For instance, you may want
him to be able to scan his own host only.
Please see the nessus-adduser manual for the rules syntax
Enter the rules for this user, and enter a BLANK LINE once you are done :
(the user can have an empty rules set)

กด Enter

Login : user1
Password : ***********
Rules :

Is that ok ? (y/n) [y] กด y
User added
วิธีตรวจสอบว่า service ยังทำงานอยู่หรือเปล่า ให้เราใช้คำสั่ง ps –ef | grep nessus

จะขึ้นรายละเอียดมาประมาณนี้

scan:~# ps -ef | grep nessus
root 17133 1 0 12:37 ? 00:00:00 /opt/nessus/sbin/nessus-service -D -q
root 17134 17133 78 12:37 pts/1 00:08:33 nessusd -q
root 17163 17046 0 12:48 pts/1 00:00:00 grep nessus


Edit : เนื่องจาก Nessus Server เวอร์ชั่น 4.2.2 ที่เป็น license แบบ Homefeed ไม่ support การใช้งาน Nessus client ที่ port TCP/1241 อีกต่อไป ดังนั้น การเข้าใช้งาน จึงต้องเข้าผ่านทาง Web browser เท่านั้น โดยเข้าไปที่ https://Servername or Server IP:8834


ที่มา : www.nessus.org

Tuesday, June 15, 2010

vSphere Client error เข้าใช้งานไม่ได้

วันนี้บังเอิญมีเรื่องที่จะต้องเข้าไป Add host ใน VMware แต่พอ Login แล้ว ปรากฏว่า หน้าจอของ VSphere client กลับขึ้นข้อความว่า

Error parsing the server “xx.xx.xx.xx” “clients.xml” files.

สงสัยว่า จะต้องมีอะไรซักอย่างผิดพลาดแน่ ๆ เลยกดปุ่ม OK ปรากฏว่า ขึ้นมาอีกข้อความนึงว่า


The type initializer for VirtualInfrastructure.Utils.HttpWebRequestProxy' threw an exception.




ซึ่งทำให้ไม่สามารถเข้าไปใช้งาน VMware ไม่ได้

จึงลองเข้าไปดูใน Knowledgebase ของ vmware พบว่า เกิดจาก patch ของ Microsoft นั่นเอง


.NET Framework (980773), released on June 9th 2010.
(http://support.microsoft.com/kb/980773)


ซึ่งทาง vmware เสนอแนวทางแก้ไขสำหรับเรื่องนี้มาสองทางคือ

1. ไป Download vSphere Client เวอร์ชั่นใหม่มาจาก vmware เลย

a. สำหรับ ESXi หรือคนที่ใช้ของฟรี ให้ไปที่

http://downloads.vmware.com/d/info/datacenter_downloads/vmware_esxi/4

b. สำหรับ ESX หรือคนที่ใช้ของเสียตัง ให้ไปที่

http://downloads.vmware.com/d/info/datacenter_downloads/vmware_vsphere_4/4

หรือ

2. ไปลบ patch 980773 ของ Microsoft

ก็จะสามารถใช้งานได้เหมือนเดิม

ซึ่งทาง vmware ยังบอกอีกด้วยนะว่า error นี้ จะมีผลกระทบกับระบบปฏิบัติการดังต่อไปนี้

Windows XP
Windows 2003
Windows 2008
Windows Vista
Windows 7


และถ้าเวอร์ชั่นของ vSphere Client คือ 208111 หรือสูงกว่านั้น หมายความว่า จะเป็น vSphere Client เวอร์ชั่น Update 1 ก็จะไม่เกิดปัญหานี้ขึ้นเช่นกัน


ขั้นตอนการติดตั้งหลังจาก Download ตัว client มาแล้ว

1. รันโปรแกรมที่เพิ่ง Download มา จะขึ้นหน้าจอนี้


2.


3.


4.


5.


6.


7.


8.


9.เข้าใช้งานได้เลย


วิธีการตรวจสอบเวอร์ชั่นของ vSphere Client

1. Log in เข้าไปที่ vSphere Client.
2. Click Help > About.


จะขึ้นมาหน้าจอแบบนี้



ที่มา : http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022611

การต่อคำสั่งสองคำสั่งเข้าด้วยกัน

ในการต่อคำสั่งสองคำสั่งเข้าด้วยกัน โดยให้ทำงานต่อกันไปเลย เราใช้ ; เป็นตัวคั่นระหว่างคำสั่งแรกกับคำสั่งที่สอง

จากตัวอย่างเป็นการประยุกต์ใช้งาน


cd /var/log; tail -f daemon.log user.log auth.log debug kern.log syslog dmesg messages


เริ่มด้วยคำสั่งแรก คือ cd /var/log เพื่อที่จะเข้าไปที่ folder /var/log

จากนั้นตามด้วยคำสั่ง tail -f daemon.log user.log auth.log debug kern.log syslog dmesg messages เื่พื่อที่จะเรียกดูท้ายไฟล์ ของ

daemon.log
user.log
auth.log
debug
kern.log
syslog
dmesg
messages

และให้แสดง Update ด้วยกรณีที่มีการเขียนข้อความใหม่ ๆ ลงบนไฟล์เหล่านี้

Monday, June 7, 2010

Logging normal Text file with rsyslog

สำหรับมือใหม่ทางด้าน Linux และ syslog จะมีคำถามว่า
ทำอย่างไร ถึงจะเก็บ Log ที่ไม่ใช่ standard log file (ตัวอย่างของ Standard log file เช่น message/ auth/ cron เป็นต้น)
เช่น เราอาจจะมีการเขียน Script ตัวนึงเพื่อใช้เก็บข้อมูล โดยให้ script นั้นเขียนไฟล์ต่อท้ายไปเรื่อย ๆ แล้วอยากจะให้เก็บ log ด้วย syslog เพื่อจะไปทำอะไรต่อก็แล้วแต่
ด้วยความสามารถของ rsyslog ทำให้เราสามารถ log text file ธรรมดาได้ โดยการโหลด module ที่ชื่อว่า imfile แล้ว config ค่าบางอย่างเพิ่มเติม ดังตัวอย่างด้านล่าง

ให้เพิ่มค่า config ด้านล่างลงไปใน rsyslog.conf



$ModLoad imfile # needs to be done just once
# File 1
$InputFileName /path/to/file1 #ฟูลพาทที่ไฟล์นั้นอยู่รวมชื่อไฟล์ด้วย
$InputFileTag tag1: # อยากให้ logfile เห็นว่ามาจากไหน ก็ใส่ชื่อลงไป
$InputFileStateFile stat-file1
$InputFileSeverity notice
$InputFileFacility local0
$InputRunFileMonitor
$InputFilePollingInterval 10 # เข้าไปตรวจสอบไฟล์ทุก ๆ 10 นาที
# File 2
$InputFileName /path/to/file2
$InputFileTag tag2:
$InputFileStateFile stat-file1
$InputFileSeverity notice
$InputFileFacility local0
$InputRunFileMonitor
$InputFilePollingInterval 10

ถ้ามีหลาย ๆ ไฟล์ ก็ต่อท้ายลงมาเรื่อย ๆ


หมายเหตุ :
1. module นี้ สามารถ monitor text file ได้แค่ 100 files เท่านั้น ถ้าจะให้ได้มากกว่านี้ ต้องเข้าไปแก้ parameter MAX_INPUT FILES ใน imfile.c
2. ใน syslog-ng ก็ทำแบบนี้ได้เหมือนกัน แต่ไม่รู้ว่า config จะเหมือนอย่างนี้หรือเปล่า ที่ทำผ่าน rsyslog เนื่องจากว่า rsyslog จะติดมากับ OS อยู่แล้ว จึงใช้ rsyslog ไปเลย ง่ายดี
3. แก้ไขค่า config เสร็จแล้ว อย่างลืม restart rsyslog ด้วย ไม่งั้นก็ยังไม่ทำงานนะ

ที่มา : http://www.rsyslog.com/doc-imfile.html