-
Notifications
You must be signed in to change notification settings - Fork 2
/
oclhcbench2csv
executable file
·267 lines (246 loc) · 5.89 KB
/
oclhcbench2csv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/oclhcbench2csv
#
hashmode=""
inhm=0
sidx=0
insp=0
debug() {
if [ ${debug:-0} -gt 0 ]
then
echo "$*"
fi
}
psys() {
# uname -nrpo
# "myhostname 4.15.0-46-generic x86_64 GNU/Linux"
sys=$(uname -nrpo)
hn=${sys%% *}
sys=${sys#* }
kv=${sys%% *}
sys=${sys#* }
arch=${sys%% *}
sys=${sys#* }
if [ -n "${sys}" -a -z "${sys##*Linux*}" ]
then
mem=$(grep MemTotal: /proc/meminfo | awk '{print $2}') # closer to actual
else
mem=$(free | grep ^Mem | awk '{print $2}') # less accurate
fi
echo "*,999999,System Info,0,${hn};${sys};${kv};${arch};${mem}kb"
}
dprint() {
# "* Device #1: GeForce GTX 560M, 368/1473 MB allocatable, 4MCU" ->
# 1,999999,INFO,0,GeForce GTX 560M; 368/1473 MB allocatable; 4MCU"
dm=${*}
dm1=${dm#Device #}
dm2="${dm1#*: }"
dm2=${dm2//,/;}
dm2=${dm2// @/;}
dm1=${dm1%:*}
echo "${dm1},999999,Device Info,0,${dm2}"
}
hmprint() {
# * Hash-Mode 7100 (macOS v10.8+ (PBKDF2-SHA512)) [Iterations: 1023]
# "Hashmode: 0 - MD5" -> (OR)
# "Hash-Mode 11300
# "Hash-Mode 0 (MD5)" ->
# "* Hash-Mode 1700 (SHA2-512)"
# "0,MD5"
hm="$*"
hm1=${hm#*Hashmode: }
hm1=${hm1#*Hash-Mode }
hm1=${hm1//[)(]/}
hm2=${hm1#* - }
hm1=${hm1%% *}
hm2=${hm2/$hm1 }
hm2=${hm2//,/;}
hm2=${hm2//+( )/ }
hm2=${hm2//[/(}
hm2=${hm2//]/)}
HM2P="${hm1},${hm2}"
}
slprint() {
# "Speed.#*.........: 172.2 MH/s (389.83ms) @ Accel:1024 Loops:512 Thr:32 Vec:1" -> OR
# "Speed.#2.........: 140.6 MH/s (89.29ms) @ Accel:1024 Loops:1024 Thr:1 Vec:8" ->
# "1,172.2 MH/s,(389.83ms) @ Accel:1024 Loops:512 Thr:32 Vec:1"
sl="$*"
sl=${sl,,}
sl1=${sl%%:*}
sl1=${sl1#speed.#}
sl1=${sl1//\./}
sl2=${sl#speed.*:}
sl3=${sl2#*h/s }
sl3=${sl3//,/;}
sl2="${sl2%h/s*}h/s"
sl2=${sl2// /}
sl2=${sl2//gh\/s/ * 1000000000}
sl2=${sl2//mh\/s/ * 1000000}
sl2=${sl2//kh\/s/ * 1000}
sl2=${sl2//h\/s/ * 1}
sl2=$( echo "scale=0; (${sl2}) / 1" | bc )
[[ "${sl1}" = "*" ]] && sl3="grand total for all devices"
if [ "${sl1}" != "*" -o ${total:-0} -eq 1 ]
then
echo "${sl1},${HM2P},${sl2},${sl3}"
fi
}
if [ -n "$*" ]
then
for opt in $*
do
if [ "${opt,,}" = "debug" ]
then
debug=1
elif [ "${opt,,}" = "total" ]
then
total=1
else
echo "IGN: unknown argument"
fi
done
fi
echo "#device, #mode, #mdesc, #hashes, #info"
psys
while read line
do
if [ -n "${line}" ]
then
debug "good, line is not empty"
# This parse has to happen before generic device name parsing
if [ -z "${line##*Skipping*}" ]
then
# support "Device #1: Skipping hash-mode 7701)"
debug "Hashmode being skipped"
skip=1
fi
if [ ${inhm:-0} -eq 0 -a ${insp:-0} -eq 0 ]
then
if [ -z "${line%\* Device #*}" -a -n "${line##*skipped*}" -a -n "${line##*WARNING*}" ]
then
# kill extra spaces in the device line
line=${line//\*/}
set -- $line
dprint "$*"
fi
fi
if [ -z "${line##*starting in benchmark mode*}" ]
then
ver=${line#*\(}
ver=${ver%\)*}
if [ ${kver:-0} -lt 1 ]
then
kver=1
echo "*,999999,Hashcat Info,0,${ver}"
fi
sidx=0
inhm=0
insp=0
unset speedline
unset hashmode
fi
debug "checking for hashmode"
if [ -z "${line%%*Hashmode*}" -o -z "${line%%*Hash-Mode*}" ]
then
debug "line has a Hashmode"
if [ $sidx -gt 0 ]
then
debug "showing old Hashmode"
hmprint "$hashmode"
debug "sidx=$sidx"
for (( i=1; i<=$sidx; i++ ))
do
slprint "${speedline[$i]}"
done
unset speedline
debug "setting new hashmode"
hashmode="${line}"
sidx=0
insp=0
elif [ $inhm -eq 1 -a $sidx -lt 1 ]
then
if [ ${skip:-0} -eq 1 ]
then
debug "reporting that this mode was skipped"
err="skipping reported by hashcat"
else
debug "found a new Hashmode line without a corresponding speed line"
err="unknown error"
fi
hmprint "$hashmode"
slprint "Speed.#*.........: 0 H/s $err"
debug "setting a new hashmode"
hashmode=${line}
inhm=1
skip=0
else
debug "set a Hashmode"
hashmode=${line}
inhm=1
fi
elif [ -z "${line%Speed*}" ]
then
debug "line has a Speed"
if [ $inhm -eq 1 ]
then
debug "set a speed "
sidx=$((sidx + 1))
speedline[$sidx]=${line}
insp=1
else
echo "found our way into a speedline without being in a hashmode!"
debug "$line"
sidx=0
inhm=0
insp=0
unset speedline
unset hashmode
fi
elif [ -z "${line%Stopped*}" ]
then
if [ $inhm -eq 1 -a $sidx -gt 0 ]
then
debug "showing old Hashmode"
hmprint "$hashmode"
debug "sidx=$sidx"
for (( i=1; i<=$sidx; i++ ))
do
slprint "${speedline[$i]}"
done
elif [ $inhm -eq 1 -a $sidx -eq 0 ]
then
debug "stopped on a hash without speed"
hmprint "$hashmode"
slprint "Speed.#*.........: 0 H/s unknown error"
else
debug "ended cleanly"
exit 0
fi
else
debug "$line"
fi
fi
# sleep 1
done
# Handle EOF
if [ $inhm -eq 1 -a $sidx -gt 0 ]
then
debug "showing old Hashmode"
hmprint "$hashmode"
debug "sidx=$sidx"
for (( i=1; i<=$sidx; i++ ))
do
slprint "${speedline[$i]}"
done
elif [ $inhm -eq 1 -a $sidx -eq 0 ]
then
debug "stopped on a hash without speed"
hmprint "$hashmode"
slprint "Speed.#*.........: 0 H/s unknown error"
else
debug "ended cleanly"
fi
exit 0