利用目录遍历攻击执行命令

发布于 2024-08-21 06:40:36 字数 330 浏览 2 评论 0原文

有没有办法使用目录遍历攻击来执行命令?

例如,我像这样访问服务器的 etc/passwd 文件

http://server.com/..%01/..%01/..%01//etc/passwd

有没有办法改为运行命令?就像......

http://server.com/..%01/..%01/..%01//ls

并得到输出?

需要澄清的是,我在我们公司的服务器中发现了该漏洞。我希望通过证明它可以让攻击者完全访问系统来提高风险级别(或对我来说是加分)

Is there a way to execute commands using directory traversal attacks?

For instance, I access a server's etc/passwd file like this

http://server.com/..%01/..%01/..%01//etc/passwd

Is there a way to run a command instead? Like...

http://server.com/..%01/..%01/..%01//ls

..... and get an output?

To be clear here, I've found the vuln in our company's server. I'm looking to raise the risk level (or bonus points for me) by proving that it may give an attacker complete access to the system

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

℡寂寞咖啡 2024-08-28 06:40:36

Linux 上的 Chroot 很容易被破坏(与 FreeBSD 不同)。更好的解决方案是打开 SELinux 并在 SELinux 沙箱中运行 Apache:

run_init /etc/init.d/httpd restart

确保已安装 mod_security 并正确配置。

Chroot on Linux is easily breakable (unlike FreeBSD). Better solution is to switch on SELinux and run Apache in SELinux sandbox:

run_init /etc/init.d/httpd restart

Make sure you have mod_security installed and properly configured.

っ左 2024-08-28 06:40:36

如果由于服务器上未正确配置文档根或目录访问权限而导致您能够查看 /etc/passwd,则此漏洞的存在并不自动意味着您可以执行以下命令你的选择。

另一方面,如果由于 Web 应用程序在 popen、exec、system、shell_exec 或未经充分清理的变体等调用中使用用户输入(文件名)而能够查看 /etc/passwd 中的条目,那么您可能会能够执行任意命令。

If you are able to view /etc/passwd as a result of the document root or access to Directory not correctly configured on the server, then the presence of this vulnerability does not automatically mean you can execute commands of your choice.

On the other hand if you are able view entries from /etc/passwd as a result of the web application using user input (filename) in calls such as popen, exec, system, shell_exec, or variants without adequate sanitization, then you may be able to execute arbitrary commands.

违心° 2024-08-28 06:40:36

除非网络服务器是由不知道自己在做什么的人完全可怕地编程的,否则尝试使用它访问 ls (假设它甚至有效)将导致您看到 的内容ls 二进制文件,仅此而已。

这可能不是很有用。

Unless the web server is utterly hideously programmed by someone with no idea what they're doing, trying to access ls using that (assuming it even works) would result in you seeing the contents of the ls binary, and nothing else.

Which is probably not very useful.

┈┾☆殇 2024-08-28 06:40:36

是的,如果应用程序真的很糟糕(就安全性而言),则有可能(第一个问题)。

http://www.owasp.org/index.php/Top_10_2007-Malicious_File_Execution

Yes it is possible (the first question) if the application is really really bad (in terms of security).

http://www.owasp.org/index.php/Top_10_2007-Malicious_File_Execution

柏拉图鍀咏恒 2024-08-28 06:40:36

编辑#2:我已经删除了我的评论,因为它们被认为是讽刺和直率的。好吧,现在更多信息来自 gAMBOOKa,Apache 与 Fedora - 您应该将其放入问题中 - 我建议:

  • 发布到 Apache 论坛,突出显示您正在运行最新版本的 Apache 并在 Fedora 上运行并提交漏洞利用给他们。
  • 再次发帖到 Fedora 论坛,强调您正在运行最新版本的 Apache 并向他们提交漏洞利用程序。
  • 应该注意的是,在发布到这两个站点的论坛时,请包含 httpd.conf。
  • 为了最大限度地减少对 passwd 文件的访问,请考虑在沙箱/chroot 环境中运行 Apache,其中任何其他文件(例如 passwd)在沙箱/chroot 环境之外都不可见...您是否有一个备用盒子来进行试验,甚至最好使用 VMWARE 来模拟与 Apache/Fedora 使用的相同环境 - 尝试使其成为相同的环境,并使 httpd 服务器在 VMWare 中运行,并远程访问虚拟机以检查漏洞利用是否仍然可见。然后 chroot/sandbox 并再次重新运行该漏洞...
  • 记录重现它的步骤并包含建议,直到找到修复程序,同时如果对在沙箱/chrooted 环境中运行的 Web 服务器影响最小- 推动他们这样做...

希望这有帮助,
此致,
汤姆.

Edit#2: I have edited out my comments as they were deemed sarcastic and blunt. Ok now as more information came from gAMBOOKa about this, Apache with Fedora - which you should have put into the question - I would suggest:

  • Post to Apache forum, highlighting you're running latest version of Apache and running on Fedora and submit the exploit to them.
  • Post to Fedora's forum, again, highlighting you're running the latest version of Apache and submit the exploit to them.
  • It should be noted, include the httpd.conf to both of the sites when posting to their forums.
  • To minimize access to passwd files, look into running Apache in a sandbox/chrooted environment where any other files such as passwd are not visible outside of the sandbox/chrooted environment...have you a spare box lying around to experiment with it or even better use VMWARE to simulate the identical environment you are using for the Apache/Fedora - try get it to be IDENTICAL environment, and make the httpd server run within VMWare, and remotely access the Virtual machine to check if the exploit is still visible. Then chroot/sandbox it and re-run the exploit again...
  • Document the step-by-step to reproduce it and include a recommendation until a fix is found, meanwhile if there is minimal impact to the webserver running in sandbox/chrooted environment - push them to do so...

Hope this helps,
Best regards,
Tom.

无可置疑 2024-08-28 06:40:36

如果您已经可以查看etc/passwd,那么服务器的配置一定很差......
如果你真的想执行命令,那么你需要知道服务器中运行的php脚本是否有system()命令,以便你可以通过url传递命令。
例如: url?command=ls
尝试查看 .htaccess 文件....它可能会成功..

If you already can view etc/passwd then the server must be poorly configured...
if you really want to execute commands then you need to know the php script running in the server whether there is any system() command so that you can pass commands through the url..
eg: url?command=ls
try to view the .htaccess files....it may do the trick..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文