How to limit the execution permission of the /tmp partition

  
 

What restrictions on execution permissions Linux's privilege rootkits are basically compiled executable files. Disabling its operation under /tmp reduces the possibility of hacking. Perl, PHP
scripts are interpreted languages ​​that can be called directly via the perl/php command, even if the script is stored in /tmp.

## Case: perl /tmp/hack.pl #Runs /tmp/back.pl #Cannot run

Check if there is a separate /tmp partition running”df -h” Command, in the "Mount On" column to confirm whether there is a ” /tmp & rdquo; information. There are separate /tmp partitions.

Restricting Permissions on Systems with Independent /tmp Partitions

### 1. Edit the /tmp mount permission in the /etc/fstab file and adjust ”defaults” to ” Rw, nosuid, noexec”. LABEL=/tmp /tmp ext3 rw,nosuid,noexec 1 2

### 2. Reload the /tmp partition with the mount command mount -oremount loop,rw,nosuid,noexec /tmp

Restrict permissions on systems that do not have separate /tmp partitions

## Example: Create a 100 megabyte /tmp partition and disable execute permissions cd /dev/dd if=/dev/zero of=Tmp bs= 1024 count=100000mkfs -t ext3 /dev/Tmpcd /cp -aR /tmp /tmp_backupmount -o loop,noexec,nosuid,rw /dev/Tmp /tmpcp -aR /tmp_backup/* /tmp/chmod 0777 /tmpchmod +t /Tmp

Disable execution permission under /var/tmp

cd /varmv /var/tmp/* /tmp/ls -alh /var/tmp # Confirm that all data has been migrated to /tmprm -fR /var/tmpln -s /tmp /var/tmp

Copyright © Windows knowledge All Rights Reserved