Linux-centos

리눅스 (centos) 취약점 점검

말하는감자 2021. 2. 26. 12:13

계정 관리

U-1 root 계정 원격 접속 제한

vim /etc/pam.d/login
auth    required    /lib/security/pam_securetty.so

test
cat /etc/securetty | grep pts*
pts* 관련 설정이 있다면 제거

U-2 패스워드 복잡성 설정

1. 사용 최대 기간, 변경 최소 기간, 최소 길이, 변경 만료 알림 설정
vim /etc/login.defs

PASS_MAX_DAYS   60
PASS_MIN_DAYS   7
PASS_MIN_LEN    10
PASS_WARN_AGE   10

test
cat /etc/login.defs | grep PASS_


2. 대문자, 소문자, 숫자 기호 설정
vim /etc/security/pwquality.conf

minlen = 10
minclass = 3
maxrepeat = 3
maxclassrepeat = 0
lcredit = 1
ucredit = 0
dcredit = 1
ocredit = 0

test
tail /etc/security/pwquality.conf


3. 패스워드 5회 이상 틀렸을 시 차단
vim /etc/pam.d/system-auth
password    requisite    pam_cracklib.so try_first_pass retry=5

test
cat /etc/pam.d/system-auth | grep 'pam_cracklib.so try_first_pass'

4. 과거 사용한 패스워드 재사용 금지
vim /etc/pam.d/system-auth
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=x

test
cat /etc/pam.d/system-auth | grep 'pam_unix.so sha512'

U-3 계정 잠금 임계값 설정

vim /etc/pam.d/system-auth
auth    required    /lib/security/pam_tally.so deny=5 unlock_time=120 no_magic_root
account    required    /lib/security/pam_tally.so no_magic_root reset

test
cat /etc/pam.d/system-auth | grep '/lib/security/pam_tally'

U-4 패스워드 파일 보호

find . -name shadow
./shadow

tail /etc/passwd
두번째 필드가 x로 되어있는지 확인

pwconv 활성화

파일 및 디렉토리 관리

U-5 root 홈, 패스 디렉터리 권한 및 패스 설정

echo $PATH

U-6 파일 및 디렉터리 소유자 설정

find / -nouser -o -nogroup 2> /dev/null
find / -nouser -print
find / -nogroup -print
검색 결과에서 불필요한 파일 삭제

U-7 /etc/passwd 파일 소유자 및 권한 설정

chmod 644 /etc/passwd
chown root:root /etc/passwd
ls -l /etc/passwd

U-8 /etc/shadow 파일 소유자 및 권한 설정

chmod 400 /etc/shadow
chown root:root /etc/shadow
ls -l /etc/shadow

U-9 /etc/hosts 파일 소유자 및 권한 설정

chmod 600 /etc/hosts
ls -l /etc/hosts

U-10 /etc/(x)inetd.conf 파일 소유자 및 권한 설정

chmod 700 /etc/xinetd.d
chmod 600 /etc/xinetd.conf

U-11 /etc/syslog.conf 파일 소유자 및 권한 설정

chmod 644 /etc/syslog.conf
ls -l /etc/syslog.conf

U-12 /etc/services 파일 소유자 및 권한 설정

chmod 644 /etc/services
ls -l /etc/services

U-13 SUID, SGID, Sticky bit 설정 파일 점검

find / -user root -type f \( -perm -04000 -o -perm -02000 \) -xdev -exec ls -al {} \;

/sbin/dump
/usr/bin/lpq-lpd
/usr/bin/newgrp
/sbin/restore
/usr/bin/lpr
/usr/sbin/lpc
/sbin/unix_chkpwd
/usr/bin/lpr-lpd
/usr/sbin/lpc-lpd
/usr/bin/at
/usr/bin/lprm
/usr/sbin/traceroute
/usr/bin/lpq
/usr/bin/lprm-lpd

목록의 파일이 확인되면 SUID 제거
chmod -s

U-14 사용자, 시스템 시작 파일 및 환경파일 소유자 및 권한 설정

chown root:root .bash_profile
chown root:root .bashrc
chown root:root /etc/bashrc
chown root:root /etc/profile
chmod 644 .bash_profile
chmod 644 .bashrc
chmod 644 /etc/bashrc
chmod 644 /etc/profile
ll -a .bash_profile .bashrc /etc/bashrc /etc/profile
소유자, 소유그룹이 root이며 기타 사용자는 읽기만 가능하도록 설정

U-15 world writable 파일 점검

find / ! \( -path '/proc*' -o -path '/sys/fs*' -o -path '/usr/local*' -prune \) -perm -2 -type f -exec ls -al {} \;
기타 사용자의 write 기능을 제거하거나 파일을 삭제

U-16 /dev에 존재하지 않는 device 파일 점검

find /dev -type f -exec ls -l {} \;
major, minor, number를 가지지 않는 device 파일 제거

U-17 $HOME/.rhosts, hosts.equiv 사용 금지

touch /etc/hosts.equiv
chown root /etc/hosts.equiv
chmod 600 /etc/hosts.equiv
touch $HOME/.rhosts
chown root $HOME/.rhosts
chmod 600 $HOME/.rhosts
vim /etc/hosts.equiv, $HOME/.rhosts에서 +를 제거하고 허용 호스트 및 계정 등록

U-18 접속 IP 및 포트 제한

.

서비스 관리

U-19 Finger 서비스 비활성화

cd /etc/xinetd.d
finger 파일이 있는지 확인
파일이 있다면 disable = no로 변경

U-20 Annonymout FTP 비활성화

cat /etc/passwd | grep "ftp"
ftp 계정 있다면 서비스 접속 제한 설정 추가
userdel ftp

U-21 r 계열 서비스 비활성화

ls -alL /etc/xinetd.d/* | egrep "rsh|rlogin|rexec" | egrep -v "grep|klogin|kshell|kexec"
find / -name rlogin
find / -name rsh
find / -name rexec

U-22 cron 파일 소유자 및 권한 설정

find / -name 'cron.*'
rm -f /etc/cron.allow
rm -f /etc/cron.deny

root 외에 다른 사용자를 이용하게 해주려면 allow 파일의 소유자의 권한을 640이하로 설정
이용가능하게 하려는 사용자만 allow파일에 기입

U-23 DoS 공격에 취약한 서비스 비활성화

/etc/xinetd.d/ 경로 안에 echo, discard, daytime, chargen 파일이 있는지 확인
cat /etc/xinetd.d/echo
cat /etc/xinetd.d/discard
cat /etc/xinetd.d/daytime
cat /etc/xinetd.d/chargen

touch /etc/xinetd.d/echo
touch /etc/xinetd.d/discard
touch /etc/xinetd.d/daytime
touch /etc/xinetd.d/chargen

U-24 NFS 서비스 비활성화

ps -ef | grep nfsd | grep -v grep
kill -9 {pid}

U-25 NFS 접근 통제

cat /etc/export
NFS를 허용하는 호스트의 디렉토리와 원격을 허용할 IP를 기입

U-26 automountd 제거

ps -ef | grep automount | grep -v grep

U-27 RPC 서비스 확인

cd /etc/xinetd.d
ls -la
rpc 기반 동작하는 불필요 서비스 목록 확인
rpc.cmsd
rusersd
rstatd
rpc.ttdbserverd
kcms_server
Walld
rpc.nidx
rpc.ypupdated
cachefsd
sadmind
sprayd
rpc.pcnfsd
rexd
rpc.rquotad

U-28 NIS, NIS+ 점검

ps -ef | egrep "ypserv | ypbind | ypxfrd | rpc.yppasswdd| rpc.ypupdated" | grep -v "grep"
ps -ef | egrep “ypserv|ypbind|ypxfrd|rpc.yppasswdd|rpc.ypupdated”

서비스 데몬 중지

'Linux-centos' 카테고리의 다른 글

centos에 python, uwsgi, flask, nginx 설치하고 설정하기  (0) 2021.03.29
mariadb 10.5 설치  (0) 2021.03.16
SElinux  (0) 2021.03.10
scp + pem  (0) 2021.03.09
wordpress 설치하기  (0) 2021.02.24