[GWCTF 2019]枯燥的抽奖 web详细解题过程

在这里插入图片描述
查看网页源代码发现有这一段
在这里插入图片描述

$(document).ready(function(){
    $("#div1").load("check.php #p1");

        $(".close").click(function(){
        		$("#myAlert").hide();
    });	     

    $("#button1").click(function(){
    	$("#myAlert").hide();
    	guess=$("input").val();
		$.ajax({
	   type: "POST",
	   url: "check.php",
	   data: "num="+guess,
		   success: function(msg){
		     $("#div2").append(msg);
		     alertmsg = $("#flag").text(); 
		     if(alertmsg=="没抽中哦,再试试吧"){
		      $("#myAlert").attr("class","alert alert-warning");
		      if($("#new").text()=="")
		     	$("#new").append(alertmsg);
		     }
		     else{		     	
		     	$("#myAlert").attr("class","alert alert-success");
		     	if($("#new").text()=="")	
		     		$("#new").append(alertmsg);	
		     }

		 
		   }
		}); 
		$("#myAlert").show();
		$("#new").empty();
		 $("#div2").empty();
	});
});

里面有提到check.php
访问一下
这就是抽奖程序的源代码!我就要看!
在这里插入图片描述

s6n0t7EpGE

<?php
#这不是抽奖程序的源代码!不许看!
header("Content-Type: text/html;charset=utf-8");
session_start();
if(!isset($_SESSION['seed'])){
$_SESSION['seed']=rand(0,999999999);
}

mt_srand($_SESSION['seed']);
$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str='';
$len1=20;
for ( $i = 0; $i < $len1; $i++ ){
    $str.=substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);       
}
$str_show = substr($str, 0, 10);
echo "<p id='p1'>".$str_show."</p>";


if(isset($_POST['num'])){
    if($_POST['num']===$str){x
        echo "<p id=flag>抽奖,就是那么枯燥且无味,给你flag{xxxxxxxxx}</p>";
    }
    else{
        echo "<p id=flag>没抽中哦,再试试吧</p>";
    }
}
show_source("check.php");

给出的公钥s6n0t7EpGE,用公钥推出私钥,私钥是由mt_rand函数生成的
工具php_mt_seed-master可以爆破出种子
然后根据种子就能把公钥换成私钥

先写一个脚本出工具需要的参数
在这里插入图片描述在这里插入图片描述
把得到的结果转换为下面的这种格式

./php_mt_seed.c 18 18 0 61 32 32 0 61 13 13 0 61 26 26 0 61 19 19 0 61 33 33 0 61 40 40 0 61 15 15 0 61 42 42 0 61

因为readme里面有
在这里插入图片描述
使用工具php_mt_seed-4.0
地址:https://www.openwall.com/php_mt_seed/
教程里面说这个工具的用法
别人的图
在这里插入图片描述
我的图
在这里插入图片描述
不知道为什么。。。

到时候出来的私钥之后使用这个脚本

<?php
mt_srand(*********);

$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str='';
$len1=20;
for ( $i = 0; $i < $len1; $i++ ){
    $str.=substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);       
}
echo $str;

?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值