Navigation

Md5/Salt...whatever Crack-klasse

Home » Scripts » Md5/Salt...whatever Crack-klasse
Article category is
Posted Apr 21, 05:30 PM


Ich schreib keine grosse Erklärung Was auch immer…mir war einfach langweilig und hab die Klasse mal geschrieben, schön ist, dass sie nicht von der encrypt methode abhängig ist, weil die encrypt methode selber geschrieben werden kann
halt über ein extend….einfach mal durchschauen, fals nicht zurechtkommen, Kommentar oder email ^^
Das andere was vielleicht noch erwähnt werden sollte….das ganze basiert auf brute-force und ist deshalb überhaupt nicht effektiv aber funktionieren tut es ^^ für kleinere passwörter ist das kein problem :D
achja…das ganze ist für konsole gemacht, webserver hält das nicht durch ^^

  1. #!/usr/bin/php
  2. <?php
  3. class Crack {
  4. private $length = '';
  5. private $hash = '';
  6. private $symbols = array();
  7. private $value = array();
  8. private $layer = 0;
  9. function __construct($hash,$length='') {
  10. $this->setHash($hash);
  11. $this->setLength($length);
  12. }
  13. public function setSymbols($array) {
  14. $this->symbols = $array;
  15. }
  16. public function setLength($length) {
  17. $this->length = $length;
  18. }
  19. public function setHash($hash) {
  20. $this->hash = (!empty($hash) ? $hash : $this->hash);
  21. }
  22. public function getPossibilities() {
  23. return number_format(pow(count($this->symbols),$this->length),0,',','.');
  24. }
  25. public function crack($hash='') {
  26. $this->setHash($hash);
  27. if(empty($this->length)) {
  28. $this->setLength(1);
  29. while(1) {
  30. if($this->determine()) {
  31. return implode('',$this->value);
  32. } else {
  33. $this->length++;
  34. }
  35. }
  36. } else {
  37. if($this->determine()) {
  38. return implode('',$this->value);
  39. }
  40. }
  41. }
  42. private function determine() {
  43. $this->layer++;
  44. for($i = 0; $i < count($this->symbols); $i++) {
  45. $this->value[$this->layer] = $this->symbols[$i];
  46. if($this->length > $this->layer) {
  47. if($this->determine()) {
  48. $this->layer--;
  49. return true;
  50. }
  51. } else {
  52. if($this->encrypt(implode('',$this->value)) == $this->hash) {
  53. $this->layer--;
  54. return true;
  55. }
  56. }
  57. #unset($this->value[count($this->value)-1]);
  58. }
  59. $this->layer--;
  60. return false;
  61. }
  62. private function encrypt($string) {
  63. return $string;
  64. }
  65. }
  66. class Md5Crack extends Crack {
  67. private function encrypt($string) {
  68. return md5($string);
  69. }
  70. }
  71. $o = new Md5Crack('598d4c200461b81522a3328565c25f7c',5);
  72. $o->setSymbols(array_merge(range(A,Z),range(a,z),range(0,9)));
  73. print 'Moeglichkeiten: '.$o->getPossibilities()."\n";
  74. print '['.date('H:i:s d/m/Y').'] Start...'."\n";
  75. print "\t\t".'Password: '.$o->crack();
  76. print '['.date('H:i:s d/m/Y').'] Finished'."\n";
  77. ?>


Kommentare

Textile Help

Feeds