Show HN: Cracking passwords with a simple genetic algorithm
github.com
github.com
One of the examples apparently takes a list of leaked passwords from MySpace - and so what does it "crack" then? I think the phrase "high impact substrings" down in the explanation is the key, but it's not wholly clear to me what the ultimate purpose of this is.
The 'GA without a fitness score' idea seems interesting, but it would help to know what exactly the algorithm is trying to do.
"what is the input and output of this at a conceptual level?" Our input is the dataset we want to crack, and our output is the passwords that were successfully cracked. In a more conventional scenario, we would have a list of hashses that need to be cracked. So the steps are
1. pick parents at random
2. crossover and maybe mutate
3. hash the child
4. see if the hashed child exists as a password in our list of hashses we want to crack
5. if it does, add the child to the end of the container and pop the oldest organism from the front.
6. goto start
Like substrings "pass" and "word" in "password".
it will genetically run through all ngrams and check if it is in the pass list to determine how to advance the evolution of the algorithm
does this crack passwords genetically? well, yes and sorta
it's a proof of concept against an existing list of real leaked passwords, proving that it could efficiently crack a number of these real passwords real people were using to protect real personal data
but from there you have to extrapolate the effectiveness on all possible passwords..
if you train against the myspace list then the passwords would have to resemble myspace passwords
can you train the algo on the myspace list then try to crack nuclear codes? very unlikely, unless government officials are protecting their access with passes like 'WARMACHINEROX'
I chuckled, imagining how some government official changes his password right now.
Also, for some reason I thought you actually used a LIFO stack. So, what if you did? My guess is organisms that put more offspring on the top of the queue would take longer to be popped from it, so that they'd have a better chance to produce more offspring. They would also benefit from organisms almost as successful as themselves (but not more).
Is this also a known approach, and if so, how well does it work?
Regarding the stack approach, I would suspect that new genetic information would immediately be lost since a new organism dies before having much chance to produce offspring. In the off chance it manages to produce offspring, those offspring would also be lost almost immediately since they get popped first.
If you are really curious, you can change line 163 in vivarium.cpp from a pop_front() to a pop_back() to see what happens.
I am indeed very curious, but also very, very short on time! Before I can justify picking up someone else's code I have a couple of pieces of coursework and a dissertation to work on - but I might get some time round abouts next weekend, I'll let you know how I get on :)
I'll still try to give your code a whirl next weekend. I know how useful it is to get some feedback for your projects.
Especially if you were to feed the training set with most-used password lists from leaked databases or similar.
Do you have any performance metrics against bruteforce for example?
I have not put them head to head, but the program seems to find passwords that are far outside the tractable search-space for a bruteforce attack. Passwords like the following are found withing a few hours:
34 a111111111111111111111111111111111
20 12345678900987654321
19 9876543211234567089
19 password12345678910
18 sexytinkerbell2013
18 prettyprincess4812
18 mickeymouseforever
18 littlepinkprincess
18 iloveyoumomforever
15 strawberryhorse
15 ilovehorses1995
15 ilovehorses1994
15 ilovehorses1234
15 horselover4ever
xkcd style passwords are actually called diceware passwords [1], the wikipedia article [2] links to arstechnica that reported in 2014 [3] that the original author upped his recommended diceware password length to at least 6 (random) words.
You can obviously always use a bigger dictionary too (as long as you choose truly random).
[1] http://world.std.com/~reinhold/diceware.html funny enough, chromium doesn't like the ssl versions the site uses "ERR_SSL_FALLBACK_BEYOND_MINIMUM_VERSION"
[2] https://en.wikipedia.org/wiki/Diceware
[3] http://arstechnica.com/information-technology/2014/03/dicewa...
let's say you have a pad lock with a 4 number combination, each of those numbers being a ring of 6 numbers themselves(o)
we have four 'slots' with six possible numbers for each slot
that means there are a total of 1296 combinations, (possible values)^(slots), 6^4=1296
a contemporary computer can do 1300 calculations perceptually instantaneously
now we look at randall and diceware's suggestion of using a series of words to bulk out your password, since a word in english is built of a possible combination of 26 character alphabet the possible values becomes 26
for a four letter word, all possible combinations of those 26 characters becomes 26^4=456,976 possible combinations, again, all values can be computed in nanoseconds
what i think randall and diceware is hoping to achieve is a higher permutation value with little tax on the user's memory
conceptually [c,o,r,r,e,c,t,h,o,r,s,e,b,a,t,t,e,r,y,s,t,a,p,l,e] is 25 characters long with each 'slot' having 26 possible combinations.. 26^25~23x10^34, that is a huge number of possible permutations which makes brute forcing finally impractical
but here is where the whole thing starts to break down a bit..
because the suggestion is to use real words to aide in remembering which negates character length in lieu of number of words
that also means that figure above is significantly less because the first in that list of 456,976 permutations is ['a','a','a','a'] which would be invalid in regard to existing words, so in reality that 450,000 figure is significantly less
'correcthorsebatterystaple' can be broken into 25 characters 'slots' or 4 word 'slots': [correct,horse,battery,staple]
what was 26^25, is now (possible words)^4
we can keep going, look at randall's most recent book(i), using the 1000 most used words
possible words becomes 1000 and 4 slots we are looking at 1000^4=1,000,000,000,000 possible permutations
which will take a contemporary laptop a few hours, respectively, to churn out
all this broken into a chart:
81 = 3**4 : [(3),(3),(3),(3)]
253 = 3**5 : [(3),(3),(3),(3),(3)]
256 = 4**4 : [(4),(4),(4),(4)]
456976 = 26**4 : [(26),(26),(26),(26)]
1000000000000 = 1000**4 [(1000),(1000),(1000),(1000)]
~230000000000000000000000000000000000+ = 26**25 : [(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26),(26)]
~640000000000000000000000000000000000000000000+ = (26*2+10)**25 : [(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62),(62)]
what this is showing you, is that anything that makes things easier for you also will make things easier for a crackerfor best security increase the number of characters when possible avoiding words.. using a combination of lowercase(26 characters) and upper case(26 characters) and numbers(0-9, 10) for 26+26+10=62 possible values.. and put those characters in as many slots as you can muster
(o) http://www.padlocks4less.com/media/catalog/product/cache/1/i...
You've made a mistake here:
> 'correcthorsebatterystaple' can be broken into 25 characters 'slots' or 4 word 'slots': [correct,horse,battery,staple]
> what was 26^25, is now (possible words)^4
1) No-one suggests using 4 words. Randall uses 4 words because it fit in the cartoon. Diceware suggests using 6 words for minimum.
2) No-one at all suggests using just the 1,000 "most common words". Diceware is a list of 7776 words. Except there's more than one diceware list.
why explain away the comic as just being an example but then confront the comment as being unaware?
why did i use 4 word 'slots' instead of diceware's suggested 6 minimum? because the comic did and that was referenced in the gp
why did i use 1000 words instead of diceware's 7776? because the number of words is arbitrary for an explanation, and, as i stated, i was playfully referencing, and intentionally promoting, more of randall's work
your comment fails to negate anything in my explanation, which was meant as a means of explaining how to think about these things
what the effectiveness of the ga cracking repo shows is that people are using even less possible words than dice's 7776 or randall's 1000
and the concluding statements that more variety with less patterns equates to better security stands
> The complete list contains 7776 short words, abbreviations and easy-to-remember character strings. The average length of each word is about 4.2 characters(o)
i'll be kind and round that 4.2 up to 5
> Diceware suggests using 6 words for minimum
so we are looking at 6 words of 5 characters.. 30 total characters
let's compare diceware to individual characters:
~220000000000000000000000+ = 7776**6 : diceware with 6 word minimum
~800000000000000000000000000000000000000000+ = 7776**10 : diceware with 10 words
~2800000000000000000000000000000000000000000000+ = 26**30 : english alphabet, 30 characters
>what this is showing you, is that anything that makes things easier for you also will make things easier for a crackerYou need to look at bits of entropy.
A 6 word passphrase is about the same as a 12 character password if you use any printable ASCII character.
i then went on to establish those values as being only those in the english alphabet, 26 characters, stead your referenced ascii set or even the diceware character set which allows some special characters
then i took the minimum suggested diceware length of 6 words, rounded the average word length of 4.2 up to 5, which gives us 6*5=30 characters
so one diceware password example:
affixafireafootagainagateagave
can be seen as diceware would have it, 6 words of length 5:
[affix, afire, afoot, again, agate, agave]
or 30 individual characters:
[a,f,f,i,x,a,f,i,r,e,a,f,o,o,t,a,g,a,i,n,a,g,a,t,e,a,g,a,v,e]
so utilising any underlying pattern, here only using the diceware wordset, weakens a passphrase of equal lengthor if you want to abstract away from the actual values that you use to determine a passphrase's strength you could say: diceware lowers the entropy of an individually random value passphrase of equal length
but that phrase unecesarily contains verbage that can confuse whereas my previous comment showed all of the number possible permutations in such a way as to easily see that one is greater than the other making the guess space larger
I ran 2 experiments each lasting 120 seconds.
For the diceware list as a seed population it finds 4570 passwords. The 6 longest ones are:
11 michelle420
11 karen123456
11 iloveyouu16
11 iloveyou789
11 iloveyou234
11 iloveyou191
For the top 2000 ngrams from the rock_you list(which is the current list used) it finds 5317 passwords. The top 6 longest passwords are:
14 fuckyouhackers
13 fuckyouhahaha
11 sexylove889
11 scooter1234
11 princess123
11 iloveyouu16
I think it's wrong to say you don't have a fitness function. Your fitness function is "Is this string a password?" and the score is binary. Why do you say there is no fitness function?
Also, in your examples, is "aaaaaaaaaaaaaaaa" really a password?
With regard to the fitness function, I think I agree with you that checking if the offspring matches a password will fall in the category of a fitness function albeit a binary one. I will update my description to include that, thanks.
With regard to if it is useful, I will let it stand or fall on its own merits. If people are going to use it to find bad passwords, then I would say yes it is. It might be pertinent to mention that I am interested in genetic algorithms in general and this is a good practical way of exploring my own theoretical ideas.
Yes, "aaaaaaaaaaaaaaaa" really is a password. Have a look at the rock_you list of passwords and sort them by length. There are some extremely long but silly passwords in there.
When I asked how useful this was, I assumed the organisms were removed from the front of the list. If you keep everything, then yes I can see how this can be used to crack passwords. It's not clear to me how it would be useful otherwise, as which organisms stay in the list is not homogeneously random, and so one organism might be quite unlucky (even though its offspring could have been very successful).
So basically this can be viewed as an accelerated brute-force of long/complex passwords?
This looks awesome, but without the GPU speed advantage I'm not sure how well it'll fare against the almost 80GH/s I can do on my desktop with cudahashcat.
It might be interesting to note that the older versions of hashcat seems to have supported reading candidate passwords straight from stdin. I have not played with that yet, but I suspect it might work a bit better.
[1] The stack is used in place of an explicit fitness function. I have nothing against fitness functions. But the bit about using a short stack instead, is really cool.
Edit: Woa. Hang on. New organisms are pushed to the back of the structure while dying ones are popped off the front- so that's a queue. My bad. But I still like it.
I would be interested to hear what other kinds of problems you see it being used for.
And is it really moral to do this? The only applications of this are pretty unethical.
As for the moral argument, even though this has probably been discussed at many different venues on many different occasions, I lean toward the sentiment that having good tools to gauge how good your password policies are is essential. Not to say that this is a good tool, but it is _a_ tool.
You can look at the section "How it work" on my github page for some diagrams and a decently lengthy description.
In simple words: Each organism is a password(a string). Passwords can mix(have sex) with each other in novel ways to produce offspring. If the offspring(a mix of the parents) also matches a password, it is added to the list of organisms. Older organisms eventually die, so it is up to the offspring to keep producing offspring in order to preserve the genetic line. The result of this simulation is that high impact substrings like "love", "luv", "mother" and "fuck" stay for a very long time in the genepool since any organism that consists of at least one of them will have a better chance to produce a child that is a password(viable offspring).
If you still don't understand, feel free to ask more questions.
1. Finds the substrings that are popular in passwords. 2. Combines them to make likely passwords that haven't been tried yet. 3. Rinse and repeat
Useful against noob passwords - of which are there many in the wild - and more effective for some applications than the usual dictionary search.
But ineffective against randomised strings like KPF27k5ANv791P2Yi88xd88D7iALX3kH, or against XKCD random word salad passwords like QuantumGerundApoptosis as long as they include at least one unusual word.
[1]: http://www.genetic-programming.com/#_John_Koza%E2%80%99s_Pub...
i noted in another comment that this ga cracker repo will only work on passes that resemble the ones it is trained on, but like all genetic algos is aggressively ineffective on inputs resembling anything else
as for programming the practice, it is embarrassingly redundant and consistent due to the structure of programming being based on grammars and logic
so imagine a program that has a data set
you need ten bits of information about that data set, like max, min, mean, etc..
so you write 10 individual functions to loop over the data and interpret it
that is all very consistent behavior and code
now imagine you write a simple genetic algorithm that can interpret your interests and write those simple loops for you on the fly
ten functions of 10 lines each is 100 lines of code
one function of 30 lines that can generate then discard those ten previous functions gives your program a 70 line and immeasurable man hour advantage
think if a search engine needed an engineer to explicitly write the discovery function of every possible query, it would be impractical, so instead you imagine generalisations that permit simple functions to take many varying inputs and produce many varying outputs
what i think the parent comment is suggesting is that these generalisation functions themselves could be built by computers and one possible method being genetic algorithms
furthering the abstraction
all puns intended
For example (as I noted in private communication to John Koza) exploring the protocol-space of distributed consensus algorithms on top of something like Microsoft Research's IronFleet (with the GP generating Gafny code) appears to be both possible and imo a fruitful avenue for researchers in the field.
[p.s. Note that Genetic Programming is distinct from Genetic Algorithms.]