From 13e849b6a583855554b8e252b0825e6c2ef5d06f Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 1 Sep 2009 08:24:42 +0200 Subject: [PATCH] Adapted the remote file reads (ssh://...) to behave like local ones when a file slice [start:end:offset] is given. --- signduterre.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/signduterre.py b/signduterre.py index 6949c56..2d50d27 100755 --- a/signduterre.py +++ b/signduterre.py @@ -128,7 +128,9 @@ Note that byte range slices '$(cmd)[:]' do work, but only [[[em]]]af has completed. So, the file version, '/dev/kmem[0xc04838a0:+88]', will simply use 88 bytes as in '$(dd if=/dev/kmem bs=1 skip=3225958560 count=88)'. However, '$(dd if=/dev/kmem bs=1)[0xc04838a0:+88]' will [[[em]]]first[[[/em]]] read all of /dev/kmem, and only then extract the 88 bytes. In general, this is not -the desired procedure (/dev/kmem contains all of the physical RAM). +the desired procedure (/dev/kmem contains all of the physical RAM). Note that the remote +'--file-soource=ssh://...' option preserves the file slice behavior as the file reads are changed into the +equivalent 'dd skip= count=' commands. [[[/p]]][[[p]]] Any string '@(python code)' will be evaluated as python 3 code. The '--execute' option is obligatory. Note that the outer ()-brackets are removed. You can extend the program by importing modules with the @@ -1359,7 +1361,7 @@ for my_passphrase in passphrase_list: input_length = input_end - input_start; if input_start >=0 and input_offset > 0 : input_start += input_offset; - # Preprocessing filename to include file sources + # Preprocessing filename to include "external" file sources if my_filesource: # Insert different file reader as a shell command if arg_is_shell_command(my_filesource) and arg_is_plain_file(filename): @@ -1387,9 +1389,16 @@ for my_passphrase in passphrase_list: host = match.group(1); path = match.group(2); if arg_is_stat(path): - print("Error: status not possible in tunnels - "+filename); + print("Error: status not possible in tunnels - "+filename); else: - filename = '$(ssh://'+host+'/dd if=/'+path+')'; + if input_start > 0 or input_length > 0: + filename = '$(ssh://'+host+'/dd if=/'+path+' bs=1 skip='+str(input_start)+' count='+str(input_length)+')'; + # The start and end have been dealt with, remove them + input_start = 0; + input_length = 0; + else: + filename = '$(ssh://'+host+'/dd if=/'+path+')'; + print(filename); # Use python @() constructs orig_command_filename = filename; if arg_is_python_script(filename): -- 2.11.4.GIT