2016-03-16 46 views
-2

我想在python中創建一個笑話密碼破解者。簡單來說,它會做的是創建從感嘆號到空間的所有字符組合。它會自動打開記事本,並在五秒鐘(當記事本已初始化)做pyautogui魔術來模擬按鍵寫行記事本。目前,我有這樣的代碼python中的笑話密碼破解者

import pyautogui, time, subprocess 

pyautogui.PAUSE = 0 
subprocess.Popen("notepad.exe") 
time.sleep(5) 

for n in range (1,3): 
    for i in range (33,127): 
     pyautogui.typewrite((chr(i))*n+"\n"*2) 

,但它產生的:

! 


" 


... 


}} 


~~ 

我需要的不過是

! 


" 


... 


~} 


~~ 

能有人回覆了我如何產生的每組合字符?謝謝! P.S.我正在使用python 3.5。

+0

這是一個笑話? – wim

+0

不,我只是想創建一個程序,它只是打印出所有組合的最高certaion值。它只是叫做joke_password_cracker.py –

+0

這應該如何工作?你如何期待'chr(i)* n'輸出兩個不同的字符? – DaveBensonPhillips

回答

1

如果你想找到的組合,使用itertools模塊:

>>> from itertools import combinations_with_replacement 

>>> a = combinations_with_replacement(map(chr, range(123,127)), password_length)) 
>>> list(a) 
[('!', '!'), ('!', '"'), ('!', '#'), ('!', '$'), ('!', '%') ........ 

有樂趣等待它完成時password_length得到的最小長度周圍大多數口令:)

+0

這是什麼:回溯(最近呼叫最後): 文件「D:\ My文件\ python \ pyautogui \ joke_password_cracker.py「,第9行,在 pyautogui.typewrite(a) 文件」C:\ Python35 \ lib \ site-packages \ pyautogui \ __ init__.py「,行961,打字 c = c.lower() AttributeError:'元組'對象沒有屬性'lower' –

+0

啊,我明白了,很抱歉再次打擾你。 –

+1

使用'('.join(i)for i in a)'將'a'轉換爲您想要的格式(可迭代的字符串) – DaveBensonPhillips