0

I am trying to simulate a brute force attack (to explain how it works). I want to display the process to crack a password of “abc”. This requires me to show what password is being attempted to crack the “abc” password at that moment (so starting at “a” then “b” then “c” until it gets to “abc”.

My question is how I can get the password being attempted at that moment, displayed on screen, whilst the code is running the code?

Would it be easier to make a video that shows this process?

Thanks

Jamie

edit Here is the code I have written with comments explaining each part. Hope this helps with me explaining the problem.

thanks for the answers so far

    // the simulation

    Button btnSim = (Button) findViewById(R.id.btnSim);
    btnSim.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            TextView currentSimPword = (TextView) findViewById(R.id.currentSimPword);

            int i = 0;//i would be replaced by the string it is trying e.g. a then b then c
                      //until it reaches abc 

            while (i < 100) {//this would loop until i reaches abc

                //this would show what the brute force attack is attempting against the real password
                currentSimPword.setText("comparing password " + i + " against the real password 'abc'");
                //at this point i want it to be displayed on screen (and at every time it reaches here)

                //here i would need a way to pause it long enough for the user to see what is being tried

                //this increases the password tried by one each time in the loop
                i = i + 1;
            }
        }

    });
Yury
  • 20,618
  • 7
  • 58
  • 86
  • Can't you just write it out to a log file and tail it? – Kevin D Feb 23 '12 at 14:27
  • a then b then c is a movie thing! You should show the number of permutations (for the password length) and the number of those that have been tried. – Che Jami Feb 23 '12 at 14:49

4 Answers4

0

You could run your bruteforce method in an AsyncTask and simply update the UI with your current attempt.

At every attempt you would call publishProgress with your current password string and update the UI in onProgressUpdate.

However I might have misunderstood the question ^^

By the way, if this is for a presentation, a video is not a bad idea, because your tool might always have some bug that shows exactly during your presentation.

Tim
  • 2,051
  • 17
  • 36
0

I think it would be neat to show a scroll of all the attempts as they pass. It's fairly easy to implement. See the answer to this question.

Community
  • 1
  • 1
sarwar
  • 2,835
  • 1
  • 26
  • 30
0

Just use a TextView and each time you're trying a new "password" update its text to the password currently being tried. If the process is to fast to be observed you might want to append the passwords one after another with a timestamp.

TextView mLabel = findViewById(R.id.yourtextview);

// do some sort of loop that would simulate your brute force attack

mLabel.append(currentPassword + "\n");

// end loop that simulates brute force attack
Jean-Philippe Roy
  • 4,752
  • 3
  • 27
  • 41
0

Please run your loop in a background thread and use Handler to update the UI. Following are some links that help you understand the Handler.

Example of thread, handler and AsyncTask

Another post talking about Handler

Community
  • 1
  • 1
Praful Bhatnagar
  • 7,425
  • 2
  • 36
  • 44