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

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

[root@oldboy work]# cat stochastic.sh

#!/bin/bash

##############################################################

# File Name: stochastic.sh

# Version: V1.0

# Author: HU JIN SHENG

# Organization: www.oldboyedu.com

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

# Description:

##############################################################

. /etc/init.d/functions

declare -a array

for i in $(seq 0 32767)

do

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

done

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

action "mate" /bin/true

for key in ${keys[@]}

do

for i in `seq 0 32767`

do

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

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

action " " /bin/true

fi

done

done

原文链接:https://www.f2er.com/bash/389874.html

猜你在找的Bash相关文章