Goede middag,

Ik keer wederom weer terug voor hulp.
Ik ben bezig met een nieuw project, waarvoor ik alle mogelijkheden met tekens moet weten in een string TOT 12 tekens. Dat zijn inderdaad een hele hoop mogelijkheden, nu wil ik AL deze dingen in de database zetten.
Ik ga dit script wel op een server draaien, maar word via de browser aangeroepen.
Wat nu dus eigenlijk de vraag is: hoe kan ik alle mogelijkheden creeëren.
Ik heb al geprobeert een bruteforce script aan te passen en het hashen eruit te halen, dit werkt wel. Maar dan moet je je pc dag en nacht laten aan staan totdat alle mogelijkheden behaald zijn. Dit gaat niet lukken natuurlijk.

Ik wil het script dus kunnen onderbreken.
Ik heb dit bruteforce script aangepast:
<?php
/*
* Thanks to Robert Green for this script he wrote in python
* http://www.rbgrn.net/blog/2007/09/how-to-write-a-brute-force-password-cracker.html
* I took what we wrote and ported this to PHP
*
* This script was written for PHP 5, but should work with
* PHP 4 if the hash() function is replaced with md5() or something else
*/

#########################################################
/* Configuration */

// this is the hash we are trying to crack
define('HASH', '9d2bbed238251f26c6faaae38e7e0c77');

// algorithm of hash
// see http://php.net/hash_algos for available algorithms
define('HASH_ALGO', 'md5');

// max length of password to try
define('PASSWORD_MAX_LENGTH', 12);

set_time_limit(60000000);
// available characters to try for password
// uncomment additional charsets for more complex passwords
$charset = 'abcdefghijklmnopqrstuvwxyz';
$charset .= '0123456789';
//$charset .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
//$charset .= '~`!@#$%^&*()-_\/\'";:,.+=<>? ';
#########################################################

function check($password)
{
if (hash(HASH_ALGO, $password) == HASH) {
echo 'FOUND MATCH, password: '.$password."\r\n";
exit;
}
}


function recurse($width, $position, $base_string)
{
global $charset;

for ($i = 0; $i < strlen($charset); ++$i) {
if ($position < $width - 1) {
recurse($width, $position + 1, $base_string . $charset[$i]);
}
check($base_string . $charset[$i]);
}
}

echo 'target hash: '.HASH."\r\n";
for ($i = 1; $i < PASSWORD_MAX_LENGTH + 1; ++$i) {
echo 'checking passwords with width: '.$i."\r\n";
recurse($i, 0, '');
}

echo "Execution complete, no password found\r\n";


?>

Dat wil wel, maar het inbouwen van het hervatten werkt niet.
Dus mijn vraag is of A: Hoe kan ik zelf een script maken die alles bij langs gaat, en hervatbaar is? Of B: Hoe kan ik het bovenstaande script dusdanig aanpassen dat het in database zetten hervatbaar is?

Ik hoop dat jullie mij begrijpen? Anders hoor ik het graag!
Niet de tekens, de passwords. Ik denk zodat je het daarna weer opnieuw kan proberen zodra het password nog NIET geraden is, dmv een mysql_num_rows ofzo?
Nee ik wil wel alle tekens erin zetten maar ik kan weinig over mn project vertellen als ie uberhaupt nog van de grond komt :(
maar je wilt nu dus gewoon een script wat alle combinaties genereert met alle letters?
ik zou eens goed nadenken over wat de functie van zo'n gigantische database word en of je die functie op een andere manier kan realiseren,

behalve de enorme hoeveelheid tijd die je erin steekt en de andere problemen die je nu inmiddels al wel gelezen hebt, vraag ik mij af wat je aan een verzameling alphabetische strings hebt
Dat is misschien wel iets waardoor we jou sneller zouden kunnen helpen.
Maar omdat php nogal slecht is in geheugen managment,, word er na de lengte 4 niks meer toegevoegd,,
maar hier dus mijn opzetje voor jou:
<?php
$length = 6;
$possible = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

$tempCombinations = $possible;

$combinations = $possible;

for ($i = 1; $i <= $length - 1; $i++) {
foreach ($tempCombinations as $string) {
foreach ($possible as $char) {
$tempCombinationsA[] = $string . $char;
}
}
$tempCombinations = $tempCombinationsA;
$combinations = array_merge($combinations, $tempCombinationsA);
// Vervang deze code voor het exporteren naar de database!!
echo '<pre>';
print_r($combinations);
echo '</pre>';

//Einde van vervanging
unset($combinations);
$combinations = array();

unset($tempCombinationsA);
}
Oke bedankt!
Maar hoezo voegt php niks meer toe na de lengte van 4 tekens?
Omdat php dan geheugen tekort heeft.
Je kan in je wamp even proberen om je geheugen te vergroten,, naar laten we zeggen, 2 GB ofzo
BTW,
Als je het echt Hard Coded wilt,,
Of je hebt iets,, dit word 1 keer gedaan,, daarna nooit meer:
<?php

/**
* @author Nico Kaag
* @copyright 2010
*/
error_reporting(E_ALL);

$alfabet = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
$combinations = array();
foreach ($alfabet as $charA) {
$combinations[] = $charA;

foreach ($alfabet as $charB) {
$combinations[] = $charA . $charB;

foreach ($alfabet as $charC) {
$combinations[] = $charA . $charB . $charC;

foreach ($alfabet as $charD) {
$combinations[] = $charA . $charB . $charC . $charD;

foreach ($alfabet as $charE) {
$combinations[] = $charA . $charB . $charC . $charD . $charE;

foreach ($alfabet as $charF) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF;

foreach ($alfabet as $charG) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG;

foreach ($alfabet as $charH) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH;

foreach ($alfabet as $charI) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH . $charI;

foreach ($alfabet as $charJ) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH . $charI . $charJ;

foreach ($alfabet as $charK) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH . $charI . $charJ . $charK;

foreach ($alfabet as $charL) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH . $charI . $charJ . $charK . $charL;

foreach ($alfabet as $charM) {
$combinations[] = $charA . $charB . $charC . $charD . $charE . $charF . $charG . $charH . $charI . $charJ . $charK . $charL . $charM;
}
// Vervang deze code voor het exporteren naar de database!!
echo '<pre>';
print_r($combinations);
echo '</pre>';

//Einde van vervanging
unset($combinations);
}
}
}
}
}
}
}
}
}
}
}
}
?>

Maar dit is NIET,,
EN ik zeg nogmaals NIET,
de mooie of goede manier.
Maar het werkt.
En de PrintR moet je dus vervangen door het naar de database schrijven.
(staan iedere keer 27 dingen in,, één leeg, en de rest A-Z)

Reageren