企业Shell面试题18:破解RANDOM随机数案例

前端之家收集整理的这篇文章主要介绍了企业Shell面试题18:破解RANDOM随机数案例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

[root@oldboy work]# cat stochastic.sh@H_502_1@

#!/bin/bash@H_502_1@

##############################################################@H_502_1@

# File Name: stochastic.sh@H_502_1@

# Version: V1.0@H_502_1@

# Author: HU JIN SHENG@H_502_1@

# Organization: www.oldboyedu.com@H_502_1@

# Created Time : 2017-11-02 00:33:57@H_502_1@

# Description:@H_502_1@

##############################################################@H_502_1@

. /etc/init.d/functions@H_502_1@

declare -a array@H_502_1@

for i in $(seq 0 32767)@H_502_1@

do@H_502_1@

array[$i]=`echo $RANDOM|md5sum | cut -c 1-8`@H_502_1@

done@H_502_1@

keys=([0]=21029299 [1]=00205d1c [2]=a3da1677 [3]=1f6d12dd [4]=890684b)@H_502_1@

action "mate" /bin/true@H_502_1@

for key in ${keys[@]}@H_502_1@

do@H_502_1@

for i in `seq 0 32767`@H_502_1@

do@H_502_1@

if [[ "${array[i]}" = "$key" ]]; then@H_502_1@

echo "破解成功" "密码:"$i------$key@H_502_1@

action " " /bin/true@H_502_1@

fi@H_502_1@

done@H_502_1@

done@H_502_1@

猜你在找的Bash相关文章