Thread: security apache
View Single Post
  #4   (View Single Post)  
Old 17th January 2009
Nk2Network Nk2Network is offline
Port Guard
 
Join Date: Jan 2009
Posts: 43
Default

hello,

I would like to restrict access to process Apache file system in use Chrooter,I need help creating my Chrooter

begin this process by creating a new folder with road /chroot/httpd

PHP Code:
mkdir -/chroot/httpd/dev
mkdir 
-/chroot/httpd/etc
mkdir 
-/chroot/httpd/var/run
mkdir 
-/chroot/httpd/usr/lib
mkdir 
-/chroot/httpd/usr/libexec
mkdir 
-/chroot/httpd/usr/local/apache/bin
mkdir 
-/chroot/httpd/usr/local/apache/logs
mkdir 
-/chroot/httpd/usr/local/apache/conf
mkdir 
-/chroot/httpd/www 
The possessor of all such records must be the root, and access rights must be of 0755. Create special device file: /dev /null /


PHP Code:
-al /dev/null
crw
-rw-rw1 root wheel 22 Mar 14 12:53 /dev/null
mknod 
/chroot/httpd/dev/null c 2 2
chown root
:sys /chroot/httpd/dev/null
chmod 666 
/chroot/httpd/dev/null 
PHP Code:
added to /etc /rc.conf
I admit to being difficult to understand and possible to have an explanation so I can understand

Examples of use "ldd", orders "strings" et "truss" are below

PHP Code:
localhost# ldd /usr/local/apache/bin/httpd
/usr/local/apache/bin/httpd:
libcrypt.so.2 => /usr/lib/libcrypt.so.2 (0x280bd000)
libc.so.4 => /usr/lib/libc.so.4 (0x280d6000)

localhost# strings /usr/local/apache/bin/httpd | grep lib
/usr/libexec/ld-elf.so.1
libcrypt
.so.2
libc
.so.4

localhost
# truss /usr/local/apache/bin/httpd | grep open
(...)
open("/var/run/ld-elf.so.hints",0,00) = (0x3)
open("/usr/lib/libcrypt.so.2",0,027757775370) = (0x3)
open("/usr/lib/libc.so.4",0,027757775370) = (0x3)
open("/etc/spwd.db",0,00) = (0x3)
open("/etc/group",0,0666) = (0x3)
open("/usr/local/apache/conf/httpd.conf",0,0666) = (0x3)
(...) 
The above should not be applied only httpd program, but all libraries and binary files required

some command does not work

PHP Code:
cp /usr/local/apache/bin/httpd /chroot/httpd/usr/local/apache/binNo such 
file or directory
PHP Code:
cp /var/run/ld-elf.so.hints /chroot/httpd/var/run
command works
PHP Code:
cp /usr/lib/libcrypt.so.2 /chroot/httpd/usr/lib
No such file or directory
PHP Code:
cp /usr/lib/libc.so.4 /chroot/httpd/usr/lib
No such file or directory
PHP Code:
cp /usr/libexec/ld-elf.so.1 /chroot/httpd/usr/libexec
command works

Using the "truss" we can also discover that the following configuration files must be present in the chroote environment:

command works

PHP Code:
cp /etc/hosts /chroot/httpd/etc/
cp /etc/host.conf /chroot/httpd/etc/
cp /etc/resolv.conf /chroot/httpd/etc/
cp /etc/group /chroot/httpd/etc/
cp /etc/master.passwd /chroot/httpd/etc/passwords
cp 
/usr/local/apache/conf/mime.types /chroot/httpd/usr/local/apache/conf

Last edited by Nk2Network; 17th January 2009 at 10:21 PM.
Reply With Quote