Download - SBC 2012 - Linux Hardening (Mẫn Thắng)
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
1
2
Trình bày: Mẫn Thắ[email protected] | manthang.wordpress.com
Kiện toàn cho Linux OS
1
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
2
2
Nội dung
I. Kiện toàn cho HĐH Linux
II. Vài công cụ tăng cường bảo mật cho Linux
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
3
2
I. Kiện toàn cho Linux
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
4
2
1. Bảo vệ Boot loader
# grub-crypt //SHA-512 by default
Password: GrbPwd4SysAd$
Retype password: GrbPwd4SysAd$
^9^32kwzzX./3WISQ0C
$ cat /etc/grub.conf
..
password --encrypted ^9^32kwzzX./3WISQ0C
..
* Ví dụ trên áp dụng cho GRUB 1, tham khảo thêm cho version 2 http://www.howtogeek.com/102009/how-to-password-protect-
ubuntus-boot-loader/
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
5
2
2. Gia cố TCP/IP Stack (1)
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
6
2
2. Gia cố TCP/IP Stack (2)
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
7
2
3. File & File system (1) Gỡ bỏ SUID, GUID của các file không cần thiết được gán các
bit này
#Tìm các SUID file
find / -perm +4000
# Tìm các GUID file
find / -perm +2000
# Kết hợp tìm cả 2
find / \( -perm -4000 -o -perm -2000 \) -print
find / -path -prune -o -type f -perm +6000 -ls
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
8
2
3. File & File system (2) Phân tách giữa các file của OS và của user. Mount các
directory sau vào partition riêng:
/usr, /home, /var, /var/tmp, /tmp Đặt root directory của Apache, FTP ở các partition riêng và
chỉnh file /etc/fstab với các option:
noexec, nodev, nosuid Ví dụ:
/dev/sda5 /ftpdata ext3 defaults,nosuid,nodev,noexec 1 2 Thiết lập disk quotas trên file system
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
9
2
4. User account (1) Tìm các account không có password và lock lại nếu cần
# awk -F: '($2 == "") {print}' /etc/shadow
# passwd -l accountName Đảm bảo các non-root account có UID khác 0
# awk -F: '($3 == "0") {print}' /etc/passwd Sử dụng lệnh sudo thay cho login với root account Mỗi service chạy dưới quyền của một account riêng, ví dụ:
apache, mysql, ntp... Lock account nếu failure login nhiều lần với faillog
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
10
2
4. User account (2) Password aging# chage -l userName
# chage -M 60 -m 7 -W 7 userName
# vi /etc/login.defs
PASS_MAX_DAYS 30
PASS_MIN_DAYS 1
PASS_WARN_AGE 7
Buộc dùng “strong password”# apt-get install libpam-cracklib//Debian-based distro
# vi /etc/pam.d/system-auth
# password required pam_cracklib.so retry=2 minlen=8 difok=7 dcredit=6 ucredit=5 lcredit=4 ocredit=3
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
11
2
4. User account (3)// fork() bomb code
:(){ :|:& };: $ cat /etc/security/limits.conf
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
12
2
5. Một vài biện pháp khác Dùng các secure protocol: SSH, SCP, rsync, FTPS,
OpenVPN,.. Mã hóa data/channel với TrueCrypt, GnuPG, IPsec,
SSL/TLS,... Loại bỏ các service/port không cần thiết Cập nhật kernel, software Giam/cách ly các program trong môi trường riêng với chroot ...
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
13
2
II. Vài công cụ tăng cường bảo mật cho Linux
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
14
2
1. Sudo Nguy cơ 1?$ sudo su -
$ sudo passwd root
Nguy cơ 2?
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
15
2
2. inetd vs. xinetd (1) inetd giải quyết 2 vấn đề: hạn chế về RAM, CPU và kiểm soát
chặt chẽ hơn việc truy cập từ các host ở ngoài tới service.
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
16
2
2. inetd vs. xinetd (2)
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
17
2
2. inetd vs. xinetd (3) xinetd bổ sung tính năng logging (syslog/file) , access control
(vd, access_time), chống DoS (max_load, per_source)
$ cat /etc/xinetd.d/imap
→ single of failure!!
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
18
2
1. TCP_Wrappers (1) Tăng cường access control cho inetd, xinetd, nhiều service
khác.
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
19
2
1. TCP_Wrappers (2) Cấu hình đơn giản
SECURITY BOOTCAMP 2012 | Make yourself to be an expert!
20
2Cảm ơn các anh chị đã theo dõi!
Q&A