hashcat Forum
Mask starting with a dash - Printable Version

+- hashcat Forum (https://hashcat.net/forum)
+-- Forum: Support (https://hashcat.net/forum/forum-3.html)
+--- Forum: hashcat (https://hashcat.net/forum/forum-45.html)
+--- Thread: Mask starting with a dash (/thread-7484.html)



Mask starting with a dash - mrfancypants - 05-08-2018

Looks like hashcat has a problem with masks that start with a dash:
Code:
e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files -?d
hashcat64: unknown option -- ?
Invalid argument specified.

e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files "-?d"
hashcat64: unknown option -- ?
Invalid argument specified.


e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files "\-?d"

hashcat (v4.1.0) starting...
<snip>
Candidates.#1....: angel\-1 -> zzzoe\-7

e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files $HEX[2D]?d
hashcat (v4.1.0) starting...
<snip>
Candidates.#1....: angel$HEX[2D]1 -> zzzoe$HEX[2D]7

e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files ?-?d

hashcat (v4.1.0) starting...
<snip>
Syntax error: ?-?d

e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable 66343_left.txt files '-?d'

hashcat (v4.1.0) starting...
Candidates.#1....: angel'-1' -> zzzoe'-7'

Finally got it to work:
Code:
e:\hashcat-4.1.0>hashcat64 -O -w 3 -m 0 -a 6 --gpu-temp-disable -1 - 66343_left.txt files ?1?d
<snip>
Candidates.#1....: angel-1 -> zzzoe-3

But that's not an immediately obvious solution, and the documentation does not mention any need for special treatment of a dash.


RE: Mask starting with a dash - philsmd - 05-08-2018

I don't think this is a problem of hashcat, but this is how most command line tools work.
a dash is a special character and denotes the beginning of a command line parameter.
one dash introduces a short argument
two dashes introduce a long argument

Getopts (https://en.wikipedia.org/wiki/Getopts) for instance is kind of a defacto standard.
It's similar to a dollar sign ($) that is interpreted by your shell as a reference to a variable... or file globbing within your command.
There are slight differences of course, the shell intreprets the globbing and variable reference before hashcat even sees the final command, while getopts is used in terms of a library within the hashcat binary... but the "problem" and solutions are similar, you need to escape the special characters.


RE: Mask starting with a dash - mrfancypants - 05-08-2018

But, as my examples show, hashcat won't honor any attempts to escape the leading dash. If I write '-?d' or \-?d instead of -?d, that $ or \ goes straight into the mask.

And besides, it should be able to recognize that, in this situation, -?d is a mask rather than a command line option.

Code:
Usage: hashcat [options]... hash|hashfile|hccapxfile [dictionary|mask|directory]...

In mode 6, it expects to find two filenames and a mask in the options. I give it two filenames and a mask. Its own usage instructions do not suggest that there might be another command-line option after the first filename.


RE: Mask starting with a dash - philsmd - 05-08-2018

The general rule for any command line tool using the (defacto) standard way of using arguments (getopts) is that the user needs to specify when the list of arguments is over and the remaining parameters (non-short or non-long args) start, e.g:
Code:
hashcat --stdout -a 3 -- -?d

The -- tells the command line parser that there are no more short or long arguments within the command line and the remaining arguments should be used AS-IS (without interpreting the dashes etc).

BTW: the --hex-charset approach should also work with
Code:
hashcat --stdout --hex-charset -a 3 2d?d



RE: Mask starting with a dash - mrfancypants - 05-08-2018

Okay, that would work.