信息收集,伪随机数
打开之后发现什么按键都没用,直接扫目录得到了两个网址:
www.zip
login.html
<?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_keyfunction 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???
可以看到这个代码要传入三个变量一个username,password,Private_key
但是这个private_key是随机数,同时如果我们传入正确的Private_key,只需要万能密码就可以成功查找
可以从题目最下面看到他给我们了public_key这时只需要用php_mt_seed找到种子就好了
首先用脚本给他转成脚本可以识别特征序列
str1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
str2 = 'KVQP0LdJKRaV3n9D'
str3 = str1[::-1] # 这一行实际上并没有用到,可以移除或保留以备后用。length = len(str2)
res = ''# 遍历str2中的每一个字符
for char in str2:# 找到char在str1中的位置index = str1.find(char)# 检查是否找到了该字符if index != -1:# 添加转换后的数字序列到结果字符串中res += f'{index} {index} 0 {len(str1) - 1} 'else:# 如果字符不在str1中,可能需要处理或抛出异常print(f"Character '{char}' not found in str1.")# 移除最后一个多余的空格
res = res.rstrip()print(res)
之后直接上kali
找到种子值值后直接写码
<?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;
}//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;
}echo public_key();
echo "--------------------------------------";
echo private_key();
之后按照我们先前的逻辑传入数值就好了
得到flag