note 109638 deleted from rar.examples by danbrown

From: Date: Fri, 10 Aug 2012 16:16:45 +0000
Subject: note 109638 deleted from rar.examples by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190011@lists.php.net to get a copy of this message
Note Submitter: wasterinc ---- just a lil code id like to share, its crude and slow but it works for recoving rar passwords if you got a couple of days. (run in cli, about 50 a sec) <?PHP $file ="..\\findpass\\passwordedfiles.rar"; $file = "..\\findpass\\encryptedfiilenames.rar"; RarException::setUsingExceptions(true); // youll need to read the status of a bad password so trow exceptions $length = 8; // max length of pass // load chars (limiting the chars will speed things up) // here im loading all sensable ansi chars $char =""; for ($c=32;$c<127;$c++) $char .= chr($c); $chars = strlen ($char)-1; $pointer[0] = 0; // first pointer $countt =0; $last_tick = time(); $counttm =0; while (@$pointer[$length] != $chars) // breaks at max length { reset($pointer); $outpassw = ""; $outindex =""; foreach ($pointer as $key => $value) { $outpassw .= $char{$value}; $outindex .= "[".$value."]"; } // echo ($countt.">".$outindex." ".$outpassw."\n"); if (check_rar_password($file,$outpassw) == TRUE) { echo ("\n\npassword = ".$outpassw."\n\n"); die (""); } $pointer[0]++; $countt++; $to = count($pointer); for ($a=0;$a<$to;$a++) { if ($pointer[$a] > $chars) { $pointer[$a] = 0; if (isset ($pointer[$a+1] )) { $pointer[$a+1] = $pointer[$a+1] +1; } else { $pointer[] = 0; } } } //print_r($pointer); if ((time()-$last_tick) > 60) { echo ("at cycle : ".$countt); $done = $countt -$counttm; echo (" done ".$done." cycles last minute (".round($done/60)." cycles sec), last tested pasw $outpassw\n"); $last_tick = time(); $counttm = $countt ; } } function check_rar_password($file,$pass) { $rar_file = rar_open($file,$pass) or die("Failed to open Rar archive"); try { $entries = rar_list($rar_file); // encrypted breaks here $entry = $entries [0]; $entry->extract(dirname("./tmp/")); // passworded breaks here } catch(Exception $e) { $ernr = $e-> getCode(); if ( $ernr == 12 || $ernr ==22) { // when passwords errors return FALSE; } echo $e-> getMessage().$ernr; } echo ("posible hit"); return TRUE; } again this is a quik 'can i do it' experiment, noway intended to be fast, userfriendly or bugfree just how you can (ab)use this function. use at your own risk! ?>

« previous php.notes (#190011) next »