当前位置:网站首页>[wp][gwctf 2019] boring lottery
[wp][gwctf 2019] boring lottery
2022-07-26 04:44:00 【_ Xiao SA】
Feel Online wp Copy each other and write it in an ambiguous way , Just briefly describe my understanding of this problem , If there are any mistakes, please correct them
<?php
# This is not the source code of the lottery program ! Don't look !
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> Luck draw , It's just so boring and tasteless , Here you are. flag{xxxxxxxxx}</p>";
}
else{
echo "<p id=flag> I missed it , Try again </p>";
}
}
show_source("check.php");
Part of the string I got from this question is
UVCRacsLrR
When the seed is fixed ,mt_srand($_SESSION[‘seed’]); The order of random numbers generated each time is also fixed
<?php
mt_srand(111);
for($i=0;$i<5;$i++){
echo mt_rand()." ";
}
echo "<hr>";
mt_srand(111);
for($i=0;$i<5;$i++){
echo mt_rand()." ";
}
?>

Need to use php_mt_seed Tools
Download address :https://www.openwall.com/php_mt_seed/
This tool is to use C Tools for language writing , One of the libraries inside is Windows I don't have any , Recommend to use Linux Direct use . Drag in kali After decompression
tar -zxvf php_mt_seed-4.0.tar.gz
install 
php_mt_seed Use
It's official readme This explains its command line syntax
php_mt_seed On its command line 1、2、4 Or more numbers . These numbers specify mt_rand() Output constraints .
When using only 1 When a number is called , This is the first one to find seeds for mt_rand() Output .
When using 2 When a number is called , These are the first mt_rand() The range the output should fall into ( The minimum and maximum values in this order ).
When using 4 When a number is called , front 2 Give the first mt_rand() Output range , the second 2 Give pass to mt_rand() The scope of the .
When using 5 When calling numbers or more , Each group 4, Then there is the last group 1、2 or ( Usually )4, Handle as above , Each group quotes the corresponding mt_rand() Output .
Or above 111 Generated for seeds
Five random numbers 823157468 1883179200 363074538 648087914 936429611 For example (php7.0)
If you crack Use a number to crack the command :
./php_mt_seed 823157468

Use two numbers ( The two numbers are the maximum and minimum , It is clear here that , So it is 823157468 823157468. The result is the same as above
./php_mt_seed 823157468 823157468
If you use four numbers , The third number is the range , Without setting the range ( mt_rand() There are no parameters in brackets ),64 The default range of bit machines is 0 2147483647
The fourth parameter is the random number generated by the second
./php_mt_seed 823157468 823157468 0 2147483647 1883179200
If you understand these, you can try to write your own script for this topic
mubiao="UVCRacsLrR"
str1="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in mubiao:
n=str1.index(i)
pa="%d %d 0 %d "%(n,n,len(str1)-1)
print(pa,end="")
The number to be output , Copy to command
./php_mt_seed 56 56 0 61 57 57 0 61 38 38 0 61 53 53 0 61 0 0 0 61 2 2 0 61 18 18 0 61 47 47 0 61 17 17 0 61 53 53 0 61
Originally, I still grabbed the bag in the middle , Want to see this question php edition , But I didn't see . But there is only one result here 
php 7.10 Above version 761644156
hold phpstudy Version change 7.1 above , Copy part of the source code , Get the full content
<?php
mt_srand(761644156);
$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;
Output is UVCRacsLrRv1Mj1Frz6e
Online script
str1='abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
str2='c3wBAyqpZM'
str3 = str1[::-1]
length = len(str2)
res=''
for i in range(len(str2)):
for j in range(len(str1)):
if str2[i] == str1[j]:
res+=str(j)+' '+str(j)+' '+'0'+' '+str(len(str1)-1)+' '
break
print(res)
Take a look , I don't understand why I put str1 Upside down , I want to see others , As if str3 It's redundant , these wp Copy each other , I didn't understand , Not worth seeing .
Reference documents :https://www.openwall.com/php_mt_seed/README
边栏推荐
- Comparison of the relationship between the number of partitions and the number of reducetask in MapReduce
- Steam science education endows classroom teaching with creativity
- Yapi installation
- Rman-06031 cannot convert database keywords
- Spark Structured Streaming HelloWorld
- 【UOJ 429】串串划分(Runs)(容斥)+ 有关 Lyndon Tree 及其应用的小小记录
- 九、文件上传和下载
- 2、 Internationally renowned project HelloWorld
- 软考回顾及计划
- 三、@RequestMapping注解
猜你喜欢

Calculate the curvature of discrete points (matlab)

columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql8.0解决办法

Use field parameters for report translation

Integrated architecture of performance and cost: modular architecture

嵌入式实操----基于RT1170 FreeRTOS实现CPU使用率统计(二十四)

Embedded practice -- CPU utilization statistics based on rt1170 FreeRTOS (24)

Ffmpeg video coding

二、国际知名项目-HelloWorld

UE4 displays text when it is close to the object, and disappears when it is far away

Analyzing the curriculum design evaluation system of steam Education
随机推荐
What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep
Vector explanation and iterator failure
2022河南萌新联赛第(三)场:河南大学 B - 逆序对计数
UE4 displays text when it is close to the object, and disappears when it is far away
UE4 通过按键控制物体的旋转
常函数const的学习
How to build an automated testing framework?
User defined type details
Phaser (I): platform jumping collection game
Phaser(一):平台跳跃收集游戏
人脸数据库收集总结
3、 @requestmapping annotation
Stm32fsmc extended SRAM
Compiled by egg serialize JS
「游戏引擎 浅入浅出」4. 着色器
There was an unexpected error (type=Method Not Allowed, status=405).记录报错
mongoDB为什么快
九、文件上传和下载
data warehouse
这种是我的vs没连上数据库吗