0

Recently, I started coding a simple python Brute Forcer for web forms and so far so good.

But, i want my bruteforcer to be capable of stopping a brute force operation and resume later with the previous session.

To do this i want to keep the last password tested and enter it sometime later, that's not the problem. My problem is that i don't know how to start bruteforcing from a specific word.

As an example, when i enter the word "Orange", i want the program to continue testing: Orangf, Orangg, Orangh and so on..

So far i'm using this code to do a simple bruteforce with the charset abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 and length 6 characters.

for word in itertools.imap(''.join, itertools.product('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', repeat=6)):

2 Answers2

1

It might be that this question contains part of the answer to yours: Using itertools.product and want to seed a value

Community
  • 1
  • 1
sgillis
  • 242
  • 2
  • 6
0

Instead of looping through all the possibilities generated by itertools.imap, create a list of all those possibilities, and iterate through that, keeping track of where you are in the list.

When you pause, record the list index that you were at last, and when you resume, you can continue at that list index again.

Edit: Oops, brain fart. That's definitely not a good idea -- see comments.

Pandu
  • 1,606
  • 1
  • 12
  • 23
  • I don't think creating a list of all possibilities is a good idea since the list would be too large. – Ankur Ankan Jun 14 '13 at 08:30
  • Thanks for your answer, I thought this too, but i think it's not handy for my program because later i will have to enter the last values of the loops that i was keeping track. Something like: 356,235,576,757.. Although it's good for my purpose, i want to enter just a single word to resume. I have seen some closed-source bruteforcers in the past that did that. – user2485188 Jun 14 '13 at 08:33
  • Right, that makes sense. Doesn't `imap` give you back an iterator, though? Could you store that in a variable and just use `next()` repeatedly? – Pandu Jun 14 '13 at 08:35
  • Oh, I see, you want to enter a word to start from, not necessarily start and stop like I thought you meant. So that doesn't work either. It looks to me like sgillis is on the right track though. – Pandu Jun 14 '13 at 08:41
  • Well, what I was thinking of is slightly different from what you want, I think. But you could store the result of `imap` in a variable, say, `possibilities.` You can get a password to try by calling `possibilities.next()`, and keep doing that until you either reach the last possibility or you send the program some sort of signal to pause. And you'd resume not by entering the word that you want to continue from, but by just calling `possibilities.next()` some more. – Pandu Jun 14 '13 at 08:48
  • Well, i'm new to python and these things are new to me, could you please give me an example of what you mean? – user2485188 Jun 14 '13 at 08:50