Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

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, August 18, 2009

Debian 5 Post installations

Debian 5 Post installations

หลังจากที่ลง Debian แบบไม่เลือก Package อะไรเลย ก็จะไม่มี Service อะไรมาให้เราใช้เลย แม้กระทั่ง OpenSSH ซึ่งจะทำให้เราไม่สามารถทำ remote จากเครื่อง Client เข้ามาได้ และ Feature อำนวยความสะดวกหลาย ๆ อย่างก็ยังไม่ได้ลงไว้ให้ อีกทั้ง ยังไม่ได้มีการ update package ให้ทันสมัยและปลอดภัย ดังนั้น จึงมีขี้นตอนการทำ post installation เกิดขึ้น เพื่อมาจัดการเรื่องเหล่านี้

1. แก้ไขไฟล์ /etc/apt/sources.list

• Comment ในส่วนที่ให้เรียกจาก CD-Rom
#deb cdrom:[Debian GNU/Linux testing _Lenny_ …

• เพิ่ม Reposition เข้าไปเพื่อให้ระบบไปดึง package จาก repo เหล่านี้

deb http://http.us.debian.org/debian lenny main contrib non-free
deb-src http://http.us.debian.org/debian lenny main conrib non-free

2. Update Debian โดยใช้คำสั่ง aptitude update

3. Upgrade Debian โดยใช้คำสั่ง aptitude upgrade

4. สร้าง user ใหม่ เพื่อรองรับกับการใช้งาน SSH (ต้อง remort ด้วย user เท่านั้น เพราะตั้งให้ remote ด้วย root ไม่ได้แล้ว)

• ใช้คำสั่ง adduser username เพื่อสร้าง user ขึ้นมา

• ใช้คำสั่ง passwd username เพื่อกำหนดรหัสผ่านให้กับ user คนนั้น ๆ

5. ติดตั้ง OpenSSH เพื่อทำให้เราสามารถ remote ได้ โดยการใช้คำสั่ง
aptitude install openssh-server

6. หลังจากที่ติดตั้ง openssh แล้ว เราต้องเพิ่มความปลอดภัย เพื่อไม่ให้สามารถ login ด้วย root จาก client ได้ จะต้อง login ด้วย client account เท่านั้น โดยการเข้าไปแก้ไข configuration file ของ openssh ดังนี้

• แก้ไขไฟล์ /etc/ssh/sshd_config เปลี่ยน option บรรทัดที่เขียน ว่า PermitRootLogin ให้เป็น no

• Restart openssh โดยพิมพ์ว่า /etc/init.d/ssh restart

7. ตั้ง timeout ให้กับเครื่อง โดยให้มีค่า Timeout 15 นาที โดยเข้าไปแก้ไขดังนี้

• แก้ไขไฟล์ /etc/profile เพิ่มคำว่า TMOUT=900 ต่อท้ายไฟล์

• แก้ไขไฟล์ /etc/bash.bashrc เพิ่มคำว่า TMOUT=900 ต่อท้ายไฟล์

8. Update time ให้ตรงกับเวลาของ Server ทุก ๆ ตัว โดยการอ้างไปยัง time.beenets.com

• ติดตั้ง ntp client เพื่อทำให้เราสามารถ Update time ได้ โดยการใช้คำสั่ง
aptitude install ntpdate

• สร้าง Script file ขึ้นมา เพื่อให้สามารถ run คำสั่ง ntpdate ได้ โดยใช้คำสั่ง
vi /etc/timeupdate.sh

• หลังจากสร้างไฟล์ขึ้นมาแล้ว ให้พิมพ์ชุดคำสั่งดังนี้

#!/bin/bash
ntpdate time.beenets.com

• จากนั้น ให้ Save File และออกมาจาก vi

• เปลี่ยน permission ของไฟล์ให้สามารถรันได้จาก root เท่านั้น โดยใช้คำสั่ง
chmod 700 /etc/timeupdate.sh

• ทดสอบ script ที่เราเขียนไว้ โดยการใช้คำสั่ง /etc/timeupdate.sh หากไม่ผิดพลาด จะเป็นการ Update time ของเครื่อง

• ไปแก้ไขไฟล์ /etc/crontab เพื่อทำการตั้งเวลาให้ Script ทำงาน โดยการ พิมพ์คำสั่งต่อท้าย
1 * * * * root /etc/timeupdate.sh

• จะมีการรันคำสั่งที่เราสร้างไว้ทุก ๆนาทีแรกของทุกชั่วโมง แสดงว่า จะมีการ Update time ทุก ๆ ชั่วโมงนั่นเอง

9. ตั้ง Timezone ให้เป็นเวลาของประเทศไทย โดยการเข้าไปแก้ไขไฟล์ /root/.profile แล้วเพิ่มคำสั่ง TZ='Asia/Bangkok'; export TZ ต่อท้าย

10. ปรับสีของ vi ให้แสดงผลเป็นสี เวลาที่เราทำการแก้ไขไฟล์

• ติดตั้ง option เสริม เพื่อทำให้เราสามารถใช้สีได้ โดยการใช้คำสั่ง
aptitude install vim vim-runtime

• สร้างไฟล์ที่ชื่อ .vimrc ที่ root โดยพิมพ์ว่า vi /root/.vimrc และพิมพ์คำสั่งข้างในว่า : syntax on จากนั้น Save file และออกจาก vi

11. ปรับ option ของการแสดงผลบนหน้าจอ และการใช้คำสั่งลัด โดยการเข้าไปแก้ไขไฟล์ /root/.bashrc โดยเอา Comment หน้าบรรทัดออกไป ดังนี้

# You may uncomment the following lines if you want `ls' to be colorized:

export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

# Some more alias to avoid making mistakes:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'


alias vi=vim --> บรรทัดนี้ เพิ่มเข้าไปใหม่


หลังจากที่เราได้ทำตามขั้นตอนเหล่านี้เรียบร้อยแล้ว เราก็จะสามารถที่จะใช้งาน Linux ได้อย่างราบรื่นมากขึ้นกว่าเดิม และจากการปรับแต่งที่กล่าวมานั้น เป็นการปรับแต่งสภาวะแวดล้อมของเครื่อง ให้สามารถใช้งานได้ โดยมีการอำนวยความสะดวกในการใช้งาน แต่ในด้านของความปลอดภัย จะต้องมีการปรับแต่งเพิ่มอีกมาก