note 109638 added to rar.examples

From: Date: Fri, 03 Aug 2012 17:00:13 +0000
Subject: note 109638 added to rar.examples
Groups: php.notes 
Request: Send a blank email to php-notes+get-189911@lists.php.net to get a copy of this message
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! ?> ---- Server IP: 69.147.83.197 Probable Submitter: 84.85.94.241 ---- Manual Page -- http://www.php.net/manual/en/rar.examples.php Edit -- https://master.php.net/note/edit/109638 Del: integrated -- https://master.php.net/note/delete/109638/integrated Del: useless -- https://master.php.net/note/delete/109638/useless Del: bad code -- https://master.php.net/note/delete/109638/bad+code Del: spam -- https://master.php.net/note/delete/109638/spam Del: non-english -- https://master.php.net/note/delete/109638/non-english Del: in docs -- https://master.php.net/note/delete/109638/in+docs Del: other reasons-- https://master.php.net/note/delete/109638 Reject -- https://master.php.net/note/reject/109638 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189911) next »