首页 > 其他分享 >[MRCTF2020]Ezaudit 1

[MRCTF2020]Ezaudit 1

时间:2024-07-15 15:10:24浏览次数:8  
标签:Ezaudit res str1 private length key public MRCTF2020

信息收集,伪随机数


打开之后发现什么按键都没用,直接扫目录得到了两个网址:
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_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???

可以看到这个代码要传入三个变量一个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

标签:Ezaudit,res,str1,private,length,key,public,MRCTF2020
From: https://www.cnblogs.com/z2gh/p/18303174

相关文章

  • [MRCTF2020]套娃
    [MRCTF2020]套娃打开环境发现有张图片显示不出来查看网页源代码发现部分代码$query=$_SERVER['QUERY_STRING'];if(substr_count($query,'_')!==0||substr_count($query,'%5f')!=0){die('Y0uareSocutE!');}if($_GET['b_u_p_t�......
  • [MRCTF2020]PYWebsite
    [MRCTF2020]PYWebsite查看源代码发现验证成功后跳转flag页面<script>functionenc(code){hash=hex_md5(code);returnhash;}functionvalidate(){varcode=document.getElementById("vcode").value;if(code!="......
  • [MRCTF2020]你传你呢
    [MRCTF2020]你传你......
  • [MRCTF2020]Easy_RSA
    [MRCTF2020]Easy_RSA首先,RSA计算的5个基本公式n=pqφ(n)=(p-1)(q-1)求φ(n)e*dmodφ(n)=1求ed其中之一c=m^emodn加密m=c^dmodn解密题目:importsympyfromgmpy2importgcd,invertfromrandomimportrandintfromCrypto.Util.numberimportgetPrime,is......
  • [MRCTF2020]Hello_ misc
    [MRCTF2020]Hello_misc压缩包里有1个压缩包和png图片压缩包有密码,先对图片进行解析发现红色通道里还藏有一张图片得到zip压缩包密码:!@#$%67*()-+这个密码是图片中藏着的压缩包的密码,输入后打开里面有一个out.txt文件12725563191127191631271272556319163......
  • mrctf2020_easyoverflow
    mrctf2020_easyoverflow控制栈上参数程序控制流bamuwe@qianenzhao:~$checksecmrctf2020_easyoverflow[*]'/home/bamuwe/mrctf2020_easyoverflow'Arch:amd64-64-littleRELRO:FullRELROStack:CanaryfoundNX:NXenabled......
  • BUUCTF [MRCTF2020]Ez_bypass 1
    题目环境:F12查看源代码IputsomethinginF12foryou include'flag.php';$flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}';if(isset($_GET['gg'])&&isset($_GET['id'])){ $id=$_GET['id']; $gg=$_GET[&#......
  • [MRCTF2020]CyberPunk
    压缩包里是一个exe程序,打开如图会刷新时间按照程序的意思,是到了2020.9.17这个日子,会给我们flag,修改下当前系统时间flag{We1cOm3_70_cyber_security}......
  • [MRCTF2020]千层套路
    压缩包需要密码,暴力破解得知为0573发现里面压缩包的密码也是文件名0114估计是套娃题,拿脚本解压importzipfilename='0573'whileTrue:fz=zipfile.ZipFile(name+'.zip','r')fz.extractall(pwd=bytes(name,'utf-8'))name=fz.filelist[0].file......
  • 【MRCTF2020】Ezpop_Revenge——PHP原生类SSRF
    【MRCTF2020】Ezpop_Revenge——PHP原生类SSRF1.收获CMS初审计google、baiduhackPHP原生类反序列化2.看题2.1读源码网页存在源码泄露,访问www.zip,得到源码。同时要知道,typecho模板是存在反序列化注入漏洞的,但是其存在于install.php,本题中没有这个文件,所以找找其他线索......