随机数种子爆破

做了道题叫枯燥的抽奖,当初面试 V&N 的时候师傅推荐的……学到了新的七里八里的知识

工具:php_mt_seed

生成工具的 Inuput 格式处理:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
rand_str = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
r = 'xxx'

S = ''

if __name__ == "__main__":
for i in range(len(r)):
if i <= len(r) / 2:
for j in range(len(rand_str)):
if r[i] == rand_str[j]:
S += str(j) + ' ' + str(j) + ' ' + '0' + ' ' + str(len(rand_str) - 1) + ' '
break
else:
for j in range(len(r)):
if r[i] == rand_str[j]:
S += str(len(r) - j) + ' ' + str(len(r) - j) + ' ' + '0' + ' ' + str(len(r) - 1) + ' '
break

print(S)

得到 seed 之后生成完整字符串:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
mt_srand(xxxx);

$rand_str = "xxxxxxxxxxxxxxxxxxx";
$r = '';

$len = N;

for($i = 0; $i < $len; $i++) {
$r .= substr($rand_str, mt_rand(0, strlen($rand_str) - 1), 1);
}

echo $r;

From:堆堆
记得注明出处嗷


评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×