hashcat / hashcat-utils

Small utilities that are useful in advanced password cracking
MIT License
1.33k stars 353 forks source link

Added combinatorX, version 1.0 #58

Closed matrix closed 3 years ago

matrix commented 3 years ago

Hi Jens,

i modified your combinator3, creating an improved version which I called "combinatorX". Following the help with an example.

Usage: ./combinatorX.bin [<options>]

Options:

  Argument   | Type        | Description                           | Option type | Example
  ----------------------------------------------------------------------------------------------
  --file1    | Path        | Set file1 path                        | required    | --file1 wordlist1.txt
  --file2    | Path        | Set file2 path                        | required    | --file2 wordlist2.txt
  --file3    | Path        | Set file3 path                        | optional    | --file3 wordlist3.txt
  --file4    | Path        | Set file4 path                        | optional    | --file4 wordlist4.txt

  --sepStart | Char/String | Set char/string at the beginning      | optional    | --sepStart '['
  --sep1     | Char/String | Set separator between file1 and file2 | optional    | --sep1 'a.'
  --sep2     | Char/String | Set separator between file2 and file3 | optional    | --sep2 'bc'
  --sep3     | Char/String | Set separator between file3 and file4 | optional    | --sep3 ',d'
  --sepEnd   | Char/String | Set char/string at the end            | optional    | --sepEnd ']'

Example:

input files: 1 2 3 4
$ cat 1 2 3 4 | xargs
one two three four
$ ./combinatorX.bin --file1 1 --file2 2 --file3 3 --file4 4 --sep1 ' . ' --sep2 ' + ' --sep3 ' @ ' --sepStart "['" --sepEnd ',*]'
['one . two + three @ four,*]

See you soon, Gabriele

lacroixboi commented 3 years ago

Hi @matrix,

After using this feature I have a suggestion that I think would make it stronger. I'd love to see an interface for this that uses a mask. This would allow for permutations in separators.

The mask arg could accept non-tokenized chars as well, allowing you to support the --sepStart and --sepEnd args; though this also lets you put in static chars anywhere in the mask.

To support your original example, I could imagine the use case being something in the shape of:

$ ./combinatorX.bin -1 words.txt -2 separators.txt ['?1?2?1?2?1$2$1,*]
jsteube commented 3 years ago

Getting some ugly warnings, please fix (even if it's just a continue statement):

combinatorX.c: In function ‘session_init’:
combinatorX.c:79:5: warning: ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result [-Wunused-result]
   79 |     ftruncate (fileno (sfp), ftell (sfp));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c:85:3: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c: In function ‘session_update’:
combinatorX.c:104:3: warning: ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result [-Wunused-result]
  104 |   ftruncate (fileno (sfp), ftell (sfp));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jsteube commented 3 years ago

More warnings:

combinatorX.c: In function ‘session_init’:
combinatorX.c:77:41: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                         ^
combinatorX.c:77:45: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                             ^
combinatorX.c:77:49: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                 ^
combinatorX.c:77:53: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                     ^
combinatorX.c:77:57: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                         ^
combinatorX.c:77:19: warning: too many arguments for format [-Wformat-extra-args]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c:77:41: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                         ^
combinatorX.c:77:45: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                             ^
combinatorX.c:77:49: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                 ^
combinatorX.c:77:53: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                     ^
combinatorX.c:77:57: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                                                         ^
combinatorX.c:77:19: warning: too many arguments for format [-Wformat-extra-args]
   77 |     fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu",*off_fd1, *off_fd2, *off_fd3, *off_fd4, *off_fd5, *off_vir_in1, *off_vir_in2, *off_vir_in3, *off_vir_in4, *off_vir_in5);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c:85:34: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                  ^
combinatorX.c:85:38: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                      ^
combinatorX.c:85:42: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                          ^
combinatorX.c:85:46: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                              ^
combinatorX.c:85:16: warning: too many arguments for format [-Wformat-extra-args]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c:85:34: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                  ^
combinatorX.c:85:38: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                      ^
combinatorX.c:85:42: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                          ^
combinatorX.c:85:46: warning: unknown conversion type character ‘z’ in format [-Wformat=]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                                              ^
combinatorX.c:85:16: warning: too many arguments for format [-Wformat-extra-args]
   85 |   fscanf (sfp, "%ld %ld %ld %ld %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c: In function ‘session_update’:
combinatorX.c:102:39: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                       ^
combinatorX.c:102:43: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                           ^
combinatorX.c:102:47: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                               ^
combinatorX.c:102:51: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                                   ^
combinatorX.c:102:55: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                                       ^
combinatorX.c:102:17: warning: too many arguments for format [-Wformat-extra-args]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combinatorX.c:102:39: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                       ^
combinatorX.c:102:43: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                           ^
combinatorX.c:102:47: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                               ^
combinatorX.c:102:51: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                                   ^
combinatorX.c:102:55: warning: unknown conversion type character ‘z’ in format [-Wformat=]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                                                       ^
combinatorX.c:102:17: warning: too many arguments for format [-Wformat-extra-args]
  102 |   fprintf (sfp, "%ld %ld %ld %ld %ld %zu %zu %zu %zu %zu", off_fd1, off_fd2, off_fd3, off_fd4, off_fd5, off_vir_in1, off_vir_in2, off_vir_in3, off_vir_in4, off_vir_in5);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think you need to use PRIu64 macro, see hashcat sources.