hashcat / princeprocessor

Standalone password candidate generator using the PRINCE algorithm
Other
425 stars 98 forks source link

IN_LEN_MIN, IN_LEN_MAX, PW_MIN, and PW_MAX #20

Closed Sc00bz closed 9 years ago

Sc00bz commented 9 years ago

I was under the impression that IN_LEN_MIN and IN_LEN_MAX were for reading words and PW_MIN and PW_MAX were for outputting passwords. This is not the case it appears that PW_MIN and PW_MAX are just used as default values for pw_min and pw_max.

We should do one of these:

magnumripper commented 9 years ago

Also, I believe ELEM_CNT_MAX is now only a default (real max is current pw_max) and this means we have a bug here (I think)

typedef struct
{
  elem_t  *elems_buf;
  u64      elems_cnt;
  u64      elems_alloc;

  chain_t *chains_buf;
  int      chains_cnt;
  int      chains_pos;
  int      chains_alloc;

-  u64      cur_chain_ks_poses[ELEM_CNT_MAX];
+  u64      cur_chain_ks_poses[IN_LEN_MAX];

} db_entry_t;

Right?

magnumripper commented 9 years ago

Oh, and there are many more places we should s/ELEM_CNT_MAX/IN_LEN_MAX/g for the same reason.

Sc00bz commented 9 years ago

Nope that's suppose to be ELEM_CNT_MAX... wait there's no check for elem_cnt_max <= ELEM_CNT_MAX. Huh that is a bug. Either ELEM_CNT_M* should be DEFAULT_ELEM_CNT_M* or made like how I thought it was.

jsteube commented 9 years ago

Usually I do default's by setting a macro that has the same name as the variable in main but uppercasing it. So indeed, in this case it's actually just a default, but I don't like adding a substring like DEFAULT or DEFAULT to the macro to much. I'd like to keep this.

Just to explain the values and what my intention was. The pw_min/max is actually out_pwmin/max. Because of historical reason and for backward compatibility I omit the out substring. I'd like to keep this as well.

The IN_LEN_MIN/MAX is just to set the size of the arrays and to avoid to use a malloc() for them at runtime. We can rename those if required.

The ELEM_CNT_MIN/MAX is really to define a range of allowed elements per chain. For example with min=4 and max=4 we can nicely crack "Correct Horse Battery Staple" passphrases. Therefore, what magnum said in an issue before that ELEM_CNT_MAX can not be greater than PW_MAX is true.

After all this, what do recommend to do now?

Sc00bz commented 9 years ago

Wait so is ELEM_CNT_MAX suppose to be a limit or a default because right now it's limit is only pw_max: https://github.com/jsteube/princeprocessor/blob/02fb0de3e389b2297c16742830acd4046f30c581/src/pp.c#L645

Sc00bz commented 9 years ago

Also I can live without any changes besides the bugs that I introduced because I thought they were limits not defaults.

jsteube commented 9 years ago

It's supposed to be a default for a variable. There's a bug for sure

jsteube commented 9 years ago

Hm after looking again on it, I don't see a problem here. Can you explain in a demonstration maybe?

Sc00bz commented 9 years ago

db_entry_t's cur_chain_ks_poses is using ELEM_CNT_MAX but with --elem-cnt-max you can set that as high as pw_max.

Sc00bz commented 9 years ago

Just fixed it https://github.com/jsteube/princeprocessor/pull/22

jsteube commented 9 years ago

OK, merged. Thanks!