Important alert: (current site time 5/23/2013 1:33:49 PM EDT)
 

VB icon

Excellent Recursion Code & MD5/SHA1 Brute Force Cracker

Email
Submitted on: 6/6/2005 8:15:26 AM
By: Max Demian  
Level: Advanced
User Rating: By 1 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 16730
(About the author)
 
     My first upload in 4 and a half years? This code is meant to be run locally in a command prompt, but can work for the web if for some reason you wanted to set it up to do so. The whole code works as a brute force md5 & sha1 password cracker. But the recursive code itself for generating the passwords was the hard part of the code. It will create every possible combonation of values in an array starting from your minimum value length to your maximum and in the order that they show in the array. It took me a few days to finally get perfected. This is the third version of the program.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Excellent Recursion Code & MD5/SHA1 Brute Force Cracker
// Description:My first upload in 4 and a half years?
This code is meant to be run locally in a command prompt, but can work for the web if for some reason you wanted to set it up to do so.
The whole code works as a brute force md5 & sha1 password cracker. But the recursive code itself for generating the passwords was the hard part of the code. It will create every possible combonation of values in an array starting from your minimum value length to your maximum and in the order that they show in the array. It took me a few days to finally get perfected. This is the third version of the program.
// By: Max Demian
//
// Inputs:+)Set the "max_execution_time" to 0 in your php.ini so the script does not timeout after 30 seconds.
+) The type of encryption (md5, sha1)
+) The character set
+) The minimum number of characters to try
+) The maximum number of characters to try
+) The password hash
//
// Returns:returns a cracked password if successfully cracked
returns a failed cracking message if unsuccessfull
returns error messages if any of the inputs are invalid
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1713&lngWId=8//for details.//**************************************

<?
	# MaxD5 Password Cracker (Release #3)
	# Written by DemiaN - maxdemian[at]hushmail.com
	# -----------------------------------------------------------
	#
	# This is a PHP console script to brute force crack md5 and
	# sha1 passwords.
	#
	# -----------------------------------------------------------
	#
	# Notes:
	#
	# You may want to set the "max_execution_time" to 0 in your
	# php.ini so the script does not timeout after 30 seconds.
	#
	# -----------------------------------------------------------
	#
	# Usage:
	#
	# Put the type of encryption in the $whichenc string
	#
	# Put the character set you want to use in the $charset string
	#
	# Put the minimum and maximum amount of characters in
	# passwords you want the brute forcer to check up.
	#
	# Put the password hash in the $passhash string
	#
	# -----------------------------------------------------------
	# Which Type of Encryption (md5, sha1)
	$whichenc = "md5";
	# Character Set ("all", "lowercase", "uppercase", "numeric", "lowernumeric", "uppernumeric")
	$charset = "all";
	# Minimum Number of Characters to Try
	$min = 1;
	# Maximum Number of Characters to Try
	$max = 10;
	# Password Hash
	$passhash = "c67ad03ad6db191f97455b1ebf26402f";
	# -----------------------------------------------------------
	# The Code
	# Making The Charsets
	$charsetall = array("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", "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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
	$charsetlower = array("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");
	$charsetupper = array("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");
	$charsetnumeric = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
	$charsetlowernumeric = array("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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
	$charsetuppernumeric = array("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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
	# Getting The Charset
	if ($charset == "all") {
		$vals = $charsetall;
	} elseif ($charset == "lowercase") {
		$vals = $charsetlower;
	} elseif ($charset == "uppercase") {
		$vals = $charsetupper;
	} elseif ($charset == "numeric") {
		$vals = $charsetnumeric;
	} elseif ($charset == "lowernumeric") {
		$vals = $charsetlowernumeric;
	} elseif ($charset == "uppernumeric") {
		$vals = $charsetuppernumeric;
	}
	# Intro
	echo "MaxD5 Password Cracker by DemiaN\n\n";
	if ($whichenc != "md5" && $whichenc != "sha1") {
		print "Invalid Encryption Selected";
		die();
	} elseif (!is_int($min) || $min < 1) {
		print "Invalid Minimum Characters";
		die();
	} elseif (!is_int($max) || $max < $min) {
		print "Invalid Maximum Characters";
		die();
	} else {
		if ($min == 1) {
			print "Starting 1 Character Cracking\n";
		} else {
			print "Starting $min Character Cracking\n";
		}
	}
	$A = array();
	$numVals = count($vals);
	$incDone = "";
	$realMax = "";
	$currentVal = "";
	$firstVal = "";
	for ($i = 0; $i < ($max + 1); $i++) {
		$A[$i] = -1;
	}
	
	for ($i = 0; $i < $max; $i++) {
		$realMax = $realMax . $vals[$numVals - 1];
	}
	for ($i = 0; $i < $min; $i++) {
		$A[$i] = $vals[0];
	}
	$i = 0;
	while ($A[$i] != -1) {
		$firstVal .= $A[$i];
		$i++;
	}
	if ($whichenc == "md5") {
		$testpass = md5($firstVal);
	} elseif ($whichenc == "sha1") {
		$testpass = sha1($firstVal);
	}
	if ($testpass == $passhash) {
		echo "\nThe Password Is: $firstVal";
		die();
	}
	while (1) {
		for ($i = 0; $i < ($max + 1); $i++) {
			if ($A[$i] == -1) {
				break;
			}
		}
		$i--;
		$incDone = 0;
		while (!$incDone) {	
			for ($j = 0; $j < $numVals; $j++) {
				if ($A[$i] == $vals[$j]) {
					break;
				}
			}
			if ($j == ($numVals - 1)) {
				$A[$i] = $vals[0];
				$i--;
				if ($i < 0) {
					for ($i = 0; $i < ($max + 1); $i++) {
						if ($A[$i] == -1) {
							break;
						}
					}
					$A[$i] = $vals[0];
					$A[$i + 1] = -1;
					$incDone = 1;
					print "Starting " . (strlen($currentVal) + 1) . " Characters Cracking\n";
				}
			} else {
				$A[$i] = $vals[$j + 1];
				$incDone = 1;
			}
		}
		$i = 0;
		$currentVal = "";
		while ($A[$i] != -1) {
			$currentVal = $currentVal . $A[$i];
			$i++;
		}
		if ($whichenc == "md5") {
			$testpass = md5($currentVal);
		} elseif ($whichenc == "sha1") {
			$testpass = sha1($currentVal);
		}
		if ($testpass == $passhash) {
			echo "\nThe Password Is: $currentVal";
			die();
		}
		if ($currentVal == $realMax) {
			break;
		}
	}
	print "Could not find the password for \"$passhash\"";
?>


Other 12 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/8/2005 4:56:04 PMAshraf Magdi

You Know , I from 2 months a MD5 Brute Force was little lines !!! you can more shortcutting , but nice code and i will give you 5 global :) hope to keep working and post more File Kind This :)
(If this comment was disrespectful, please report it.)

 
1/21/2007 8:16:19 AMCraig Phillips

Nice English ;)
(If this comment was disrespectful, please report it.)

 
9/16/2009 6:18:24 PMSimon

Rofl
(If this comment was disrespectful, please report it.)

 
2/28/2012 3:54:04 PMcalidev

does this code actually work?. That's the real question
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.