我们以前把文本加密成二进制的内容,那如果要把加密的二进制还原成相关的ASCII码,是不是也能用shell脚本来实现呢?答案是可以的。 举下解码的实际例子: 二进制的内容为:010010000110010101101100 011011000110111100101100001000000111011101 解码后的ASCII码为: 10111101110010011011000110010000100001
该shell脚本(generate-wordlist.sh)的代码如下:
#!/bin/sh # http://hektor.umcs.lublin.pl/~mikosmul/computing/shell-scripts/decode-binary # Written by Michal Kosmulski <mkosmul _at_ users _dot_ sourceforge _dot_ net> # This script is hereby put in the public domain. # # Decode ascii text written using binary digits into human readable form. tr -d ' \n#\t' | ( while read -n 8; do character=`echo -e "ibase=2;obase=1000;$REPLY\nquit" | bc` echo -ne '\'$character done ) |