Click here to Skip to main content
15,889,034 members
Articles / Programming Languages / C#

Brute Force

Rate me:
Please Sign up or sign in to vote.
3.94/5 (9 votes)
15 May 2009CPOL 105.5K   11.2K   27   17
Brute Force algorithm with MD5 & SHA Hashing
Image 1

Introduction

This is my attempt to create a brute force algorithm that can use any hash or encryption standard.

Background

Bruteforcing has been around for some time now, but it is mostly found in a pre-built application that performs only one function. My attempt to bruteforcing started when I forgot a password to an archived rar file. I decided to create a bruteforce algorithm that can be used in a plug-and-play manner. At the moment, the basic hashing algorithms (MD5 & SHA) are supported but nothing stops you from using it to brute a Microsoft SQL password (* using pwdencrypt and pwdcompare).

Using the Code

Using the method is straight forward. Set up your character and password array and call the brute() or bruteUI() method.

C#
//Password array
string[] passwordArray;
//Lowercare character array
string[] lower = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", 
	"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
//Uppercase character array
string[] upper = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", 
	"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
//Digits array
string[] digits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 

private void setupCharArray()
{
   if (ckhLower.Checked)
   {
      characterArray.AddRange(lower);
   }

   if (chkUpper.Checked)
   {
      characterArray.AddRange(upper);
   }

   if (chkDigits.Checked)
   {
      characterArray.AddRange(digits);
   }
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
   brute();
}

Points of Interest

An MD5 and SHA Hash class make it easy to choose a hash type. While your PC is bruting away, a CPU monitor shows you the load on the system.

History

  • 15th May, 2009: Initial post

This is my first attempt to Bruteforcing and like I said it is expandable to many other hash types and encryption standards.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Backbase
Netherlands Netherlands
Senior Solutions Architect.

I reject your code and substitute my own Smile | :) !

Comments and Discussions

 
QuestionHow to Use Pin
Member 1351642413-Nov-17 13:06
Member 1351642413-Nov-17 13:06 
GeneralThoughts Pin
PIEBALDconsult7-Mar-14 2:15
mvePIEBALDconsult7-Mar-14 2:15 
QuestionOKok it works, but.. Pin
Member 106481687-Mar-14 2:12
Member 106481687-Mar-14 2:12 
Questionnot working Pin
Psycho_Coder1-Apr-13 18:25
professionalPsycho_Coder1-Apr-13 18:25 
QuestionTried for MD5, didn't work properly Pin
Shukhrat Nekbaev20-Dec-12 2:10
Shukhrat Nekbaev20-Dec-12 2:10 
AnswerRe: Tried for MD5, didn't work properly Pin
Pieter Alec Myburgh16-Jan-13 22:47
Pieter Alec Myburgh16-Jan-13 22:47 
Questionstart true to arrive the the truth Pin
ibrahim_ragab5-Nov-12 7:43
professionalibrahim_ragab5-Nov-12 7:43 
QuestionIt works but you cant use it for like hotmail or something? Pin
swerdiofire13-Nov-11 1:34
swerdiofire13-Nov-11 1:34 
GeneralMy vote of 4 Pin
c4th0d38-Oct-11 3:23
c4th0d38-Oct-11 3:23 
GeneralRe: My vote of 4 Pin
CodeKrash28-Aug-12 16:19
CodeKrash28-Aug-12 16:19 
GeneralMy vote of 4 Pin
Uhlume28-Sep-11 10:19
Uhlume28-Sep-11 10:19 
QuestionWrong Average PW/sec Calculation Pin
Member 81486429-Aug-11 9:14
Member 81486429-Aug-11 9:14 
GeneralSymmetries Pin
Chris Maunder15-May-09 14:51
cofounderChris Maunder15-May-09 14:51 
GeneralRe: Symmetries Pin
Pieter Alec Myburgh3-Dec-09 22:25
Pieter Alec Myburgh3-Dec-09 22:25 
Jokewanted to say hi! Pin
eRRaTuM15-May-09 14:22
eRRaTuM15-May-09 14:22 
3BB3E15E069E7EF2102B160566E3893D
1666CA77AB75F7D731E645FA6EF4FC60 DC1F3D93B4D480FDD3A7E22B44CFF8BA
AF648B284ADC3DA6B9826AD567F3873E 59B9A2DF8C7820F34F57DA83A136E68F
774D5A70309F3F72D5C857C307C8D9E5 ED469618898D75B149E5C7C4B6A1C415
9258B18F85B508DE9ED83F64F86156B2 09A413A9DE81C74A86ABBCA89C4069ED
704A0D4F6AAA0EFBC273AF450214881E ABC13D066497DEC268D827A25F649699
CB62B90B6F5250FFC69FD31DAEDD1<code>G00D1UCK</code>5B14A49729EAD612994600609A75


O TEMPORA ! O MORES !

GeneralRe: wanted to say hi! Pin
Member 103700801-Apr-14 6:30
Member 103700801-Apr-14 6:30 
GeneralHehe... Pin
Axel Rietschin15-May-09 11:50
professionalAxel Rietschin15-May-09 11:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.