Skip to content

rules.c: Simplify the latest bugfix to stacked rules #5725

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

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/john.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2024 by Solar Designer
*
* ...with changes in jumbo by JimF, magnum, Claudio, and several others
* Copyright (c) 2009-2025, magnum
* Copyright (c) 2021, Claudio
* Copyright (c) 2009-2018, JimF
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
Expand Down Expand Up @@ -1947,6 +1948,7 @@ static void john_done(void)
/* We already printed to stderr from signals.c */
log_event("%s", abort_msg);
} else if (children_ok) {
log_event("Candidates tried: %"PRIu64"p", status.cands);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also log suppressor's hits and misses, which is info that is otherwise impossible to access at session end (no way to press s at exactly the right moment).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a new function in status.c, right? You could create a ticket for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a new function in status.c, right?

No, it's status.suppressor_hit and status.suppressor_miss just like status.cands that you use.

log_event("Session completed");
if (john_main_process) {
fprintf(stderr, "Session completed. %s\n", mode_exit_message);
Expand Down
24 changes: 9 additions & 15 deletions src/rules.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-99,2003,2005,2009,2010,2015,2016 by Solar Designer
*
* With heavy changes in Jumbo, by JimF and magnum
* Copyright (c) 2009-2025, magnum
* Copyright (c) 2009-2018, JimF
*/

#include <stdio.h>
Expand Down Expand Up @@ -1855,39 +1855,33 @@ char *rules_process_stack_all(char *key, rule_stack *ctx)
if (!ctx->rule) {
ctx->rule = ctx->stack_rule->head;
rules_stacked_number = 0;
if (!stack_rules_mute)
log_event("+ Stacked Rule #%u: '%.100s' accepted",
rules_stacked_number + 1, ctx->rule->data);
} else {
if ((ctx->rule = ctx->rule->next)) {
rules_stacked_number++;
if (!stack_rules_mute)
log_event("+ Stacked Rule #%u: '%.100s' accepted",
rules_stacked_number + 1, ctx->rule->data);
}
}

rules_stacked_after = 0;

while (ctx->rule) {
if (!stack_rules_mute)
log_event("+ Stacked Rule #%u: '%.100s' accepted",
rules_stacked_number + 1, ctx->rule->data);
if ((word = rules_apply(key, ctx->rule->data, -1)))
return word;
if ((ctx->rule = ctx->rule->next)) {
rules_stacked_number++;
if (!stack_rules_mute)
log_event("+ Stacked Rule #%u: '%.100s' accepted",
rules_stacked_number + 1, ctx->rule->data);
}
}

rules_stacked_after = !!(options.flags & (FLG_RULES_CHK | FLG_SINGLE_CHK | FLG_BATCH_CHK));

if (!stack_rules_mute && options.verbosity <= VERB_DEFAULT) {
if (!stack_rules_mute && options.verbosity < VERB_DEBUG) {
stack_rules_mute = 1;
if (john_main_process) {
log_event(
"- Some rule logging suppressed. Re-enable with --verbosity=%d or greater",
VERB_LEGACY);
VERB_DEBUG);
}
}

Expand Down Expand Up @@ -2124,12 +2118,12 @@ int rules_count(struct rpp_context *start, int split)
}

if (((options.flags & FLG_PIPE_CHK) && count1 >= RULES_MUTE_THR) &&
options.verbosity < VERB_LEGACY) {
options.verbosity < VERB_DEBUG) {
rules_mute = 1;
if (john_main_process) {
log_event(
"- Some rule logging suppressed. Re-enable with --verbosity=%d or greater",
VERB_LEGACY);
VERB_DEBUG);
}
}
return count1;
Expand Down
4 changes: 2 additions & 2 deletions src/single.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,12 @@ static void single_run(void)
if (rules_stacked_after) {
saved_min[0] = rule_number = 0;
rpp_init(rule_ctx, options.activesinglerules);
if (!rules_mute && options.verbosity <= VERB_DEFAULT) {
if (!rules_mute && options.verbosity < VERB_DEBUG) {
rules_mute = 1;
if (john_main_process) {
log_event(
"- Some rule logging suppressed. Re-enable with --verbosity=%d or greater",
VERB_LEGACY);
VERB_DEBUG);
}
}
}
Expand Down