11.7 Zabezpieczenie LILO
Jeśli serwer jest dostępny fizycznie dla osób trzecich to dobrym
pomysłem jest skonfigurowanie hasła dostępowego do komputera w BIOS
lub LILO (lub przynajmniej w jednym z tych rozwiązań). Podczas gdy BIOS
pozwala nam na założenie hasła do całego systemu, LILO pozwala na skonfigurowanie
hasła dla konkretnych systemów - inne np. by uruchomić Windows a inne by uruchomić Linuksa.
Konfiguracja hasła w LILO polega na dopisaniu dwóch wierszy do
pliku konfiguracyjnego /etc/lilo.conf
# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
boot = /dev/hda
#compact # faster, but won't work on all systems.
prompt
timeout = 300
# Normal VGA console
vga = normal
# Windows bootable partition config begins
other = /dev/hda1
label = WinXP
table = /dev/hda
# Windows bootable partition config ends
# Linux bootable partition config begins
image = /boot/vmlinuz
mandatory
password=haslo123
root = /dev/hda3
label = Linux
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
# Linux bootable partition config ends
# Windows bootable partition config begins
other = /dev/hda2
label = Win2000
table = /dev/hda
# Windows bootable partition config ends
Do wyboru mamy dwie możliwości sprawdzania hasła:
mandatory
Podanie hasła jest zawsze wymagane
restricted
Podanie hasła jest wymagane tylko wtedy gdy podano parametry startowe jądra.
Po więcej szczegółów odsyłam do manuala lilo.conf.
Aby zmiany zostały wdrożone zapisujemy plik i uruchamiamy lilo
# lilo -v
LILO version 22.5.9, Copyright (C) 1992-1998 Werner Almesberger
Development beyond version 21 Copyright (C) 1999-2004 John Coffman
Released 08-Apr-2004 and compiled at 00:18:50 on May 21 2004.
Warning: LBA32 addressing assumed
Reading boot sector from /dev/hda
Using MENU secondary loader
Calling map_insert_data
Boot other: /dev/hda1, on /dev/hda, loader CHAIN
Added WinXP *
Boot image: /boot/vmlinuz -> vmlinuz-ide-2.4.26
Added Linux
Boot other: /dev/hda2, on /dev/hda, loader CHAIN
Added Win2000
Writing boot sector.
/boot/boot.0300 exists - no boot sector backup copy made.
#
11.8 Zmiana uprawnień do plików
Wiele z plików w nowo zainstalowanym systemie posiada prawa dostępu
odbiegające od ideału. W tym podrozdziale zajmiemy się naprawieniem tego
niedopatrzenia. Prawa dostępu zmienimy dla następujących plików:
# chattr +i /etc/exports
# chattr +i /etc/hosts.equiv
# chattr +i /etc/hosts.lpd
# chattr +i /etc/inetd.conf
# chattr +i /etc/lilo.conf
# chattr +i /etc/login.access
# chattr +i /etc/login.defs
# chattr +i /etc/porttime
# chattr +i /etc/protocols
# chattr +i /etc/securetty
# chattr +i /etc/services
# chattr +i /etc/suauth
# chmod 750 /bin/mt-st
# chmod 600 /etc/ftpusers
# chmod 600 /etc/hosts.allow
# chmod 600 /etc/hosts.deny
# chmod 600 /etc/inetd.conf
# chmod 600 /etc/inittab
# chmod 600 /etc/lilo.conf
# chmod 600 /etc/login.defs
# chmod 600 /etc/securetty
# chmod 600 /etc/suauth
# chmod 440 /etc/sudoers
# chmod 600 /etc/syslog.conf
# chmod 750 /sbin/badblocks
# chmod 750 /sbin/debugfs
# chmod 750 /sbin/depmod
# chmod 750 /sbin/dumpe2fs
# chmod 750 /sbin/explodepkg
# chmod 750 /sbin/fdisk
# chmod 750 /sbin/fsck
# chmod 750 /sbin/fsck.ext2
# chmod 750 /sbin/fsck.minix
# chmod 750 /sbin/ftl_check
# chmod 750 /sbin/ftl_format
# chmod 750 /sbin/halt
# chmod 750 /sbin/hwclock
# chmod 750 /sbin/ifconfig
# chmod 750 /sbin/ifport
# chmod 750 /sbin/ifuser
# chmod 750 /sbin/init
# chmod 750 /sbin/insmod
# chmod 750 /sbin/installpkg
# chmod 750 /sbin/isapnp
# chmod 750 /sbin/killall5
# chmod 750 /sbin/lilo
# chmod 750 /sbin/makepkg
# chmod 750 /sbin/mke2fs
# chmod 750 /sbin/mkfs
# chmod 750 /sbin/mkfs.minix
# chmod 750 /sbin/mkdosfs
# chmod 750 /sbin/mkraid
# chmod 750 /sbin/mkswap
# chmod 750 /sbin/modinfo
# chmod 750 /sbin/netconfig.color
# chmod 750 /sbin/netconfig.tty
# chmod 750 /sbin/pkgtool
# chmod 750 /sbin/pnpdump
# chmod 750 /sbin/removepkg
# chmod 750 /sbin/rpc.portmap
# chmod 750 /sbin/quotaon
# chmod 750 /sbin/rdev
# chmod 750 /sbin/runlevel
# chmod 750 /sbin/setserial
# chmod 750 /sbin/swapon
# chmod 750 /sbin/tune2fs
# chmod 750 /sbin/upgradepkg
# chmod 750 /sbin/uugetty
# chmod 750 /usr/bin/eject
# chmod 4750 /usr/bin/gpasswd
# chmod 750 /usr/bin/lpq
# chmod 750 /usr/bin/lprm
# chmod 4750 /usr/bin/lpr
# chmod 750 /usr/bin/minicom
# chmod 700 /usr/bin/nohup
# chmod 700 /usr/bin/script
# chmod 500 /usr/lib/news/bin/inndstart
# chmod 500 /usr/lib/news/bin/startinnfeed
# chmod 750 /usr/lib/setup/cpkgtool
# chmod 750 /usr/lib/setup/hdsetup
# chmod 750 /usr/sbin/atd
# chmod 750 /usr/sbin/atrun
# chmod 750 /usr/sbin/crond
# chmod 750 /usr/sbin/ctrlaltdel
# chmod 750 /usr/sbin/dhcpd
# chmod 750 /usr/sbin/dhcrelay
# chmod 750 /usr/sbin/edquota
# chmod 750 /usr/sbin/groupadd
# chmod 750 /usr/sbin/groupdel
# chmod 750 /usr/sbin/groupmod
# chmod 750 /usr/sbin/grpck
# chmod 750 /usr/sbin/grpconv
# chmod 750 /usr/sbin/grpunconv
# chmod 750 /usr/sbin/hdparm
# chmod 750 /usr/sbin/imapd
# chmod 750 /usr/sbin/in.comsat
# chmod 755 /usr/sbin/in.fingerd
# chmod 755 /usr/sbin/in.identd
# chmod 750 /usr/sbin/in.talkd
# chmod 000 /usr/sbin/in.rexecd
# chmod 000 /usr/sbin/in.rlogind
# chmod 000 /usr/sbin/in.rshd
# chmod 750 /usr/sbin/in.telnetd
# chmod 000 /usr/sbin/in.tftpd
# chmod 750 /usr/sbin/in.timed
# chmod 750 /usr/sbin/inetd
# chmod 750 /usr/sbin/ipop3d
# chmod 750 /usr/sbin/klogd
# chmod 2750 /usr/sbin/lpc
# chmod 740 /usr/sbin/lpd
# chmod 750 /usr/sbin/lpf
# chmod 550 /usr/sbin/makemap
# chmod 750 /usr/sbin/mouseconfig
# chmod 750 /usr/sbin/named
# chmod 750 /usr/sbin/newusers
# chmod 750 /usr/sbin/nmbd
# chmod 750 /usr/sbin/ntpdate
# chmod 750 /usr/sbin/ntpq
# chmod 750 /usr/sbin/ntptime
# chmod 750 /usr/sbin/ntptrace
# chmod 750 /usr/sbin/pppd
# chmod 750 /usr/sbin/pwck
# chmod 750 /usr/sbin/pwconv
# chmod 750 /usr/sbin/pwunconv
# chmod 550 /usr/sbin/quotastats
# chmod 750 /usr/sbin/rpc.bootparamd
# chmod 750 /usr/sbin/rpc.mountd
# chmod 750 /usr/sbin/rpc.nfsd
# chmod 750 /usr/sbin/rpc.rusersd
# chmod 750 /usr/sbin/rpc.rwalld
# chmod 750 /usr/sbin/rpc.yppasswdd
# chmod 750 /usr/sbin/rpc.ypxfrd
# chmod 750 /usr/sbin/rpcinfo
# chmod 750 /usr/sbin/showmount
# chmod 750 /usr/sbin/smbd
# chmod 750 /usr/sbin/syslogd
# chmod 750 /usr/sbin/tcpd
# chmod 750 /usr/sbin/tcpdchk
# chmod 750 /usr/sbin/tcpdmatch
# chmod 750 /usr/sbin/tcpdump
# chmod 750 /usr/sbin/timeconfig
# chmod 750 /usr/sbin/useradd
# chmod 750 /usr/sbin/userdel
# chmod 750 /usr/sbin/usermod
# chmod 750 /usr/sbin/vipw
Ponieważ jest ich bardzo dużo przygotowałem skrypt, który zmieni
prawa dostępu do plików automatycznie. Można go ściągnąć
tutaj.
Dobrym pomysłem jest również przeglądnięcie wszystkich plików z
ustawionym setuid lub setgid i usunięcie tego prawa dla niektórych z nich.
| Tip: |
| Najprościej mówiąc pliki posiadające prawa setuid i
setgid pozwalają uruchomić program jako root normalnemu użytkownikowi.
Prosty przykład takiego programu to passwd
pozwalający zmienić hasło. Każdy użytkownik ma prawo to zrobić. Niestety
by zmienić hasło program musi dokonać zmian w plikach /etc/passwd
lub/i /etc/shadow a dostęp do tych plików ma tylko
administrator systemu czyli root. Zobacz też podrozdział
8.4 Prawa dostępu do plików i katalogów |
Pliki oraz katalogi posiadające atrybut setuid lub setgid możemy łatwo znaleźć wydając polecenia:
# find / \( -perm -4000 -o -perm -2000 \) -type f -exec ls {} \;
# find / \( -perm -4000 -o -perm -2000 \) -type d -exec ls {} \;
Z listy wybierz pliki lub katalogi do których użytkownicy nie powinni mieć dostępu
i zmień ich prawa dostępu używając polecenia:
# chmod a-s nazwa_pliku
Z wyświetlonej listy polecam zmienić przynajmniej prawa do plików:
- at - wykonuje zadania o podanym czasie
- chage - zmiana właściwości starzenia się hasła
- chfn - polecenie pozwalające użytkownikowi zmienić
informacje takie jak imię, nr telefonu itd.
- chsh - zmiana shella
- crontab - wykonywanie zadań co ustalony odstęp czasu
- expiry - zmiana właściwości starzenia się hasła
- rlogin - logowanie na zdalnym hoście (powinno się używać ssh,
rlogin nie jest bezpieczny ponieważ jest to połączenie nie szyfrowane)
- rpc - kopiowanie plików miedzy dwoma hostami
- rsh - zdalne wykonywanie komend
- utempter - pozwala nieuprzywilejowanym
programom na uzyskanie praw uprawnień root
Skrypcik można ściągnąć tutaj.
[ Poprzednia ]
[ Spis treści ]
[ Następna ]