: Python3 Tkinter Requests: Temporary locking in get ('url') with the requests!

-2

This is the following I created a script to 'decrypt' md5 hash, but when I enter Entry 21232f297a57a5a743894a0e4a801fc3 that is admin and is contained in wordlist, it hangs every time it reaches the b=get(f'url').content.decode().split() line in the window. tkinter is locked until the request is complete, that is, until you play the wordlist in the variable, you have to wait for the request without the window to hang ..

from hashlib import md5
from requests import get
from tkinter import Button, Entry , Label , Tk ,END
root=Tk()

def test():  
    a=str(decry.get()).strip()
    if len(a)==32 or len(a)==40 or len(a)==64 and a.isdigit()==False and a.isalpha()==False and a.isalnum()==True:
        pass
    else:
        return
    c=0
    url='https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt'
    b=get(f'url').content.decode().split()
    while(True):
        root.update()
        if str(md5(b[c].encode()).hexdigest())== a:
            decry.delete(0, END)
            decry.insert(0, b[c])
            but["text"]="Decrypter"
            break
        else:
            c+=1
            if c==len(b):
                break


root.geometry("390x120")
root.resizable(width=False, height=False)
root.title("Decry(hash(num)) v2.0")
lab1=Label(root, font="Arial 9 bold" , text="\n(Md5, Sha1 , Sha256) Todos os direitos reservados a Code Ghost.")
lab1.pack()
decry=Entry(root, width=40,font="Arial 12 bold")
decry.pack()
but=Button(root, text='Decrypter', command=test)
but.pack()
root.mainloop()
    
asked by anonymous 25.10.2018 / 15:18

1 answer

0

The problem is that this single line makes the request and downloads the whole file, so tkinter does not have time to update the interface, because it takes a long time without calling root.update() .

One way to mitigate this problem is to download the file line by line instead of downloading it all at once. Change the code of the locking line to the end of the test() function for this code:

with get(url, stream=True) as r:
    for word in r.iter_lines()
        root.update()
        word = word.strip()
        if str(md5(word.encode()).hexdigest())== a:
            decry.delete(0, END)
            decry.insert(0, word)
            but["text"]="Decrypter"
            break

Another advantage of this method is that, by finding the word you want, it will stop downloading the file, saving time and network.

    
25.10.2018 / 17:19