Skip to content

Commit 6875527

Browse files
authored
FIX: fix issue where hashes that are in binary format do not get thei… (#1108)
* fix: fix issue where hashes that are in binary format do not get their cracked plaintext returned through the api
1 parent 087bd05 commit 6875527

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/inc/utils/HashlistUtils.class.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,20 +1130,23 @@ public static function getCrackedHashes($hashlistId, $user) {
11301130
if (!AccessUtils::userCanAccessHashlists($lists, $user)) {
11311131
throw new HTException("No access to the hashlists!");
11321132
}
1133-
11341133
$hashlistIds = Util::arrayOfIds($lists);
11351134
$qF1 = new ContainFilter(Hash::HASHLIST_ID, $hashlistIds);
11361135
$qF2 = new QueryFilter(Hash::IS_CRACKED, 1, "=");
11371136
$hashes = [];
1138-
$entries = Factory::getHashFactory()->filter([Factory::FILTER => [$qF1, $qF2]]);
1137+
$isBinary = $hashlist->getFormat() != 0;
1138+
$factory = $isBinary ? Factory::getHashBinaryFactory() : Factory::getHashFactory();
1139+
$entries = $factory->filter([Factory::FILTER => [$qF1, $qF2]]);
11391140
foreach ($entries as $entry) {
11401141
$arr = [
11411142
"hash" => $entry->getHash(),
11421143
"plain" => $entry->getPlaintext(),
11431144
"crackpos" => $entry->getCrackPos()
11441145
];
1145-
if (strlen($entry->getSalt()) > 0) {
1146-
$arr["hash"] .= $hashlist->getSaltSeparator() . $entry->getSalt();
1146+
if ($hashlist->getIsSalted()) {
1147+
if (strlen($entry->getSalt()) > 0) {
1148+
$arr["hash"] .= $hashlist->getSaltSeparator() . $entry->getSalt();
1149+
}
11471150
}
11481151
$hashes[] = $arr;
11491152
}

0 commit comments

Comments
 (0)