【问题标题】:How to loop through the alphabet until it finds a word如何遍历字母表直到找到一个单词
【发布时间】:2023-03-17 13:21:01
【问题描述】:

我想编写一个 bash 脚本,它读取文件中的一个单词,然后尝试遍历字母表,直到找到该单词。这是我到目前为止编写的代码,但我不太确定从这里做什么,任何帮助将不胜感激。

maxlen=5

while -r file; do

for i in {a...z}; do

done 

done < ~/textfilelocation

所以基本上作为家庭作业的一部分,我应该尝试使用所有可能的字符组合对密码文件进行暴力攻击,我们假设它都是小写英文。

【问题讨论】:

  • 简而言之,您是在检查从文件中读取的单词是否具有特定模式?
  • 不知道你在这里问什么。为什么它会遍历字母表来查找单词?字母表包含字母而不是单词。
  • 所以基本上作为家庭作业的一部分,我应该尝试使用所有可能的字符组合对密码文件进行暴力攻击,我们假设它都是小写英文。

标签: bash unix


【解决方案1】:

我在这里留下了一些东西让你完成-

while read -r file; do
  for i in {a..z}; do
    for j in {a..z}; do
      for k in {a..z}; do
        for l in {a..z}; do
          for m in {a..z}; do
            word="$i""$j""$k""$l""$m"

            *set up an if condition to check if $word matches the test word*
            *break out of the loop if yes*

          done
        done
      done
    done 
  done < ~/textfilelocation

【讨论】:

  • word=$(echo "$i""$j""$k""$l""$m")?严重地?那太糟了!请改用word=$i$j$k$l$m。此外,您可能在 while 语句的某处错过了 read
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-15
  • 2019-03-08
  • 1970-01-01
相关资源
最近更新 更多