Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding loops to scan through lines to support importing hashes longer then 1024 bytes #1062

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/inc/utils/HashlistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,19 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
$startTime = time();

//find the line separator
$buffer = fread($file, 1024);
$lineSeparators = array("\r\n", "\n", "\r");
$lineSeparator = "";
foreach ($lineSeparators as $sep) {
if (strpos($buffer, $sep) !== false) {
$lineSeparator = $sep;

// This will loop through the buffer until it finds a line separator
while (!feof($file)) {
$buffer = fread($file, 1024);
foreach ($lineSeparators as $ls) {
if (strpos($buffer, $ls) !== false) {
$lineSeparator = $ls;
break;
}
}
if (!empty($lineSeparator)) {
break;
}
}
Expand Down Expand Up @@ -387,7 +394,18 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
$crackedIn[$l->getId()] = 0;
}
while (!feof($file)) {
$data = stream_get_line($file, 1024, $lineSeparator);
$data = '';
while(($line = stream_get_line($file, 1024, $lineSeparator)) !== false){
$data .= $line;
// seek back the length of lineSeparator and check if it indeed was a line separator
// If no lineSeperator was found, make sure not to check but just to keep reading
if (strlen($lineSeparator) > 0) {
fseek($file, strlen($lineSeparator) * -1, SEEK_CUR);
if (fread($file, strlen($lineSeparator)) === $lineSeparator) {
break;
}
}
}
if (strlen($data) == 0) {
continue;
}
Expand Down
Loading