File Post commands will execute the appropriate command and handle the different formats of issuing the commands depending on the OS for when executing against shell sessions.

git-svn-id: file:///home/svn/framework3/trunk@12776 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Carlos Perez 2011-05-30 22:14:11 +00:00
parent ec3e1efbc8
commit 520760a899
1 changed files with 17 additions and 6 deletions

View File

@ -66,13 +66,16 @@ module File
# as a String.
#
def read_file(file_name)
return false if file_name.length > 0
data = nil
if session.type == "meterpreter"
data = read_file_meterpreter(file_name)
elsif session.respond_to? :shell_command_token
data = session.shell_command_token("cat '#{file_name}'")
elsif session.type == "shell"
if session.platform == "windows"
data = session.shell_command_token("type \"#{file_name}\"")
else
data = session.shell_command_token("cat #{file_name}")
end
end
data
end
@ -87,7 +90,11 @@ module File
fd.write(data)
fd.close
elsif session.respond_to? :shell_command_token
session.shell_command_token("echo \'#{data}\' >> '#{file_name}'")
if session.platform == "windows"
session.shell_command_token("echo #{data} > \"#{file_name}\"")
else
session.shell_command_token("echo \'#{data}\' > \'#{file_name}\'")
end
end
return true
@ -103,7 +110,11 @@ module File
fd.write(data)
fd.close
elsif session.respond_to? :shell_command_token
session.shell_command_token("echo \'#{data}\' >> '#{file_name}'")
if session.platform == "windows"
session.shell_command_token("echo #{data} >> \"#{file_name}\"")
else
session.shell_command_token("echo \'#{data}\' >> \'#{file_name}\'")
end
end
return true
end