1

So, there's this website (http://md5decrypter.co.uk) which, given an md5 hash, will attempt to return the original string.

Is there an API or has someone made a PHP class to work with it? I can't find one...

Before, you ask, let me assure you that I have no malicious intent.

Thank you in advance.

citruspi
  • 6,709
  • 4
  • 27
  • 43
  • 7
    Ha, *let me assure you*. Classic. – Josh Apr 16 '12 at 20:59
  • 3
    MD5-"Decryptors" compares input strings with rainbow tables. Just create such a table and compare your string against the pre-calculated md5-hashes. However, trying to decrypt hashes makes you slighly suspicous ... – KingCrunch Apr 16 '12 at 20:59
  • @KingCrunch I always wanted something like this. :D (My current nick supports the reasons) Thanks Mihir-Singh – hjpotter92 Apr 16 '12 at 21:01
  • I'm slightly unfamiliar with rainbow tables... If I 'made" one, I would have all hashes that md5decryptor? I'm asking for this specific site because I have found that they have the largest database. – citruspi Apr 16 '12 at 21:01
  • @ChasingDeath welcome... But in all honesty guys, I have no malicious intent... – citruspi Apr 16 '12 at 21:03
  • I do. :D I just wanted to find some passwords from an age-old database. Now, it seems like those passwords aren't MD5 crypted at all. :( – hjpotter92 Apr 16 '12 at 21:04
  • 1
    @KingCrunch With today's computing power, rainbow tables are outdated. They take up way too much space, and cracking passwords can be done quite fast on Amazon's clouds or similar. – kba Apr 16 '12 at 21:04
  • 2
    @KristianAntonsen Space is not expensive and with power you can evaluate multiple (partial) tables at once. I don't think, they are that useless. Slightly depends on wether you already have some tables, or not. If you need to create them first, then it's maybe really more useful to omit it. – KingCrunch Apr 16 '12 at 21:05
  • 1
    @KingCrunch but at the same time, by "piggy-backing" off of md5decryptor, I would save myself space and processing power. – citruspi Apr 16 '12 at 21:06

3 Answers3

4

Even so the guy from md5decryptor is nice, he won't make his asset accessible to you via HTTP only because you're asking. As anybody else you can use the publicly available webinterface which requires a captcha - which says everything.

Or in short: No there ain't no PHP API out there.

However, why don't you run your own? It's rather trivial:

$decryptors = array('Google', 'Gromweb');

foreach ($hashes as $hash) {
    echo "$hash";
    foreach($decryptors as $decrytor)
    {
        if (NULL !== ($plain = MD5Decryptor::plain($hash, $decrytor))) {
            echo " - found: $plain ($decrytor)";
            break;
        }
    }
    echo "\n";
}

Output:

fcf1eed8596699624167416a1e7e122e - found: octopus (Google)
bed128365216c019988915ed3add75fb - found: passw0rd (Google)
d0763edaa9d9bd2a9516280e9044d885 - found: monkey (Google)
dfd8c10c1b9b58c8bf102225ae3be9eb - found: 12081977 (Google)
ede6b50e7b5826fe48fc1f0fe772c48f - found: 1q2w3e4r5t6y (Google)

Those you're not able to directly look-up, you can paste at that site manually. Keep in mind if more folks think like you, more and more sites will go down (most of them are already).

abstract class MD5Decryptor
{
    abstract public function probe($hash);

    public static function plain($hash, $class = NULL)
    {
        if ($class === NULL) {
            $class = get_called_class();
        } else {
            $class = sprintf('MD5Decryptor%s', $class);
        }
        $decryptor = new $class();

        if (count($hash) > 1) {
            foreach ($hash as &$one) {
                $one = $decryptor->probe($one);
            }
        } else {
            $hash = $decryptor->probe($hash);
        }
        return $hash;
    }

    public function dictionaryAttack($hash, array $wordlist)
    {
        $hash = strtolower($hash);
        foreach ($wordlist as $word) {
            if (md5($word) === $hash)
                return $word;
        }
    }
}

abstract class MD5DecryptorWeb extends MD5Decryptor
{
    protected $url;

    public function getWordlist($hash)
    {
        $list = FALSE;
        $url = sprintf($this->url, $hash);
        if ($response = file_get_contents($url)) {
            $list[$response] = 1;
            $list += array_flip(preg_split('/\s+/', $response));
            $list += array_flip(preg_split('/(?:\s|\.)+/', $response));
            $list = array_keys($list);
        }
        return $list;
    }

    public function probe($hash)
    {
        $hash = strtolower($hash);
        return $this->dictionaryAttack($hash, $this->getWordlist($hash));
    }
}

class MD5DecryptorGoogle extends MD5DecryptorWeb
{
    protected $url = 'http://www.google.com/search?q=%s';

}

class MD5DecryptorGromweb extends MD5DecryptorWeb
{
    protected $url = 'http://md5.gromweb.com/query/%s';
}
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Hmmm, I know what you mean about him making it available for me just because I ask... Its just that [he had one](http://forum.hashkiller.com/index.php?topic=7352.0) two or three months ago, but it seems to have completely vanished.... – citruspi Apr 19 '12 at 19:42
  • And, I can't enter them manually because its part of an app that I'm writing... – citruspi Apr 19 '12 at 19:45
  • @MihirSingh: Obviously that one ain't online any longer. And even that site wouldn't have given you all hashes plain, so in any case you have a leftover, so keep that apart and store for later manual cracking. or feed it to hashcat with rules etc, works pretty well. – hakre Apr 19 '12 at 19:47
  • Unfortunately, that seems to be the case... :( – citruspi Apr 19 '12 at 19:51
  • "You may award your bounty in 5 hours"... Well, see you then... – citruspi Apr 19 '12 at 19:52
  • @hakre... Welcome. Quick question... Does this only work with Google and Gromweb? Or can I keep expanding it to get the most hashes cracked? – citruspi Apr 19 '12 at 20:07
  • That's meant to be extended actually. As long as you keep the base class, this should play well. – hakre Apr 19 '12 at 20:08
  • @hakre... Ok thanks... And how easy is it to extend? Would I just have to do class MD5DecryptorService extends MD5DecryptorWeb { protected $url = 'http://service.com/query/%s' }? – citruspi Apr 19 '12 at 20:14
  • It depends on the service for which you would like to integrate into the API. – hakre Apr 19 '12 at 20:15
  • Well, yes, but I meant do I just have to add the class and add the URL for the query? Or do I have to add it, or implement the class, else where? – citruspi Apr 19 '12 at 20:17
  • As long as the class extends like the two others (google and Gromweb), it's equally easy: Just change the URL and the classname. – hakre Apr 19 '12 at 20:19
  • Hakre, when you are back online, could you address [this problem](http://stackoverflow.com/questions/10254482/catching-failed-http-request-in-php/) with the script? – citruspi Apr 20 '12 at 22:50
1

BozoCrack is a dead simple ruby script that uses google as a rainbowtable and is frighteningly good at cracking unsalted MD5 passwords. Looking at the code it shouldn't be too hard to migrate it to PHP.

PS: everybody who uses unsalted MD5 as password hashing algorithm should have his passwords cracked, one for one ... don't use md5, use bcrypt!

Community
  • 1
  • 1
ChrisR
  • 14,370
  • 16
  • 70
  • 107
0

You could always make your own:

<?php 
//From file or some John the ripper piped input
$wordlist=file('some_word_list.lst');

foreach ($wordlist as $word){
    $sql="INSERT INTO table (plain_word,hashed_word)values('$word','".md5($word)."')";
    ...
}
?>
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
  • I realize that, but I am limited by space and power. In addition, md5decryptor already has so many hashes... I couldn't think of or find so many words.... – citruspi Apr 16 '12 at 21:08