crack hash with dictionary from C rand()
#2
you can use a pipe / stdin instead ( ./my_generator.bin | ./hashcat -m 0 -a 0 -O -w 4 hash.txt

it's important that this (your) password candidate generator (my_generator.bin) is optimized and very fast... of course it would work best with slow hashes (but MD5 is of course a very fast hash).

You could try to optimize it by not "printing" each and every password candidate as soon as possible, but use a large buffer instead (buffered)... the size (of each line with newline appended to each password) is fixed anyway.
Some ideas/optimization can be found also in the source code of maskprocessor or similar tools....

so my suggestion is to use pipes with an optimized generator.

you could start with something like this for the my_generator source code and adapt and/or optimize it further:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>

// Author: philsmd
// Date: October 2020
// License: public domain, credits go to philsmd and hashcat

//
// How to compile:
//

// gcc -O2 -o my_generator.bin my_generator.c


//
// Constants:
//

// here we assume that srand (time (0)) is used

#define SEED_MIN 1500000000 // or 0
#define SEED_MAX 1600000000 // or time (0)

#define BUF_SIZE 29 * 35 * 1024 // just under 1 MB

//
// Start:
//

int main ()
{
  // disable buffering:

  setbuf (stdout, NULL);

  // init large buffer:

  unsigned char buf[BUF_SIZE];

  memset (buf, 0x0a, BUF_SIZE); // little hack: set the newline char (\n) only once

  int buf_off = 0; // offset

  // main loop:

  for (size_t seed = SEED_MIN; seed < SEED_MAX; seed++)
  {
    srand (seed);

    for (int i = 0; i < 14; i++)
    {
      buf[buf_off + i] = 'A' + (rand () % 25);
    }

    for (int i = 14; i < 28; i++)
    {
      buf[buf_off + i] = '0' + (rand () %  9);
    }

    buf_off += 29;

    if (buf_off >= BUF_SIZE)
    {
      fwrite (buf, 1, BUF_SIZE, stdout);

      buf_off = 0;
    }
  }

  // final output:

  if (buf_off) fwrite (buf, 1, buf_off, stdout);

  return 0;
}
Reply


Messages In This Thread
RE: crack hash with dictionary from C rand() - by philsmd - 10-10-2020, 10:41 AM