did not write info when file did not exists, problem fixed
git-svn-id: file:///home/svn/framework3/trunk@9739 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
29c78e5c5c
commit
e0d9c41b5f
|
@ -2,61 +2,61 @@ module Msf
|
|||
module Scripts
|
||||
module Meterpreter
|
||||
module Common
|
||||
|
||||
#
|
||||
# Commonly used methods and techniques for Meterpreter scripts
|
||||
#
|
||||
|
||||
#
|
||||
# Commonly used methods and techniques for Meterpreter scripts
|
||||
#
|
||||
#
|
||||
# These methods should only print output in the case of an error. All code should be tab indented
|
||||
# All methods should follow the naming coventions below (separate words with "_", end queries with a ?, etc)
|
||||
#
|
||||
|
||||
#
|
||||
# These methods should only print output in the case of an error. All code should be tab indented
|
||||
# All methods should follow the naming coventions below (separate words with "_", end queries with a ?, etc)
|
||||
#
|
||||
#Writes a given string to a file specified
|
||||
def file_local_write(file2wrt, data2wrt)
|
||||
if not ::File.exists?(file2wrt)
|
||||
::FileUtils.touch(file2wrt)
|
||||
end
|
||||
|
||||
#Writes a given string to a file specified
|
||||
def file_local_write(file2wrt, data2wrt)
|
||||
if not ::File.exists?(file2wrt)
|
||||
::FileUtils.touch(file2wrt)
|
||||
else
|
||||
output = ::File.open(file2wrt, "a")
|
||||
data2wrt.each_line do |d|
|
||||
output.puts(d)
|
||||
output = ::File.open(file2wrt, "a")
|
||||
data2wrt.each_line do |d|
|
||||
output.puts(d)
|
||||
end
|
||||
output.close
|
||||
end
|
||||
#Returns a MD5 checksum of a given local file
|
||||
def file_local_digestmd5(file2md5)
|
||||
if not ::File.exists?(file2md5)
|
||||
raise "File #{file2md5} does not exists!"
|
||||
else
|
||||
require 'digest/md5'
|
||||
chksum = nil
|
||||
chksum = Digest::MD5.hexdigest(::File.open(file2md5, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
#Returns a SHA1 checksum of a given local file
|
||||
def file_local_digestsha1(file2sha1)
|
||||
if not ::File.exists?(file2sha1)
|
||||
raise "File #{file2sha1} does not exists!"
|
||||
else
|
||||
require 'digest/sha1'
|
||||
chksum = nil
|
||||
chksum = Digest::SHA1.hexdigest(::File.open(file2sha1, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
#Returns a SHA256 checksum of a given local file
|
||||
def file_local_digestsha2(file2sha2)
|
||||
if not ::File.exists?(file2sha2)
|
||||
raise "File #{file2sha2} does not exists!"
|
||||
else
|
||||
require 'digest/sha2'
|
||||
chksum = nil
|
||||
chksum = Digest::SHA256.hexdigest(::File.open(file2sha2, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
output.close
|
||||
end
|
||||
end
|
||||
#Returns a MD5 checksum of a given local file
|
||||
def file_local_digestmd5(file2md5)
|
||||
if not ::File.exists?(file2md5)
|
||||
raise "File #{file2md5} does not exists!"
|
||||
else
|
||||
require 'digest/md5'
|
||||
chksum = nil
|
||||
chksum = Digest::MD5.hexdigest(::File.open(file2md5, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
#Returns a SHA1 checksum of a given local file
|
||||
def file_local_digestsha1(file2sha1)
|
||||
if not ::File.exists?(file2sha1)
|
||||
raise "File #{file2sha1} does not exists!"
|
||||
else
|
||||
require 'digest/sha1'
|
||||
chksum = nil
|
||||
chksum = Digest::SHA1.hexdigest(::File.open(file2sha1, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
#Returns a SHA256 checksum of a given local file
|
||||
def file_local_digestsha2(file2sha2)
|
||||
if not ::File.exists?(file2sha2)
|
||||
raise "File #{file2sha2} does not exists!"
|
||||
else
|
||||
require 'digest/sha2'
|
||||
chksum = nil
|
||||
chksum = Digest::SHA256.hexdigest(::File.open(file2sha2, "rb") { |f| f.read})
|
||||
return chksum
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue