primitive password cracker
Bischoop
Bischoop at vimart.net
Thu Jan 7 04:44:13 EST 2021
I was practising for educational purpose with simply password cracker.
I know that I could use itertool but in my case when I'm learning I
would miss facing problems and learning on them and indeed I've met one
which is not giving me a peace.
What I want to learn is if I need get for example four combinations, so
how to get in a loop first letter 'a',then another step'a' and again 'a'
and 'a', to have 'aaaa' later on'abaa' etc.
So I wrote that:
------------------------------------------
import string
passe = 'zulu'
mylist = []
#letters = string.ascii_lowercase
letters = ['a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'w', 'q', 'y', 'z']
mineset= set()
for a in letters:
for b in letters:
for c in letters:
for d in letters:
s = a + b + c + b
mylist.append(s)
mineset=set(mylist)
k = sorted(mineset)
print(k)
for i in k:
if i == passe:
print('got it: ', i )
print(passe in k)
--------------------------------------
It works in someway but the problems are:
Not all combination are made, I change password to: 'pass' and that combination is not in results.
Another thing is, I had to made a set from list because combinations
were repeated.
And finally, I was struglling with making it in without creating four
loops for four letters, something like that:
To try to solve those I went with that approach:
-------------
letters = ['a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'w', 'q', 'y', 'z']
password = 'pass'
combin = ''
lista=[]
for x in range(4):
for y in letters:
combin +=y
lista.append(combin)
combin=''
mineset=set(lista)
print(mineset)
for i in lista:
if i == password:
print('pass:', i)
-------------------
But the results are disspainting:
{'abc', 'a', 'ab', 'abcd', 'abcde'}
I was seating on it for a long day but can't even closely achieve
similar effect to 4 loops in previous code.
--
Thanks
More information about the Python-list
mailing list