All pastes #559362 Raw Edit

Anonymous

public php v1 · immutable
·published 2007-06-11 18:55 UTC
rendered paste body
<?phpfunction parse_md5sum($filename) {	$fp = fopen($filename, 'rt');	$ln=0;	while (($line = fgets($fp)) !== FALSE) {		$ln++;		if(!preg_match('/([a-fA-F0-9]{32})\s+([ *])(.*)/', $line, $matches)) {			trigger_error("line $ln of md5sum file $filename doesn't match regex",E_USER_WARNING);			continue;		}		$hashes[$matches[1]] = $matches[3];	}	fclose($fp);	return $hashes;}function hash_part($fp,$start,$length) {	$ctx = hash_init('md5');	$remaining=$length;	$chunkSize=65536;	while ($remaining > 0) {		$read = hash_update_stream($ctx, $fp, min($chunkSize, $remaining));		//echo "$read\n";		$remaining -= $read;		//printf("\r%04.1f%%",(1-$remaining/$length)*100);	}	//echo "\n";	return hash_final($ctx);}$hashes = parse_md5sum('sl-x86-3.4.loop1-to-3.4.loop2b.xd3.md5');$fp = fopen('sl-x86-3.4.loop1-to-3.4.loop2b.xd3','rb');$hash = hash_part($fp,0,40*1024*1024);echo "$hash\n";if (isset($hashes[$hash])) {	$file = $hashes[$hash];	echo "We have a match with file $file\n";}fclose($fp);?>Output: >php recover.php40d99ed59fba1844207283d25f833c35We have a match with file sl-x86-3.4.loop1-to-3.4.loop2b.xd3.00>php recover.php40d99ed59fba1844207283d25f833c35We have a match with file sl-x86-3.4.loop1-to-3.4.loop2b.xd3.00>php recover.php40d99ed59fba1844207283d25f833c35We have a match with file sl-x86-3.4.loop1-to-3.4.loop2b.xd3.00>php recover.php02621f7530933bab8dea50a61ff25003>php recover.php40d99ed59fba1844207283d25f833c35We have a match with file sl-x86-3.4.loop1-to-3.4.loop2b.xd3.00