Skip to content

Instantly share code, notes, and snippets.

@roycewilliams
Last active January 15, 2019 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roycewilliams/6df8c53c35f5448171714155d95b1eb4 to your computer and use it in GitHub Desktop.
Save roycewilliams/6df8c53c35f5448171714155d95b1eb4 to your computer and use it in GitHub Desktop.
Crude example of using rules for the fourth word to accelerate performance of hashcat attack of 4-way Diceware (separated by spaces)
#!/bin/bash
#-----------------------------------------------------------------------
# Crude example of using rules for the fourth word to accelerate
# performance of hashcat attack on a four-word Diceware passphrase,
# separated by spaces
#-----------------------------------------------------------------------
TEST_PLAIN="vine embalm blood micro"
TEST_MD5=$(echo -n ${TEST_PLAIN} | md5sum | awk '{print $1}')
pp64() { /usr/local/bin/pp64.bin $*; }
#-----------------------------------------------------------------------
# Remember to patch princeprocessor for longer password lengths.
#
# 28 = (6 (length of longest Diceware word) + 1 (prepended space)) x 4 (wordcount) = 28
# --- pp.c-dist 2019-01-14 21:33:46.443328919 -0900
# +++ pp.c 2019-01-14 21:28:24.224837741 -0900
# @@ -29,7 +29,7 @@
# #define IN_LEN_MAX 32
# #define OUT_LEN_MAX 32 /* Limited by (u32)(1 << pw_len - 1) */
# #define PW_MIN 1
# -#define PW_MAX 16
# +#define PW_MAX 28
# #define ELEM_CNT_MIN 1
# #define ELEM_CNT_MAX 8
# #define WL_DIST_LEN 0
#-----------------------------------------------------------------------
# Process Diceware list.
awk '$1=/[1-6]{5}/ {print $2}' diceware.wordlist.asc \
> diceware.list
wc -l diceware.list
head diceware.list
echo ""
sed 's/^/ /g' diceware.list >diceware.space-prepended.list
wc -l diceware.space-prepended.list
head diceware.space-prepended.list
echo ""
#-----------------------------------------------------------------------
# Generate rules.
sed 's/\|/ $/g;s/^ /$ /g;s/\$$//g' diceware.list > diceware-pos4-space.rule
wc -l diceware-pos4-space.rule
head diceware-pos4-space.rule
echo ""
echo "- Test plain: ${TEST_PLAIN}"
echo "- Test MD5 ${TEST_MD5}"
echo ${TEST_MD5} >diceware.hash
ls -la diceware.hash
cat diceware.hash
echo ""
#-----------------------------------------------------------------------
# Test.
pp64 --elem-cnt-min=3 --elem-cnt-max=3 diceware.space-prepended.list \
| cut -b2- \
| hashcat -w 4 -O -m 0 -a 0 -r diceware-pos4-space.rule diceware.hash
#-----------------------------------------------------------------------
exit
#-----------------------------------------------------------------------
# Performance is definitely meh (and notice GPU utilization %) ...
# (basically, ~7.4% of benchmark):
#
Session..........: hashcat
Status...........: Running
Hash.Type........: MD5
Hash.Target......: 54b349e56ab283229119a203065eaf48
Time.Started.....: Mon Jan 14 21:36:29 2019 (29 secs)
Time.Estimated...: Mon Jan 14 21:36:58 2019 (0 secs)
Guess.Base.......: Pipe
Guess.Mod........: Rules (diceware-pos4-space.rule)
Speed.#1.........: 1860.4 MH/s (23.87ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#2.........: 1858.9 MH/s (24.47ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#3.........: 1843.1 MH/s (24.34ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#4.........: 1843.3 MH/s (24.07ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#5.........: 1841.1 MH/s (23.89ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#6.........: 1791.2 MH/s (24.19ms) @ Accel:128 Loops:256 Thr:256 Vec:1
Speed.#*.........: 10889.1 MH/s
Recovered........: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.........: 293496422400
Rejected.........: 0
Restore.Point....: 0
Restore.Sub.#1...: Salt:0 Amplifier:0-256 Iteration:0-256
Restore.Sub.#2...: Salt:0 Amplifier:7680-7776 Iteration:0-256
Restore.Sub.#3...: Salt:0 Amplifier:7680-7776 Iteration:0-256
Restore.Sub.#4...: Salt:0 Amplifier:7680-7776 Iteration:0-256
Restore.Sub.#5...: Salt:0 Amplifier:7680-7776 Iteration:0-256
Restore.Sub.#6...: Salt:0 Amplifier:4608-4864 Iteration:0-256
Candidates.#1....: o idle n a -> g 1975 abject amulet
Candidates.#2....: x vent g 33rd -> l gd gt @
Candidates.#3....: 2 kc hd 33rd -> 9 # merle @
Candidates.#4....: m gd gt 33rd -> 1 kc hd @
Candidates.#5....: ! # merle 33rd -> t mz hr @
Candidates.#6....: u mz hr oint -> n idle n persia
Hardware.Mon.#1..: Temp: 37c Fan: 80% Util: 0% Core:1911MHz Mem:4513MHz Bus:8
Hardware.Mon.#2..: Temp: 36c Fan: 80% Util: 0% Core:1873MHz Mem:4513MHz Bus:4
Hardware.Mon.#3..: Temp: 44c Fan: 80% Util: 0% Core:1885MHz Mem:4513MHz Bus:16
Hardware.Mon.#4..: Temp: 40c Fan: 80% Util: 0% Core:1885MHz Mem:4513MHz Bus:4
Hardware.Mon.#5..: Temp: 37c Fan: 80% Util: 46% Core:1911MHz Mem:4513MHz Bus:1
Hardware.Mon.#6..: Temp: 40c Fan: 80% Util:100% Core:1898MHz Mem:4513MHz Bus:1
#-----------------------------------------------------------------------
# ... compared to benchmark (on same system with same parameters):
#
$ hashcat -b -m 0 -w 4 -O
hashcat (v5.1.0-25-g050b54b8) starting in benchmark mode...
OpenCL Platform #1: NVIDIA Corporation
======================================
* Device #1: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
* Device #2: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
* Device #3: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
* Device #4: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
* Device #5: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
* Device #6: GeForce GTX 1080, 2029/8119 MB allocatable, 20MCU
OpenCL Platform #2: Advanced Micro Devices, Inc.
================================================
* Device #7: AMD FX(tm)-8350 Eight-Core Processor, skipped.
Benchmark relevant options:
===========================
* --optimized-kernel-enable
* --workload-profile=4
Hashmode: 0 - MD5
Speed.#1.........: 24851.6 MH/s (26.85ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#2.........: 24476.5 MH/s (27.22ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#3.........: 24605.6 MH/s (27.08ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#4.........: 24723.0 MH/s (26.95ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#5.........: 24844.6 MH/s (26.78ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#6.........: 24730.8 MH/s (26.84ms) @ Accel:128 Loops:1024 Thr:256 Vec:4
Speed.#*.........: 148.2 GH/s
Started: Mon Jan 14 21:41:00 2019
Stopped: Mon Jan 14 21:41:21 2019
#-----------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment