@@ -303,10 +303,11 @@ public static function rename($hashlistId, $name, $user) {
303303 * @param array $post
304304 * @param array $files
305305 * @param User $user
306+ * @param boolean $overwritePlaintext
306307 * @return int[]
307308 * @throws HTException
308309 */
309- public static function processZap ($ hashlistId , $ separator , $ source , $ post , $ files , $ user ) {
310+ public static function processZap ($ hashlistId , $ separator , $ source , $ post , $ files , $ user, $ overwritePlaintext ) {
310311 // pre-crack hashes processor
311312 $ hashlist = HashlistUtils::getHashlist ($ hashlistId );
312313 if (!AccessUtils::userCanAccessHashlists ($ hashlist , $ user )) {
@@ -427,16 +428,22 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
427428 }
428429 else if ($ hashEntry ->getIsCracked () == 1 ) {
429430 $ alreadyCracked ++;
430- continue ;
431+ if (!$ overwritePlaintext ) {
432+ continue ;
433+ }
431434 }
432435 $ plain = str_replace ($ hash . $ separator . $ hashEntry ->getSalt () . $ separator , "" , $ data );
433436 if (strlen ($ plain ) > SConfig::getInstance ()->getVal (DConfig::PLAINTEXT_MAX_LENGTH )) {
434437 $ tooLong ++;
435438 continue ;
436439 }
437440 $ hashFactory ->mset ($ hashEntry , [Hash::PLAINTEXT => $ plain , Hash::IS_CRACKED => 1 , Hash::TIME_CRACKED => time ()]);
438- $ newCracked ++;
439- $ crackedIn [$ hashEntry ->getHashlistId ()]++;
441+
442+ if ($ hashEntry ->getIsCracked () != 1 ) {
443+ $ newCracked ++;
444+ $ crackedIn [$ hashEntry ->getHashlistId ()]++;
445+ }
446+
440447 if ($ hashlist ->getFormat () == DHashlistFormat::PLAIN ) {
441448 $ zaps [] = new Zap (null , $ hashEntry ->getHash (), time (), null , $ hashlist ->getId ());
442449 }
@@ -469,19 +476,28 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
469476 foreach ($ hashEntries as $ hashEntry ) {
470477 if ($ hashEntry ->getIsCracked () == 1 ) {
471478 $ alreadyCracked ++;
472- continue ;
479+ if (!$ overwritePlaintext ) {
480+ continue ;
481+ }
473482 }
483+
474484 $ plain = str_replace ($ hash . $ separator , "" , $ data );
485+
475486 if (strlen ($ plain ) > SConfig::getInstance ()->getVal (DConfig::PLAINTEXT_MAX_LENGTH )) {
476487 $ tooLong ++;
477488 continue ;
478489 }
490+
479491 $ hashFactory ->mset ($ hashEntry , [Hash::PLAINTEXT => $ plain , Hash::IS_CRACKED => 1 , Hash::TIME_CRACKED => time ()]);
480- $ crackedIn [$ hashEntry ->getHashlistId ()]++;
492+
493+ if ($ hashEntry ->getIsCracked () != 1 ) {
494+ $ newCracked ++;
495+ $ crackedIn [$ hashEntry ->getHashlistId ()]++;
496+ }
497+
481498 if ($ hashlist ->getFormat () == DHashlistFormat::PLAIN ) {
482499 $ zaps [] = new Zap (null , $ hashEntry ->getHash (), time (), null , $ hashlist ->getId ());
483500 }
484- $ newCracked ++;
485501 }
486502 }
487503 $ bufferCount ++;
0 commit comments