11779785d4
git-svn-id: file:///home/svn/framework3/trunk@12955 4d416f70-5f16-0410-b530-b9f4589650da
52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
###
|
|
#
|
|
# This module exposes a simple method to create a file.
|
|
#
|
|
###
|
|
|
|
module Msf
|
|
module Exploit::FILEFORMAT
|
|
|
|
def initialize(info = {})
|
|
super
|
|
|
|
register_options(
|
|
[
|
|
OptString.new('FILENAME', [ true, 'The file name.', 'MSF']),
|
|
], Msf::Exploit::FILEFORMAT
|
|
)
|
|
|
|
register_advanced_options(
|
|
[
|
|
OptBool.new('DisablePayloadHandler', [ false, "Disable the handler code for the selected payload", true ])
|
|
], Msf::Exploit::FILEFORMAT
|
|
)
|
|
end
|
|
|
|
def file_create(data)
|
|
fname = datastore['FILENAME']
|
|
slashes = fname.count(::File::SEPARATOR)
|
|
|
|
if slashes == 0
|
|
# use default directory, create the directories if they do not exist already
|
|
if ::File.directory?(Msf::Config.config_directory)
|
|
::Dir.mkdir(Msf::Config.config_directory + "/data/", 0755) rescue nil
|
|
::Dir.mkdir(Msf::Config.config_directory + "/data/exploits/", 0755) rescue nil
|
|
end
|
|
|
|
path = Msf::Config.config_directory + "/data/exploits/"
|
|
fname = path + fname
|
|
end
|
|
|
|
begin
|
|
fd = File.new(fname, 'wb')
|
|
fd.write(data)
|
|
fd.close
|
|
print_status("Generated output file #{fname}")
|
|
rescue Errno::ENOENT
|
|
print_error("Path for #{fname} does not exist. Create this path and try again.")
|
|
end
|
|
end
|
|
end
|
|
end
|