eWebtricity
12-17-2005, 11:15 PM
Courtesy of JohnWong - original thread can be found here: http://www.1and1faq.com/forums/showthread.php?t=70
I used to create a loop back file for the /tmp directory Not only to have a bigger /tmp directory, I can have some limited protection from script kiddies. Those script kiddies like to use some PHP application weakness (like older version of phpBB, zeroboard) to instruct php to download source code, compile it and execute the binary. The binary may be something to DoS or sending spam emails .... Therefore, I used to send up a separate /tmp partition with loopback device and add the noexec option during mounting. Here is the instructions:
change directory to /var
# cd /var
write a 300MB file
# dd if=/dev/zero of=tmpMnt bs=1024 count=300000
create a ext2 partition on the file
# /sbin/mke2fs /var/tmpMnt
copy current tmp directory content to
# cp -R /tmp /tmp_backup
mount the new /tmp partition
# mount -o loop,noexec,nosuid,rw /var/tmpMnt /tmp
setup correct permission for the new /tmp folder
# chmod 1777 /tmp
copy all previous content of tmp directory to the new old
# cp -R /tmp_backup/* /tmp/
remove unused files
# rm -rf /tmp_backup
create proper symbolic links
# ln -s /tmp /var/tmp
If you want this change to be permanent, add this line at the bottom of your /etc/fstab:
/var/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0
Beside using this method to stop the script kiddies to execute anything from my server tmp directory, I like to change the permission of "wget" (normally used by those script kiddies to download their payload) to owner executable only.
I used to create a loop back file for the /tmp directory Not only to have a bigger /tmp directory, I can have some limited protection from script kiddies. Those script kiddies like to use some PHP application weakness (like older version of phpBB, zeroboard) to instruct php to download source code, compile it and execute the binary. The binary may be something to DoS or sending spam emails .... Therefore, I used to send up a separate /tmp partition with loopback device and add the noexec option during mounting. Here is the instructions:
change directory to /var
# cd /var
write a 300MB file
# dd if=/dev/zero of=tmpMnt bs=1024 count=300000
create a ext2 partition on the file
# /sbin/mke2fs /var/tmpMnt
copy current tmp directory content to
# cp -R /tmp /tmp_backup
mount the new /tmp partition
# mount -o loop,noexec,nosuid,rw /var/tmpMnt /tmp
setup correct permission for the new /tmp folder
# chmod 1777 /tmp
copy all previous content of tmp directory to the new old
# cp -R /tmp_backup/* /tmp/
remove unused files
# rm -rf /tmp_backup
create proper symbolic links
# ln -s /tmp /var/tmp
If you want this change to be permanent, add this line at the bottom of your /etc/fstab:
/var/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0
Beside using this method to stop the script kiddies to execute anything from my server tmp directory, I like to change the permission of "wget" (normally used by those script kiddies to download their payload) to owner executable only.