Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $max_req = 4;
- // ограничить кол-во запросов для сессии: 1 запрос на 4 секунд
- session_start();
- if ( isset($_SESSION['last_request_time']) )
- {
- if ($_SESSION['request_count'] > $max_req)
- {
- #var_dump($_SESSION['last_request_time'], mktime()) ;
- if ( ($_SESSION['last_request_time'] + 3) > mktime() )
- {
- $data['error'] = "You can do 1 search query in 3 seconds. Want more? Send your suggestion to harpywar@gmail.com.";
- die ( json_encode($data) );
- }
- else{
- $_SESSION['last_request_time'] = mktime();
- $_SESSION['request_count'] = 0;
- }
- }
- else
- {
- $_SESSION['request_count']++;
- }
- }
- else
- {
- $_SESSION['last_request_time'] = mktime();
- $_SESSION['request_count'] = 0;
- }
- $hash = ( isset($_REQUEST["hash"]) ) ? $_REQUEST["hash"] : false;
- $search_in = ( isset($_REQUEST["search_in"]) ) ? $_REQUEST["search_in"] : false;
- if ( $hash )
- {
- require_once("inc/HashCrack.class.php");
- $db_steps = 0; // кол-во шагов для поиска
- $db_size = 0; // размер бд в байтах
- $db_rows = 0; // кол-во записей
- $db_elapsed = 0; // поисковое время
- $db_bytes_read = 0; // считано байтов
- // TODO: cache? для последних 100 запросов
- // если запрос есть в файле кеша, то отправить пароли оттуда
- // поиск в одном файле за один запрос
- switch ($search_in)
- {
- // dictionary
- case '1':
- $passList = SearchDictionary($hash);
- break;
- // 1-6 symbols
- case '2':
- $passList = SearchAlpha6($hash);
- break;
- // 7-9 symbols
- case '3':
- $passList = SearchDigits9($hash);
- break;
- // 10 symbols
- case '4':
- $passList = SearchDigits10($hash);
- break;
- default:
- $passList = false;
- }
- //$passList2 = SearchNum9($hash);
- //$passList = array_merge($passList1, $passList2);
- //var_dump($db_elapsed);
- //var_dump($passList);
- //foreach ($passList as $p)
- // echo $p . '<br>';
- #if (!$passList)
- # $passList = SearchNum($hash);
- $data = array
- (
- 'error' => ($passList === false) ? 'Not found' : '',
- 'passwords' => $passList,
- 'database' => array (
- 'size' => $db_size, //$db_size,
- 'rows' => $db_rows,
- 'steps' => $db_steps,
- 'passwords_found' => count($passList),
- 'bytes_read' => $db_bytes_read,
- 'elapsed' => $db_elapsed
- ),
- 'server' => array (
- 'processor' => 'P4 3.06GHz',
- 'memory' => '256Mb',
- 'disk' => '250Gb',
- 'os' => 'Debian 6',
- 'hosted' => 'Naki-BoT'
- )
- );
- #var_dump($data);
- //$s = serialize($data);
- //echo $s;
- echo json_encode($data);
- }
- // искать хеш в паролях из букх и цифр 0-9a-z, 1-6 символов
- function SearchAlpha6($hash)
- {
- $filename = "../250g/hash_data/1-6alpha";
- $pass_length = 6;
- $pass_compressed = false;
- $hash_length = 3;
- $hash_compressed = true;
- $meta1_length = 2;
- $meta2_length = 6;
- $pass = CrackIt($hash, $filename, $pass_length, $pass_compressed, $hash_length, $hash_compressed, $meta1_length, $meta2_length);
- return $pass;
- }
- // искать хеш в паролях из цифр 0-9, 7-9 символов
- function SearchDigits9($hash)
- {
- $filename = "../250g/hash_data/7-9digits";
- $pass_length = 5;
- $pass_compressed = true;
- $hash_length = 3;
- $hash_compressed = true;
- $meta1_length = 2;
- $meta2_length = 6;
- $pass = CrackIt($hash, $filename, $pass_length, $pass_compressed, $hash_length, $hash_compressed, $meta1_length, $meta2_length);
- return $pass;
- }
- // искать хеш в паролях из цифр 0-9, 10 символов
- function SearchDigits10($hash)
- {
- $filename = "../250g/hash_data/10digits";
- $pass_length = 5;
- $pass_compressed = true;
- $hash_length = 3;
- $hash_compressed = true;
- $meta1_length = 2;
- $meta2_length = 6;
- $pass = CrackIt($hash, $filename, $pass_length, $pass_compressed, $hash_length, $hash_compressed, $meta1_length, $meta2_length);
- return $pass;
- }
- // искать хеш в паролях из словаря (32 символа)
- function SearchDictionary($hash)
- {
- $filename = "../250g/hash_data/dictionary";
- $pass_length = 32;
- $pass_compressed = false;
- $hash_length = 3;
- $hash_compressed = true;
- $meta1_length = 1;
- $meta2_length = 5;
- $pass = CrackIt($hash, $filename, $pass_length, $pass_compressed, $hash_length, $hash_compressed, $meta1_length, $meta2_length);
- return $pass;
- }
- function CrackIt($hash, $filename, $pass_length = 5, $pass_compressed = false, $hash_length = 3, $hash_compressed = true, $meta1_length = 2, $meta2_length = 6)
- {
- global $db_steps, $db_size, $db_rows, $db_elapsed, $db_bytes_read;
- $h = new HashCrack($filename, $hash_length, $hash_compressed, $pass_length, $pass_compressed, $meta1_length, $meta2_length);
- $pass = $h->Search($hash);
- $db_size += $h->GetDbSize();
- $db_rows += $h->GetDbRows();
- $db_steps += $h->GetDbSteps();
- $db_bytes_read += $h->GetDbBytesRead();
- $db_elapsed += $h->GetDbElapsed();
- if ( $pass !== false )
- return $pass;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement