本周学习的主要内容有
学习完了js 浅层次入门sql使用 xss的练手
一js(总算学习完了)
如图
二浅层次sql学习
如图
三 xss练手
因为上一周学习了html php js 所以现在可以看得懂代码了
也可以开始迈出 安全员的第一步了
http://test.ctf8.com/ 靶场
请先关闭 浏览器xss防护 否则gg
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不错!");
window.location.href="level2.php?keyword=test";
}
</script>
<title>欢迎来到level1</title>
</head>
<body>
<h1 align=center>欢迎来到level1</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["name"];
echo "<h2 align=center>欢迎用户".$str."</h2>";
?>
<center><img src=level1.png></center>
<?php
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>
第一关
window.alert = function() 可以看出 只要检测到弹框函数,就可以触发进入下一关的函数。也就是说只要触发alert即可
<?php
ini_set("display_errors", 0); //貌似是不报错代码
$str = $_GET["name"];
echo "<h2 align=center>欢迎用户".$str."</h2>";
关键的php代码块
http://test.ctf8.com/level1.php?name=
name后面就是接收字符的地方
含义是使用超级全局变量 使用get从url中收取一段字符,再显示这一段字符的长度和字符本身(也就是说正常情况下,你输入什么他显示什么)
所以直接使用script即可
输入<script>alert(1)</script>
触发alert函数,进入下一关
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不错!");
window.location.href="level3.php?writing=wait";
}
</script>
<title>欢迎来到level2</title>
</head>
<body>
<h1 align=center>欢迎来到level2</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level2.php method=GET>
<input name=keyword value="'.$str.'">
<input type=submit name=submit value="搜索"/>
</form>
</center>';
?>
<center><img src=level2.png></center>
<?php
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>
多了一个表单,可以从表单里直接接收数据,从php中可以看见
htmlspecialchars过滤了部分字符 《》行不通了
有两种思路
第一种,那就索性不用script了,借助表单的性质,用onclick来触发alert函数,只要到时候再点击表单即可。
第二种,先闭合掉再触发alert函数,还是使用script
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不错!");
window.location.href="level4.php?keyword=try harder!";
}
</script>
<title>欢迎来到level3</title>
</head>
<body>
<h1 align=center>欢迎来到level3</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>"."<center>
<form action=level3.php method=GET>
<input name=keyword value='".htmlspecialchars($str)."'>
<input type=submit name=submit value=搜索 />
</form>
</center>";
?>
<center><img src=level3.png></center>
<?php
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>
第三题
过滤更加严格了,《script、》的过滤更加严格了,只能使用第一种方法
顺便使用//打掉后面的代码
然后寒假要求 要求是多学,而不是深究,再加上后面的部分代码超过了目前自学php的范围,所以暂时就没有往后做了。