Bilginin Adresi Ana Sayfa
Forum Anasayfası Forum Anasayfası > Bilgisayar Güvenliği / Computer Security > Güvenlik / Security Makaleleri
  Aktif Konular Aktif Konular RSS - Grsecurity nin patchlenmesi
  SSS SSS  Forumu Ara   Events   Kayıt Ol Kayıt Ol  GiriÅŸ GiriÅŸ

Grsecurity nin patchlenmesi

 Yanıt Yaz Yanıt Yaz
Yazar
Mesaj
megabros Açılır Kutu Gör
Security Professional
Security Professional
Simge

Kayıt Tarihi: 08-06-2009
Konum: Turkey
Status: Aktif DeÄŸil
Points: 752
Mesaj Seçenekleri Mesaj Seçenekleri   Thanks (0) Thanks(0)   Alıntı megabros Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: Grsecurity nin patchlenmesi
    Gönderim Zamanı: 23-08-2009 Saat 10:42

Bu yazıda geçenler tüm redhat familyasına sorunsuz şekilde uygulanabilir
Grsecurity:Kernel seviyesinde uygulanan güvenliği arttırmak için bir çok yama ve seçenekten oluşmaktadır.Sadece kernel i sağlamlaştırmakla kalmayıp olabilicek açıklara karşı sistemi korumaktadır grsecurity 3 aşamadan oluşur tanımlama bildirme ve önleme.Bu yazı genel olarak sunucular için hazırlanmıştır ev kullanıcılarının kernellerini grsecurity ile patchlemeleri çok gerekli değildir.

 

Grsecurity nin Genel Özellikleri Şunlardır.

* Role-Based Access Control
* User, group, and special roles
* Domain support for users and groups
* Role transition tables
* IP-based roles
* Non-root access to special roles
* Special roles that require no authentication
* Nested subjects
* Variable support in configuration
* And, or, and difference set operations on variables in configuration
* Object mode that controls the creation of setuid and setgid files
* Create and delete object modes
* Kernel interpretation of inheritance
* Real-time regular-expression resolution
* Ability to deny ptraces to specific processes
* User and group transition checking and enforcement on an inclusive or exclusive basis
* /dev/grsec entry for kernel authentication and learning logs
* Next-generation code that produces least-privilege policies for the entire system with no configuration
* Policy statistics for gradm
* Inheritance-based learning
* Learning configuration file that allows the administrator to enable inheritance-based learning or disable learning on specific paths
* Full pathnames for offending process and parent process
* RBAC status function for gradm
* /proc/<pid>/ipaddr gives the remote address of the person who started a given process
* Secure policy enforcement
* Supports read, write, append, execute, view, and read-only ptrace object permissions
* Supports hide, protect, and override subject flags
* Supports the PaX flags
* Shared memory protection feature
* Integrated local attack response on all alerts
* Subject flag that ensures a process can never execute trojaned code
* Full-featured fine-grained auditing
* Resource, socket, and capability support
* Protection against exploit bruteforcing
* /proc/pid filedescriptor/memory protection
* Rules can be placed on non-existent files/processes
* Policy regeneration on subjects and objects
* Configurable log suppression
* Configurable process accounting
* Human-readable configuration
* Not filesystem or architecture dependent
* Scales well: supports as many policies as memory can handle with the same performance hit
* No runtime memory allocation
* SMP safe
* O(1) time efficiency for most operations
* Include directive for specifying additional policies
* Enable, disable, reload capabilities
* Option to hide kernel processes

Chroot restrictions

* No attaching shared memory outside of chroot
* No kill outside of chroot
* No ptrace outside of chroot (architecture independent)
* No capget outside of chroot
* No setpgid outside of chroot
* No getpgid outside of chroot
* No getsid outside of chroot
* No sending of signals by fcntl outside of chroot
* No viewing of any process outside of chroot, even if /proc is mounted
* No mounting or remounting
* No pivot_root
* No double chroot
* No fchdir out of chroot
* Enforced chdir(”/”) upon chroot
* No (f)chmod +s
* No mknod
* No sysctl writes
* No raising of scheduler priority
* No connecting to abstract unix domain sockets outside of chroot
* Removal of harmful privileges via capabilities
* Exec logging within chroot

Address space modification protection

* PaX: Page-based implementation of non-executable user pages for i386, sparc, sparc64, alpha, parisc, amd64, ia64, and ppc; negligible performance hit on all i386 CPUs but Pentium 4
* PaX: Segmentation-based implementation of non-executable user pages for i386 with no performance hit
* PaX: Segmentation-based implementation of non-executable KERNEL pages for i386
* PaX: Mprotect restrictions prevent new code from entering a task
* PaX: Randomization of stack and mmap base for i386, sparc, sparc64, alpha, parisc, amd64, ia64, ppc, and mips
* PaX: Randomization of heap base for i386, sparc, sparc64, alpha, parisc, amd64, ia64, ppc, and mips
* PaX: Randomization of executable base for i386, sparc, sparc64, alpha, parisc, amd64, ia64, and ppc
* PaX: Randomization of kernel stack
* PaX: Automatically emulate sigreturn trampolines (for libc5, glibc 2.0, uClibc, Modula-3 compatibility)
* PaX: No ELF .text relocations
* PaX: Trampoline emulation (GCC and linux sigreturn)
* PaX: PLT emulation for non-i386 archs
* No kernel modification via /dev/mem, /dev/kmem, or /dev/port
* Option to disable use of raw I/O
* Removal of addresses from /proc/<pid>/[maps|stat]

Auditing features

* Option to specify single group to audit
* Exec logging with arguments
* Denied resource logging
* Chdir logging
* Mount and unmount logging
* IPC creation/removal logging
* Signal logging
* Failed fork logging
* Time change logging

Randomization features

* Larger entropy pools
* Randomized PIDs
* Randomized TCP source ports

Other features

* /proc restrictions that don”t leak information about process owners
* Symlink/hardlink restrictions to prevent /tmp races
* FIFO restrictions
* Dmesg(8) restriction
* Enhanced implementation of Trusted Path Execution
* GID-based socket restrictions
* Nearly all options are sysctl-tunable, with a locking mechanism
* All alerts and audits support a feature that logs the IP address of the attacker with the log
* Stream connections across unix domain sockets carry the attacker”s IP address with them (on 2.4 only)
* Detection of local connections: copies attacker”s IP address to the other task
* Automatic deterrence of exploit bruteforcing
* Low, Medium, High, and Custom security levels
* Tunable flood-time and burst for logging

2.4.x kernelden 2.6.x kernele çıkıcak olanlar module-init-tools u güncellemeliler bu işlem şu şekilde yapılıcaktır.

Kod:
cd /usr/local/src/
wget http://www.kernel.org/pub/linux/kernel/people/rusty/modules/old/module-init-tools-3.0.tar.gz
tar -zxf module-init-tools-3.0.tar.gz
cd module-init-tools-3.0
./configure –prefix=”"
make moveold
make install
./generate-modprobe.conf /etc/modprobe.conf
cd ..

Gerekli Paketlerin Yüklenmesi

-Gcc ve bağımlılıklarının yüklenmesi

Fedora ve Centos için

Kod:
yum install gcc

Redhat için

Kod:
up2date gcc

-ncurses-devel ın ve bağımlılıklarının yüklenmesi menuconfig kısmı için gerekli

Fedora ve Centos için

Kod:
yum install ncurses-devel

Redhat için

Kod:
up2date ncurses-devel

-Patch paketi ve bağımlılıklarının yüklenmesi

Fedora ve Centos için

Kod:
yum install patch

Redhat için

Kod:
up2date patch

Root Olarak Başlıyalım

Kerneli ve grsecurity patch ini indiriceğimiz dizine geçelim

Kod:
cd /usr/local/src

Kerneli çekelim

Kod:
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.3.tar.bz2

Grsecurity yi çekelim

Kod:
http://www.grsecurity.org/grsecurity-2.1.7-2.6.14.3-200511291802.patch.gz

Kerneli açalım

Kod:
tar xvfj linux-2.6.14.3.tar.bz2

Grsecurity yi açalım

Kod:
gzip -d grsecurity-2.1.7-2.6.14.3-200511291802.patch.gz

Kerneli patchliyelim

Kod:
patch -p0 < ./grsecurity-2.1.7-2.6.14.3-200511291802.patch

Kernel kaynak kodunun bulunduğu klasöre girelim

Kod:
cd /usr/src/linux-2.6.14.3

Eski ayarları temizleyelim

Kod:
make mrproper

Konfigurasyon menusune geçelim

Kod:
make menuconfig

burada sisteminizin ihtiyaçlarınıza göre gerekli modülleri ekleyip çıkardıktan sonra en sonra Security Options kısmına geliyoruz

burda NSA SELinux Support kısmını kapatıyoruz yani yanındaki işaretini kaldırıyoruz sonra grsecurity menusune giriyoruz

Grsecurity Menusu

Security Level kısmına gelip custom u seçiyoruz genelde medium seçeğide bir çok sistemde çok rahat çalışacaktır ayar yapmak istemiyorsanız direk medium u seçip derlemeye başlayabilrisiniz high ı seçerseniz bir çok panelde sorun yaşatıcaktır özellikle cpanel ve directadmin de denediğim için söylüyorum logrotate olayı düzgün çalışmayacak ve stats programlarıda düzgün şekilde işlemeyecektir

Adress Space Protectionkısmına giriyoruz
bu bölümde şu 3 seçeği seçiyoruz
Deny writing to /dev/kmem, /dev/mem, and /dev/port
Hide kernel symbols
Disable privileged I/O

Eper x masaüstünü kullanıyorsanız Disable privileged I/O kısmını seçmeyin yoksa sisteminiz açılmayacaktır.

Role Based Access Control Options kısmını olduğu gibi bırakın
Filesystem Protections kısmına gelin burada şu seçenekleri seçin
*] Proc restrictions
Restrict /proc to user only
Additional restrictions
Linking restrictions
FIFO restrictions
Chroot jail restrictions
eğer ensim yada plesk kullanıyorsanız Chroot jail restirictions seçeneğini seçmeyin yoksa ensimin kendi chroot sisitemini bozacağı gibi plesk inde düzgün çalışmamasına neden olacaktır
Kernel Auduting kısmını olduğu gibi bırakın
Executable Protections kısmına gelin
Destroy unused shared memory
Dmesg(8) restriction
Randomized PIDs
Destroy unused shared memory
seçeneklerini seçin
Network Protections kısmına gelin
Larger entropy pools
Randomized TCP source ports
seçeneklerini seçin
Sysctl support ve logging options kısımlarını geçin sysctl support kısmında kernel ayarlarının özellikle yaptığınız grsecurity ayarlarının kerneli yeniden derlemeden değiştirmenizi sağlamaktadır.

şimdi kerneli derlemeye geçelim

sırasıyla aşğıdaki komutları verin eğer monolitnic yani modül desteği olmayan bir kernel hazırladıysanız herşeyi static olarak eklediyseniz make modules ve make modules_install kısımlarını atlayın

Kod:
make bzImage

Kod:
make modules

Kod:
make modules_install

ve son olarak initial ramdisk oluşturucaz eğer bnu oluşturmazda grsecurity ile beraber derlerseniz grsecurity ile patchlenmiş kernelle başlattığınızda alıcağınız hata şu olacaktır

Kod:
Kernel panic – not syncing vfs unable to mount root filesystem on unknown block gibi

initial ram disk oluşturuyoruz

Kod:
mkinitrd /boot/initrd-2.6.14.3-grsec.img 2.6.14.3

Kerneli kullanım için hazırlıyoruz

Kod:

cp .config /boot/config-2.6.14.3-grsec
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.14.3-grsec
cp System.map /boot/System.map-2.6.14.3-grsec
ln -s /boot/System.map-2.6.14.3-grsec /boot/System.map

/dev/mapper/control ile ilgili bir hata alırsanız bunu yapın

Kod:

rm -rf /boot/initrd-2.6.14.3-grsec.img
mkinitrd –omit-lvm-modules /boot/initrd-2.6.14.3-grsec.img 2.6.14.3

Bootloaderların ayarlanması LİLO , GRUB
sıra geldi bootloader ların ayarlanmasına ilk önce grub ile başlayalım

pico /etc/grub.conf yazarak ayar dosyasını açıyoruz

Kod:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd1,0)
#          kernel /boot/vmlinuz-version ro root=/dev/hdb1
#          initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-22.0.1.EL)
root (hd1,0)
kernel /boot/vmlinuz-2.6.9-22.0.1.EL ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.9-22.0.1.EL.img

altına şunu ekliyoruz

Kod:
title CentOS (2.6.14.3-grsec)
root (hd1,0)
kernel /boot/vmlinuz-2.6.14.3-grsec ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.14.3-grsec.img

Eklendiğinde tümünün görünümü şu şekilde oluyoru

Kod:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd1,0)
#          kernel /boot/vmlinuz-version ro root=/dev/hdb1
#          initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-22.0.1.EL)
root (hd1,0)
kernel /boot/vmlinuz-2.6.9-22.0.1.EL ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.9-22.0.1.EL.img
title CentOS (2.6.14.3-grsec)
root (hd1,0)
kernel /boot/vmlinuz-2.6.14.3-grsec ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.14.3-grsec.img

sonra grub yazıyoruz ve yeni kernelle 1 kere başlatmak üzetre ayarlıyoruz eğer düzgün başlarsa grub.conf ta default yazan değeri 1 yapıyorsunuz

Kod:
savedefault –default=1 –once
ve reboot atın

Lilo için ayarlanlası

Kod:
pico /etc/lilo.conf yazarka lilo konfigurasyon dosyasını açıyorsunuz

Kod:

prompt
timeout=50
default=2.4.21-32.0.1.E
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
message=/boot/message
lba32

image=/boot/vmlinuz-2.4.21-32.0.1.EL
label=linux
initrd=/boot/initrd-2.4.21-32.0.1.EL.img
read-only
append=”root=LABEL=/”

şu kıısmı ekliyoruz altına

Kod:

image=/boot/vmlinuz-2.6.14.3-grsec
label=linux
initrd=/boot/initrd-2.6.14.3.-grsec.img
read-only
append=”root=LABEL=/”

görünümü şu şekilde oluyor

Kod:
prompt
timeout=50
default=2.4.21-32.0.1.E
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
message=/boot/message
lba32

image=/boot/vmlinuz-2.4.21-32.0.1.EL
label=linux
initrd=/boot/initrd-2.4.21-32.0.1.EL.img
read-only
append=”root=LABEL=/”

image=/boot/vmlinuz-2.6.14.3-grsec
label=linux
initrd=/boot/initrd-2.6.14.3.-grsec.img
read-only
append=”root=LABEL=/”

ve yeni kernelle 1 kere boot edicek şekilde ayarlıyoruz

Kod:
lilo -v -v

Kod:
lilo -R 2.6.14.3.-grsec

eğer sorunsuz bir şekilde boot ederseniz gene lilo.conf u açıp default=2.4.21-32.0.1.E yazan kısımı default=2.6.14.3-grsec şeklinde değiştirip konsolda lilo -v -v komutunu vererek mbr ye kaydedin.

Saygılar..


Düzenleyen megabros - 23-08-2009 Saat 10:42
Yukarı Dön
 Yanıt Yaz Yanıt Yaz

Forum Atla Forum İzinleri Açılır Kutu Gör



Bu Sayfa 0.155 Saniyede Yüklendi.