From 6875527c6ebfb4760e6aea2a588c49095c565d14 Mon Sep 17 00:00:00 2001 From: yungcero <133906218+yungcero@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:24:57 -0700 Subject: [PATCH] =?UTF-8?q?FIX:=20fix=20issue=20where=20hashes=20that=20ar?= =?UTF-8?q?e=20in=20binary=20format=20do=20not=20get=20thei=E2=80=A6=20(#1?= =?UTF-8?q?108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: fix issue where hashes that are in binary format do not get their cracked plaintext returned through the api --- src/inc/utils/HashlistUtils.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/inc/utils/HashlistUtils.class.php b/src/inc/utils/HashlistUtils.class.php index 192448fc3..314be9992 100644 --- a/src/inc/utils/HashlistUtils.class.php +++ b/src/inc/utils/HashlistUtils.class.php @@ -1130,20 +1130,23 @@ public static function getCrackedHashes($hashlistId, $user) { if (!AccessUtils::userCanAccessHashlists($lists, $user)) { throw new HTException("No access to the hashlists!"); } - $hashlistIds = Util::arrayOfIds($lists); $qF1 = new ContainFilter(Hash::HASHLIST_ID, $hashlistIds); $qF2 = new QueryFilter(Hash::IS_CRACKED, 1, "="); $hashes = []; - $entries = Factory::getHashFactory()->filter([Factory::FILTER => [$qF1, $qF2]]); + $isBinary = $hashlist->getFormat() != 0; + $factory = $isBinary ? Factory::getHashBinaryFactory() : Factory::getHashFactory(); + $entries = $factory->filter([Factory::FILTER => [$qF1, $qF2]]); foreach ($entries as $entry) { $arr = [ "hash" => $entry->getHash(), "plain" => $entry->getPlaintext(), "crackpos" => $entry->getCrackPos() ]; - if (strlen($entry->getSalt()) > 0) { - $arr["hash"] .= $hashlist->getSaltSeparator() . $entry->getSalt(); + if ($hashlist->getIsSalted()) { + if (strlen($entry->getSalt()) > 0) { + $arr["hash"] .= $hashlist->getSaltSeparator() . $entry->getSalt(); + } } $hashes[] = $arr; }