I am about creating a distributed Password Cracker, in which I will use brute force technique, so I need every combination of string.
For the sake of distribution, Server will give Client a range of strings like from "aaaa" to "bxyz". I am supposing that string length will be of four. So I need to check every string between these two bounds.
I am trying to generate these strings in C. I am trying to make logic for this but I’m failing; I also searched on Google but no benefit. Any Idea?
EDIT
Sorry brothers, I would like to edit it
I want combination of string with in a range, lets suppose between aaaa and aazz that would be strings like aaaa aaab aaac aaad ..... aazx aazy aazz .. my character space is just upper and smaller English letters that would be like 52 characters. I want to check every combination of 4 characters. but Server will distribute range of strings among its clients. MY question was if one client gets range between aaaa and aazz so how will I generate strings between just these bounds.
If your strings will comprehend only the ASCII table, you’ll have, as an upper limit, 256 characters, or 2^8 characters.
Since your strings are 4 characters length, you’ll have
2^8 * 2^8 * 2^8 * 2^8combinations,or
2^8^4 = 2^32combinations.Simply split the range of numbers and start the combinations in each machine.
You’ll probably be interested in this: Calculating Nth permutation step?
Edit:
Considering your edit, your space of combinations would be
52^4 = 7.311.616combinations.Then, you do simply need to divide these “tasks” for each machine to compute, so,
7.311.616 / n = r, havingras the amount of permutations calculated by each machine — the last machine may computer + (7.311.616 % n)combinations.Since you know the amount of combinations to build in each machine, you’ll have to execute the following, in each machine:
The function
nth_permutation()is not hard to derive, and I’m quite sure you can get it in the link I’ve posted.After this, you would simply start a process with such a function as
check_permutations, giving thebegin,end, and the vector of characterschars.