关于工具: 攻击包装器是用于为DPA竞赛(http://www.dpacontest.org/home/index.html)运行和评估攻击的工具。它可以在任何类Unix操作系统上运行,例如Linux,Mac OS X等,以及Windows。使用此工具,您可以使用几乎任何编程语言(C,C ++,Python,Perl ...)或使用Matlab开发攻击。
您可以在此处找到下载链接以及有关它的更多信息: http://www.dpacontest.org/tools/tools.php
当我试图评估数据时(可以在这里找到http://www.dpacontest.org/v4/42_traces.php)攻击包装工具只是创建空文件然后挂起。
我的命令:
attack_wrapper -d DPA_contestv4_2_k00/DPA_contestv4_2/ -x dpav4_2_index.txt -e v4_2 -t -o results_k0 -f fifo
结果:
D - Output filename = results_k0 (truncate if exists)
D - FIFO mode
D - Base name for FIFOs = fifo
D - Compatibility mode (v2) = disabled
D - Traces will be read from directory DPA_contestv4_2_k00/DPA_contestv4_2/
D - Using index file dpav4_2_index.txt
D - We will check if traces are available
D - Offsets/Shuffles are not provided to the attack
D - Samples are transfered as floats
I - Reading index file (v4_2)...
D - Total number of traces in the index file = 80000
D - Total number of traces available = 5000
D - Total number of keys in the index file = 16
D - Total number of keys available = 1
D - Key #00 (8249ceb658c71d41d7b734449629ab97): 5000 traces available
D - Key #01 (ef38c2af582a7e6b14255d139e9dbefc): not available
D - Key #02 (79db64df1e68124f6a57372b10e20e63): not available
D - Key #03 (efe61497dacc689fd9828465d3ff812b): not available
D - Key #04 (6a4daad5346e6eb385e1d278d1305089): not available
D - Key #05 (c0f38792d0d49c9f9ab97073f92c54b7): not available
D - Key #06 (389f496d23017d998c90ae1972aeaa0f): not available
D - Key #07 (2f345fbf2cd45942f3d91752cbe43ae7): not available
D - Key #08 (f3522c01495323615bcca67de0075395): not available
D - Key #09 (d4a9c9846bbc91da654eca24f08b9176): not available
D - Key #10 (c32807b275242ebf0f53d4639369980d): not available
D - Key #11 (80ceed788ce14c553ae0329995a5bebe): not available
D - Key #12 (0538cad22e6ca8405e14b4f3c5703c92): not available
D - Key #13 (512bfe6e6c4d2c62afa5f900fcc9cb11): not available
D - Key #14 (5384facaaefd16f38f1359ace6a29037): not available
D - Key #15 (b3e0a2b88e2dcf4bf765f2aad1538588): not available
D - Key # = 0
D - # of traces = 5000
I - Preparing the results file...
I - FIFO Wrapper -> Attack: fifo_from_wrapper
I - FIFO Attack -> Wrapper: fifo_to_wrapper
I - Sending # of iterations (5000)
然后没有任何事情发生(无休止地)。
我在Windows 7,Ubuntu 16.04,Ubuntu 17.10上以模式fork和FIFO尝试过它,结果是一样的。
如何修复它以便能够评估数据?
更新
当我在“发送...”提示后发出攻击
./attack_by_CPA/py_attack_by_CPA/attack.py fifo_from_wrapper fifo_to_wrapper
我收到了错误:
Traceback (most recent call last):
File "./attack_by_CPA/py_attack_by_CPA/attack.py", line 514, in <module>
attack.launchAttack()
File "./attack_by_CPA/py_attack_by_CPA/attack.py", line 377, in launchAttack
this.samples = np.array([struct.unpack('f', fifoIn.read(4))[0] for _ in range(NUM_SAMPLES)])
File "./attack_by_CPA/py_attack_by_CPA/attack.py", line 377, in <listcomp>
this.samples = np.array([struct.unpack('f', fifoIn.read(4))[0] for _ in range(NUM_SAMPLES)])
struct.error: unpack requires a buffer of 4 bytes
fifo_from_wrapper和fifo_to_wrapper只是空文件:
prw------- 1 acan acan 0 апр 14 10:50 fifo_from_wrapper|
prw------- 1 acan acan 0 апр 14 10:41 fifo_to_wrapper|
打开这些文件的部分代码:
def launchAttack(this):
# Open the FIFOs
fifoIn = open(this.fifoInName, 'rb')
fifoOut = open(this.fifoOutName, 'wb')
# Read the number of traces
numTraces = struct.unpack('i', fifoIn.read(4))[0]
答案 0 :(得分:0)
在出现“正在发送...”提示后,您是否手动启动了攻击程序?如果你是,你能否从包装器的流文件中发布与读/写相关的攻击程序部分?
在DPA竞赛网站的“工具”页面中:
如果包装器使用FIFO模式(如果使用-f或--fifo启动,或在Windows上启动),则包装器会创建两个特殊文件(两个十五或管道)以与攻击通信。 必须手动启动攻击并且必须打开这两个文件(在Unix上:在只读模式下为xxx_from_wrapper,在只写模式下为xxx_to_wrapper;在Windows上为:\。\ pipe \ xxx_from_wrapper为只读模式和\。\ pipe \ xxx_to_wrapper在只写模式下)。接下来,要从包装器读取数据,攻击只需要从文件xxx_from_wrapper(或Windows上的\。\ pipe \ xxx_from_wrapper)读取并将数据发送到包装器,攻击只需要写入文件xxx_to_wrapper(或Windows上的\。\ pipe \ xxx_to_wrapper)。 xxx将替换为包装器命令行中的最后一个参数。