首页 > 代码库 > perl实现可打印字符加法(ascii:32-126)

perl实现可打印字符加法(ascii:32-126)

#!/usr/bin/perl -w

sub add_32to126{
        my $word = $_[0];
        $last_char_num = ord(substr($word,-1,1))+1;
        if($last_char_num == 127){
                chop($word);
                if($word eq ''){
                        $word .= chr(32);
                }else{
                        if(substr($word,-1,1) eq chr(126)){
                                $word = &add_32to126($word);
                        }else{
                                $word .= chr(ord(chop($word))+1);
                        }
                }
                $word .= chr(32);
                return $word;
        }else{
                $word .= chr(ord(chop($word))+1);
        }
}

$pass = ' ';
while(1){
        print "|$pass|".$/;
        $pass = &add_32to126($pass);
        #sleep (1);
}


可以用来爆破。

输出如:

|!ZS|
|!ZT|
|!ZU|
|!ZV|
|!ZW|
|!ZX|
|!ZY|
|!ZZ|
|!Z[|
|!Z\|
|!Z]|
|!Z^|
|!Z_|
|!Z`|
|!Za|
|!Zb|
|!Zc|
|!Zd|
|!Ze|
|!Zf|
|!Zg|
|!Zh|
|!Zi|
|!Zj|
|!Zk|
|!Zl|
|!Zm|
|!Zn|
|!Zo|
|!Zp|
|!Zq|
|!Zr|
|!Zs|
|!Zt|
|!Zu|
|!Zv|

。。。

perl实现可打印字符加法(ascii:32-126)