-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_leaks_solver.py
51 lines (43 loc) · 8.01 KB
/
login_leaks_solver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
All three letter segments are part of the password and are guaranteed to be in order
but not necessarily consecutive. There are no repeated characters in the password.
Solution: build a dictionary of all the letters and their relative position to one another.
As we scan through the words, if a letter is behind another, its position is set to be
behind that letter. All letters which are behind the original letter are also decremented.
This gives us each letter's relative position to one another. If there were enough
word samples, this will be enough to reconstruct the entire password. If not,
the password will be printed with '/'s inbetween letters the program is
unsure about.
"""
WORD_LENGTH = 3
words = ["$zq",">W_","(^}","9z}","A-R","*z2","<Af",">q_","-e6","9$e","_26","&Z6","<-6","*W&","_&Z","<zd","{!R","96d","<nf","<nL","!f}","!Lf","(W^",">*f","<qf","<!A",">eL","R6}",")Wz",">96",")_R","A2^","-(&","*W6",")_^","{(e","A)f","A$z",")Rd","!L^","&Zd","e&6","&6d","<6^","!A(","9nq",">z6","A(L","{zL","*^}","!*f","<*f",")6}","!&R","nq}","nW2",">$^","A(W","$zR","e_2","W6}","(z^","-_&","{n&","!qd","<ZR","(zq","eW_","n)R","<9W","{ZR","!)(","Wz^","LR^","L2}","{nq","!(*","(q&","<(}","L&d","ezZ","*fR","9_^","{n)","Wq6","A*q","9WZ","<f}","{W}","-_}","<z_","f6}","$Wq","&f}","-W^","<n2",">_}","nW_",">e_","!A)","n$6","{z_",")f2",">Wq","$f^","A9}","(q6","_&2","A(6","(eW","A*^","zq}","{z6","{&^","A^d","!-R","-q^","nR6",")fR","eZ}","LfR","*f2","<fd","2R6","!(}","!9d",">A)","<nZ","!2}","9(R","{-L","$(f","$2}","n(e","-Wd","9&6","W_^","Af^","AR6","-Rd","nWL","qf6","(zL","{zZ","LZ2",")(e","qfR","n)d","{z6","{!*","nzd","9q&","-6d",">_6","$(&","9LZ","L6d","9z&","q_2","<(f","-(R","A$_","!A_","{_&","R6d","!nd","-z_","$q2","&d}","9)R",")eW","n)&","Ae_","{>d","nLZ","{-d","!L_","e_Z",">L2","-)W","9(W","><f",">(_",">6^","$W6","<(_","!&^",">6}","{-_","!$L","*d}",">eW","<9L","!W_","{nL","A9W","Wq_","$fd",")(L","9)}","9Zf","9&2",">)(","A9q","!e6","-(f","n$*","!)e","{WZ","<z_","{A)",">(6","nWd","!n)","&Z2","9_R","*q^","-zR",">9e","9)Z","{!}","9-_","!A_","eqR","*_2",">9e",">*_","(L&","-zL","(LZ",">*R","n*z","ez&","{<_",">!-","{f6","n2d","L_&",")z2","WL&","9&Z","-q2","A(R","!q6","{)z","{)f","nR}","Wf2","$)Z",")26","{>L","_&}","(&f","$(d","f6^","nf2","(eW","{n}","*z6",">*W",")W}",">96","<WZ","(ed","An)","$(f","2Rd","<)&","-eW","{*L","ZR}","<)(","<!^","{LZ","<Wf","<A$","$*f","-nq","9Lf","nzq","*Z}","A)e","Wzf",">AR","(Wz","q26",")e^","A-*","A_^","<n&","{-q","-$z","9_R","!$L",")(z","fRd","<_d","{q6","{9^","{!}","&fd","z2R","*z}","eLf","{d}","L^d","n*W","<ZR","9(R","9ed","!fR",">WR","q_2","&Z2","{>6","n*&","{>$","nzR","(z2","><f",")&2","e&d",")f}","{!}","{Az","Aez","<A)",">)z","!)*","A-_","6^d","A-$","e^d","><f","{!&","(z6","{!A","<qd","$(Z","Zfd","AR6","n)f","nq6","AnR","!AZ","A-Z","Wzd","A(&","9-f",">*z","-(f","$(e",">Z2","WL&","<fR","A&2","Z2R",">fd","9_Z","<2^","$^}","qZ^","(*2","ne&","!WL","n$)","e2}","9e}","n*_","Af6","f2R","_d}","<e&","n(Z","-*_","-zq","!&2","A-L","<Wf",">z}","L6d","9)R","<Zd","-q6","!-Z","{)d","_Zd","*ZR","9_6","qR6","!9)","$)z","n)*","(^d","WzL","-n6","n$^","<*6","z&}","n$6","!qZ","{qd","W^d","f^}","-6}","!(*","A(_","{6^",">n&","*L6","AR}","9*z","<nd",">W^","-W2","$)R","!e}",">f2","-2^","q2d","&2R","eZR","!Wf",">(^","9(e","-_^","A$L","Zf2","And",">z2","-nd","!Ld","9_^",")R6","!$R",")q2","A)e","9)2",">)6",">$2","{9$","n$}","$eq","-n)","$)W","!-n","(Rd","{>^","<A&","-n&","$_&","ezR","!e2","(L}","!e_","<W^","!9d","<n&","-)W",")^d","!LZ","!Wq","!L^","9(2","!q2","A)}","!)2",">L_","!)R","{ef","{&2","{q_",")Z2","$&d","$2^","z_f",">$}","A(L",")&R","&Z6","<_&","ne2","<-W","zZ2","!AW",")&6","A-L","-)f",")W}","(WR",">A-","9)2","<9L","_&6","eRd","<_f","{(f","<_}","><2","eL^","9ef","!n(",">zZ","q&Z","9e}","e*z","$e*","$zL","L6d","-)2","AW&","<!L","n6}","A-n","*L&","L2d","-^d","*6^",">-}","!(&","A-R","e&f","A_d","$L^",">-6","AnW","$eR","-e_","{WR",">z2","-$}","*_2","$qR","!Af",")WZ","9e*","!Ad","<-Z",")WR","{>d",">)^","<&R","-ez","$e*","{LZ","!)d","{_2","<!R","(*^","AnL",">9*","!q2","9(^","n*f","*q2","$qR","$R^","A*f","!9Z","eL_","nef","qL^","n$(","A-2",">!9",">nf","9W&","{$^","><A","_d}","*6^","$zq","!n*","<_&","A-$","$Wq","!n*","-q^",">qd","q^d","nef","WR^","9WR","{*^","<e&","n*z","$q2","$qR","_R^","L&Z","*WZ","<nz","<(6","$q_",">_^",">!d","<!*","e_}","!*W","AL_","-e6","(_Z","{6d","(Wd","q2R","A-q","!ne","!A6","{(*","WZ^","e26","<qd",")ZR","{A$","!A2",">!n",">L}","-$L","nq^","n(^","<$*","{6d","<9$","A2R","-)2","nL6","And","e6^","Wqf","92R","{9$","9n(","{f^","*^d","<-z",">-$","!)}","$q2","-*d","A-n","<(f","A-^","nWZ","*26","{<(",">f6",")qZ","eL^","9)^","(6^","<W6","q&2","nW^","!L2","(e_","{_f","n_f","<e_","n$L","!-e","9*Z",">)z","zfd","A$)","9)}","Wqd","L&}","*zR","$&^","<zf","{eL","*Rd","n$*","Wq}","{WZ","{e}","Ae6","qd}","_26","{_d","WL_","(6^","9W_","-q}","&R^","<eR",">2d","9_R","6^d","{Wf","-R}","><z",">LZ","<$f","-n$","<9W","n)_","(Wf","{&2","eZf","!R6","W&d",">(e","f6d","!92","e*d","(ef",")(^","{Wq","{<R","A2^","n*f","fd}","9$d","!e_","&f}","<)6","zZ2","-e}",")eL","9L2","-R}","A_R","{>2",">^}","n(6","&f^","<!_","z&Z","$e2","<9}","9nz","9WL","Az6","-(}","zLZ","9(f","(e_","A)(","n(W","9$d","f6}","AeL","<-)",">AW",">A}","!(6","(L2","!96","9(6",">!Z","-&^","$&f","An_",")e2","!e*","!)^","><A","n*2","!9W","><L","*qZ","!qd","*^d","zLZ","e_^","-W6","-2}","$(R","9fR","!&^",">)_","zLf","z26","(e2","<WL","f6}","n)d","A&f","ne&","e_d","$f^","*6^","9)L","!zL","-(W","e*W","A-6","nzR","!W2",">)e",">qL","(fR","{9Z","A)Z",">*}","!-Z","{>z","An$","q&f","neW","A26","ZR6","(q^","AeL","A*d",">(d","q_&",">AL","qRd","WR^","!9z","!)(","zZ^","9*L",">-q","<*W","e2}","$)q","{!}","e&6",")Wz",")_}","<zd","n*2","!-Z","!(2","!nd","<*f","{>_","A*d","!-^","-)R","-)R","!-L","!)Z","9z2","(z6","92d","-)e","9)}","$2^","{*_","WZf","n$}","9qZ","<9f","9(W","nd}","-)(","n(Z","><z",">$e","9-Z","!9q","9e_",">zf","9-d","<zR","<!z","(Lf",">^d","*WZ","{)f","!$(","9-)","zR^","!W^","<-^","{R^",">f6","*W^",")z6","$)^","!nq",">-}","nWL","<eW","-qd","!&^",">-R","q_6","!L}","WZf","!-f","<(e","zL&","Wz6","<)L","-ZR","{>R","!f^","-*d","(fR",">-&","$6d",">n)","nz_","-$q","<)z","9W^","<!e","ezZ","$)q","A(W","*zf",">9(","Az}","-_&",")f^",">)R",">!R","*W^","9(Z","{!d","A)d","{9^","{9&","<&2","9Wd",">9)","(W2","$)2","{)(","{<(",">n&",")&d","_2}","!-e","{*R","AL&",")Lf",")2R","n$Z","$Ld","Ae6","Aeq",")(2","!W^","L6}","A$&",">96","WzZ",">$f","*f2","A)(","<zR",")26","e*6","-R^","zq}","9)&","n)2",">AZ","$_f",">!_","9-(","!A^","*q^","<eZ","9Z2","-_6","!ed","{A&",")WR","*26","{$2","!6^",">9(","AzR","!9}","9_f","<Aq","{-Z","{(*","2^d","(Wf","AZ}","zf2","<$z","-*&","9*W",">n_","{<9","!*L","Lf}",">-d","*W}","AnW",">9f","{9)","q_^","{*W",")fd","q6}","<WL","_d}",">$}","9nz","{L6"]
letter_pos = {}
if __name__ == "__main__":
for word in words:
for i in range(0, WORD_LENGTH):
if word[i] not in letter_pos:
letter_pos[word[i]] = 0
# scan word
for j in range(i + 1, WORD_LENGTH):
if word[j] not in letter_pos:
letter_pos[word[j]] = 0
# if letter in front has smaller position in dict, make current letter's
# position smaller than the letter in front.
if letter_pos[word[j]] <= letter_pos[word[i]]:
letter_pos[word[i]] = letter_pos[word[j]] - 1
# decrement positions of all letters behind current letter as well
# to keep relative positioning
for letter in letter_pos:
if letter != i and letter_pos[letter] <= letter_pos[word[i]]:
letter_pos[letter] -= 1
# print letters based on their positions
printingList = {}
for letter in letter_pos:
if letter_pos[letter] in printingList:
printingList[letter_pos[letter]].append(letter)
else:
printingList[letter_pos[letter]] = [letter]
for num in sorted(printingList.keys()):
print(f"{num}: {printingList[num]}")
for num in sorted(printingList.keys()):
print(*printingList[num], sep = "/", end = "")