| blib/lib/Digest/MD5/Reverse.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 13 | 13 | 100.0 |
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 5 | 5 | 100.0 |
| pod | 0 | 1 | 0.0 |
| total | 18 | 19 | 94.7 |
| line | stmt | bran | cond | sub | pod | time | code | |
|---|---|---|---|---|---|---|---|---|
| 1 | package Digest::MD5::Reverse; | |||||||
| 2 | ||||||||
| 3 | 1 | 1 | 21452 | use warnings; | ||||
| 1 | 2 | |||||||
| 1 | 26 | |||||||
| 4 | 1 | 1 | 5 | use strict; | ||||
| 1 | 1 | |||||||
| 1 | 28 | |||||||
| 5 | 1 | 1 | 971 | use Socket; | ||||
| 1 | 5012 | |||||||
| 1 | 626 | |||||||
| 6 | 1 | 1 | 9 | use Exporter; | ||||
| 1 | 2 | |||||||
| 1 | 810 | |||||||
| 7 | ||||||||
| 8 | =head1 NAME | |||||||
| 9 | ||||||||
| 10 | Digest::MD5::Reverse - MD5 Reverse Lookup | |||||||
| 11 | ||||||||
| 12 | =cut | |||||||
| 13 | ||||||||
| 14 | our $VERSION = "1.3"; | |||||||
| 15 | our @ISA = qw(Exporter); | |||||||
| 16 | our @EXPORT = qw(&reverse_md5); | |||||||
| 17 | ||||||||
| 18 | ||||||||
| 19 | =head1 VERSION | |||||||
| 20 | ||||||||
| 21 | Version 1.3 | |||||||
| 22 | ||||||||
| 23 | =head1 SYNOPSIS | |||||||
| 24 | ||||||||
| 25 | use Digest::MD5::Reverse; | |||||||
| 26 | my $plaintext = reverse_md5($md5); | |||||||
| 27 | ||||||||
| 28 | =head1 DESCRIPTION | |||||||
| 29 | ||||||||
| 30 | MD5 sums (see RFC 1321 - The MD5 Message-Digest Algorithm) are used as a one-way | |||||||
| 31 | hash of data. Due to the nature of the formula used, it is impossible to reverse | |||||||
| 32 | it. | |||||||
| 33 | ||||||||
| 34 | This module provides functions to search several online MD5 hashes database and | |||||||
| 35 | return the results (or return undefined if no match found). | |||||||
| 36 | ||||||||
| 37 | We are not breaking security. We are however making it easier to lookup the | |||||||
| 38 | source of a MD5 sum. | |||||||
| 39 | ||||||||
| 40 | =head1 EXAMPLES | |||||||
| 41 | ||||||||
| 42 | use Digest::MD5::Reverse; | |||||||
| 43 | print "Data is ".reverse_md5("acbd18db4cc2f85cedef654fccc4a4d8")."\n"; | |||||||
| 44 | # Data is foo | |||||||
| 45 | ||||||||
| 46 | =head1 DATABASE | |||||||
| 47 | ||||||||
| 48 | =over 4 | |||||||
| 49 | ||||||||
| 50 | =item * milw0rm.com | |||||||
| 51 | ||||||||
| 52 | =item * gdataonline.com | |||||||
| 53 | ||||||||
| 54 | =item * hashreverse.com | |||||||
| 55 | ||||||||
| 56 | =item * us.md5.crysm.net | |||||||
| 57 | ||||||||
| 58 | =item * nz.md5.crysm.net | |||||||
| 59 | ||||||||
| 60 | =item * ice.breaker.free.fr | |||||||
| 61 | ||||||||
| 62 | =item * hashchecker.com | |||||||
| 63 | ||||||||
| 64 | =item * md5.rednoize.com | |||||||
| 65 | ||||||||
| 66 | =item * md5.xpzone.de | |||||||
| 67 | ||||||||
| 68 | =item * md5encryption.com | |||||||
| 69 | ||||||||
| 70 | =back | |||||||
| 71 | ||||||||
| 72 | =cut | |||||||
| 73 | ||||||||
| 74 | our $DATABASE = [ | |||||||
| 75 | { | |||||||
| 76 | host => "milw0rm.com", | |||||||
| 77 | path => "/cracker/search.php", | |||||||
| 78 | meth => "POST", | |||||||
| 79 | content => "hash=%value%&Submit=Submit", | |||||||
| 80 | mreg => qr{ | |||||||
| 81 | ||||||||
| 82 | md5<\/TD> | |||||||
| 83 | \w{32}<\/TD> | |||||||
| 84 | (.+?)<\/TD> | |||||||
| 85 | cracked<\/TD> | |||||||
| 86 | <\/TR> | |||||||
| 87 | }x | |||||||
| 88 | }, | |||||||
| 89 | { | |||||||
| 90 | host => "gdataonline.com", | |||||||
| 91 | path => "/qkhash.php?mode=xml&hash=%value%", | |||||||
| 92 | meth => "GET", | |||||||
| 93 | mreg => qr{ | |||||||
| 94 | |
|||||||
| 95 | }x | |||||||
| 96 | }, | |||||||
| 97 | { | |||||||
| 98 | host => "hashreverse.com", | |||||||
| 99 | path => "/index.php?action=view", | |||||||
| 100 | meth => "POST", | |||||||
| 101 | content => "hash=%value%&Submit2=Search+for+a+SHA1+or+MD5+hash", | |||||||
| 102 | mreg => qr{ | |||||||
| 103 | |
|||||||
| 104 | }x | |||||||
| 105 | }, | |||||||
| 106 | { | |||||||
| 107 | host => "us.md5.crysm.net", | |||||||
| 108 | path => "/find?md5=%value%", | |||||||
| 109 | meth => "GET", | |||||||
| 110 | mreg => qr{ | |||||||
| 111 | |
|||||||
| 112 | }x | |||||||
| 113 | }, | |||||||
| 114 | { | |||||||
| 115 | host => "nz.md5.crysm.net", | |||||||
| 116 | path => "/find?md5=%value%", | |||||||
| 117 | meth => "GET", | |||||||
| 118 | mreg => qr{ | |||||||
| 119 | |
|||||||
| 120 | }x | |||||||
| 121 | }, | |||||||
| 122 | { | |||||||
| 123 | host => "ice.breaker.free.fr", | |||||||
| 124 | path => "/md5.php?hash=%value%", | |||||||
| 125 | meth => "GET", | |||||||
| 126 | mreg => qr{ | |||||||
| 127 | \s-\s(.+?) |
|||||||
| 128 | }x | |||||||
| 129 | }, | |||||||
| 130 | { | |||||||
| 131 | host => "hashchecker.com", | |||||||
| 132 | path => "/index.php", | |||||||
| 133 | meth => "POST", | |||||||
| 134 | content => "search_field=%value%&Submit=search", | |||||||
| 135 | mreg => qr{ | |||||||
| 136 | (.+?)<\/b>\sused\scharlist | |||||||
| 137 | }x | |||||||
| 138 | }, | |||||||
| 139 | { | |||||||
| 140 | host => "md5.rednoize.com", | |||||||
| 141 | path => "/?s=md5&q=%value%", | |||||||
| 142 | meth => "GET", | |||||||
| 143 | mreg => qr{ | |||||||
| 144 | (.+?)<\/div> |
|||||||
| 145 | }x | |||||||
| 146 | ||||||||
| 147 | }, | |||||||
| 148 | { | |||||||
| 149 | host => "md5.xpzone.de", | |||||||
| 150 | path => "/?string=%value%&mode=decrypt", | |||||||
| 151 | meth => "GET", | |||||||
| 152 | mreg => qr{ | |||||||
| 153 | Code:\s(.+?) |
|||||||
| 154 | }x | |||||||
| 155 | }, | |||||||
| 156 | { | |||||||
| 157 | host => "md5encryption.com", | |||||||
| 158 | path => "/?mod=decrypt", | |||||||
| 159 | meth => "POST", | |||||||
| 160 | content => "hash2word=%value%", | |||||||
| 161 | mreg => qr{ | |||||||
| 162 | Decrypted\sWord:<\/b>\s(.*?)(?: ){2} |
|||||||
| 163 | }x | |||||||
| 164 | } | |||||||
| 165 | ]; | |||||||
| 166 | ||||||||
| 167 | my $get = sub | |||||||
| 168 | { | |||||||
| 169 | my($url,$path) = @_; | |||||||
| 170 | socket(my $socket, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die "Socket Error : $!\n"; | |||||||
| 171 | connect($socket,sockaddr_in(80, inet_aton($url))) or die "Connect Error: $!\n"; | |||||||
| 172 | send($socket,"GET $path HTTP/1.1\015\012Host: $url\015\012User-Agent: Firefox\015\012Connection: Close\015\012\015\012",0); | |||||||
| 173 | return do { local $/; <$socket> }; | |||||||
| 174 | }; | |||||||
| 175 | ||||||||
| 176 | my $post = sub | |||||||
| 177 | { | |||||||
| 178 | my($url,$path,$content) = @_; | |||||||
| 179 | my $len = length $content; | |||||||
| 180 | socket(my $socket, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die "Socket Error : $!\n"; | |||||||
| 181 | connect($socket,sockaddr_in(80, inet_aton($url))) or die "Connect Error : $!\n"; | |||||||
| 182 | send($socket,"POST $path HTTP/1.1\015\012Host: $url\015\012User-Agent: Firefox\015\012Content-Type: application/x-www-form-urlencoded\015\012Connection: Close\015\012Content-Length: $len\015\012\015\012$content\015\012",0); | |||||||
| 183 | return do { local $/; <$socket> }; | |||||||
| 184 | }; | |||||||
| 185 | ||||||||
| 186 | my $reverseit = sub | |||||||
| 187 | { | |||||||
| 188 | my $md5 = shift; | |||||||
| 189 | return undef if length $md5 != 32; | |||||||
| 190 | my($string,$page); | |||||||
| 191 | SEARCH: | |||||||
| 192 | for my $site (@{ $DATABASE }) | |||||||
| 193 | { | |||||||
| 194 | my $host = $site->{host}; | |||||||
| 195 | my $path = $site->{path}; | |||||||
| 196 | my $meth = $site->{meth}; | |||||||
| 197 | my $mreg = $site->{mreg}; | |||||||
| 198 | my $content = $site->{content}; | |||||||
| 199 | if($meth eq "POST") | |||||||
| 200 | { | |||||||
| 201 | $content =~ s/%value%/$md5/ig; | |||||||
| 202 | $page = $post->($host,$path,$content); | |||||||
| 203 | } | |||||||
| 204 | else | |||||||
| 205 | { | |||||||
| 206 | $path =~ s/%value%/$md5/ig; | |||||||
| 207 | $page = $get->($host,$path); | |||||||
| 208 | } | |||||||
| 209 | next unless $page; | |||||||
| 210 | last SEARCH if(($string) = $page =~ /$site->{mreg}/); | |||||||
| 211 | } | |||||||
| 212 | return $string ? $string : undef; | |||||||
| 213 | }; | |||||||
| 214 | ||||||||
| 215 | sub reverse_md5 | |||||||
| 216 | { | |||||||
| 217 | 1 | 1 | 0 | 317 | return $reverseit->(shift); | |||
| 218 | } | |||||||
| 219 | ||||||||
| 220 | =head1 SEE ALSO | |||||||
| 221 | ||||||||
| 222 | L |
|||||||
| 223 | ||||||||
| 224 | =head1 AUTHOR | |||||||
| 225 | ||||||||
| 226 | Raoul-Gabriel Urma << blwood@skynet.be >> | |||||||
| 227 | ||||||||
| 228 | =head1 COPYRIGHT & LICENSE | |||||||
| 229 | ||||||||
| 230 | Copyright 2007 Raoul-Gabriel Urma, all rights reserved. | |||||||
| 231 | ||||||||
| 232 | This program is free software; you can redistribute it and/or modify it | |||||||
| 233 | under the same terms as Perl itself. | |||||||
| 234 | ||||||||
| 235 | =cut | |||||||
| 236 | ||||||||
| 237 | 1; |