当前位置:网站首页>[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
![]()


边栏推荐
猜你喜欢

What does a good resume look like in the eyes of a big factory interviewer?

如何注册域名、备案以及解析

huato hot update environment construction (DLL method hot update C# code)

为什么中年男人爱出轨?

Goland opens file saving and automatically formats

Leetcode 119. Yang Hui's Triangle II

3D激光SLAM:LeGO-LOAM论文解读---特征提取部分

DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计

PHP留言反馈管理系统源码

探究CSAPP实验二-bomb lab-第一节
随机推荐
Goland 开启文件保存自动进行格式化
Public Key Retrieval is not allowed报错解决方案
加密生活,Web3 项目合伙人的一天
04、Activity的基本使用
Security business revenue growth rate exceeds 70% 360 builds digital security leader
3D激光SLAM:LeGO-LOAM论文解读---激光雷达里程计与建图
PHP message feedback management system source code
测试管理与规范
【Linux Operating System】 Virtual File System | File Cache
【SOC】Classic output hello world
绕开驱动层检测的无痕注入
Login Module Debugging - Getting Started with Software Debugging
【SOC FPGA】Peripheral KEY LED
Visual Studio编辑器 2019:scanf函数返回值被忽略(C4996)报错及解决办法
PCIE入门
数据库课程设计大作业大盘点【建议在校生收藏】
Public Key Retrieval is not allowed error solution
有没有并发系统设计的经验,我该怎么说?
DTSE Tech Talk丨Phase 2: 1 hour in-depth interpretation of SaaS application system design
js 切换数据源的时候该缓存checkbox选中结果并回显?