Simple Expect program to send a key when the program yields some text

0

I need to run this program:

Luis@Windu /cygdrive/c/Temporal/Expect$ oclhashcat64 ../Test.hccap -m 2500 -a 3 ?d?d?d?d?d?d?d?d
oclHashcat v1.31 starting...

Device #1: Bonaire, 1024MB, 1050Mhz, 12MCU
Device #2: Tahiti, 3072MB, 900Mhz, 28MCU

Hashes: 1 hashes; 1 unique digests, 1 unique salts
Bitmaps: 8 bits, 256 entries, 0x000000ff mask, 1024 bytes
Applicable Optimizers:
* Zero-Byte
* Single-Hash
* Single-Salt
* Brute-Force
Watchdog: Temperature abort trigger set to 90c
Watchdog: Temperature retain trigger set to 80c
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/m02500.Bonaire_1573.4_1573.4 (VM).kernel (259320 bytes)
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/markov_le_v1.Bonaire_1573.4_1573.4 (VM).kernel (92404 bytes)
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/bzero.Bonaire_1573.4_1573.4 (VM).kernel (30496 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/m02500.Tahiti_1573.4_1573.4 (VM).kernel (259428 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/markov_le_v1.Tahiti_1573.4_1573.4 (VM).kernel (92388 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/bzero.Tahiti_1573.4_1573.4 (VM).kernel (30492 bytes)

[s]tatus [p]ause [r]esume [b]ypass [q]uit =>

When this last line appears, I need some automated way to send the q key, so I will receive results like:

Session.Name...: oclHashcat
Status.........: Aborted
Input.Mode.....: Mask (?d?d?d?d?d?d?d?d) [8]
Hash.Target....: 101 (00:1f:5b:c2:fb:0c <-> 30:87:30:e0:0b:cd)
Hash.Type......: WPA/WPA2
Time.Started...: Sun Nov 16 06:41:17 2014 (11 secs)
Time.Estimated.: Sun Nov 16 06:54:56 2014 (13 mins, 28 secs)
Speed.GPU.#1...:    26537 H/s
Speed.GPU.#2...:    99510 H/s
Speed.GPU.#*...:   126.0 kH/s
Recovered......: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.......: 1413120/100000000 (1.41%)
Skipped........: 0/1413120 (0.00%)
Rejected.......: 0/1413120 (0.00%)
HWMon.GPU.#1...:  0% Util, 38c Temp, N/A Fan
HWMon.GPU.#2...: 98% Util, 44c Temp, 49% Fan

WARNING: Failed to restore default fan speed for gpu number: 1:
Started: Sun Nov 16 06:41:17 2014
Stopped: Sun Nov 16 06:41:28 2014

I am trying to to this using expect. This is the code:

spawn oclHashcat64.exe ../Test.hccap -m 2500 -a 3 ?d?d?d?d?d?d?d?d
expect "*tatus"
send "q\r"
close
exit

But it seems not to be working. This is the result:

Luis@Windu /cygdrive/c/Temporal/Expect
$ expect.exe Prueba02.expect
spawn oclHashcat64.exe ../Test.hccap -m 2500 -a 3 ?d?d?d?d?d?d?d?d
oclHashcat v1.31 starting...

Device #1: Bonaire, 1024MB, 1050Mhz, 12MCU
Device #2: Tahiti, 3072MB, 900Mhz, 28MCU

Hashes: 1 hashes; 1 unique digests, 1 unique salts
Bitmaps: 8 bits, 256 entries, 0x000000ff mask, 1024 bytes
Applicable Optimizers:
* Zero-Byte
* Single-Hash
* Single-Salt
* Brute-Force
Watchdog: Temperature abort trigger set to 90c
Watchdog: Temperature retain trigger set to 80c
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/m02500.Bonaire_1573.4_1573.4 (VM).kernel (259320 bytes)
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/markov_le_v1.Bonaire_1573.4_1573.4 (VM).kernel (92404 bytes)
Device #1: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/bzero.Bonaire_1573.4_1573.4 (VM).kernel (30496 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/m02500.Tahiti_1573.4_1573.4 (VM).kernel (259428 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/markov_le_v1.Tahiti_1573.4_1573.4 (VM).kernel (92388 bytes)
Device #2: Kernel D:\Programas\HashCat\OCLHashCat/kernels/4098/bzero.Tahiti_1573.4_1573.4 (VM).kernel (30492 bytes)

[s]tatus [p]ause [r]esume [b]ypass [q]uit =>
Luis@Windu /cygdrive/c/Temporal/Expect$

As you can see, the expected line appears, but the second part does not, and the q is not sent, because the main process keeps alive:

Luis@Windu /cygdrive/c/Temporal/Expect$ ps -e | grep "hashcat" -i
     1180       1    1180       6976  pty0    1000 07:51:13 /cygdrive/d/Programas/HashCat/OCLHashCat/oclHashcat64

Could someone tell me what am I doing wrong, please?

expect

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0