![简单的 Expect 程序在程序产生一些文本时发送一个键](https://linux22.com/image/1430853/%E7%AE%80%E5%8D%95%E7%9A%84%20Expect%20%E7%A8%8B%E5%BA%8F%E5%9C%A8%E7%A8%8B%E5%BA%8F%E4%BA%A7%E7%94%9F%E4%B8%80%E4%BA%9B%E6%96%87%E6%9C%AC%E6%97%B6%E5%8F%91%E9%80%81%E4%B8%80%E4%B8%AA%E9%94%AE.png)
我需要运行这个程序:
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 =>
当这个最后一行出现,我需要一些自动化的方式来发送关键q,所以我会接收结果喜欢:
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
我正在尝试使用预计。这是代码:
spawn oclHashcat64.exe ../Test.hccap -m 2500 -a 3 ?d?d?d?d?d?d?d?d
expect "*tatus"
send "q\r"
close
exit
但它似乎不起作用。结果如下:
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$
正如您所看到的,出现预期的线,但第二部分却没有,并且q 未发送,因为主进程保持活动状态:
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
有人能告诉我我做错了什么吗?