File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,29 @@ def self.read_replace_script_template(filename, hash_sub)
74
74
template % hash_sub
75
75
end
76
76
77
+
78
+ # Generates a ZIP file.
79
+ #
80
+ # @param files [Array<Hash>] Items to compress. Each item is a hash that supports these options:
81
+ # * :data - The content of the file.
82
+ # * :fname - The file path in the ZIP file
83
+ # * :comment - A comment
84
+ # @example Compressing two files, one in a folder called 'test'
85
+ # Msf::Util::EXE.to_zip([{data: 'AAAA', fname: "file1.txt"}, {data: 'data', fname: 'test/file2.txt'}])
86
+ # @return [String]
87
+ def self . to_zip ( files )
88
+ zip = Rex ::Zip ::Archive . new
89
+
90
+ files . each do |f |
91
+ data = f [ :data ]
92
+ fname = f [ :fname ]
93
+ comment = f [ :comment ] || ''
94
+ zip . add_file ( fname , data , comment )
95
+ end
96
+
97
+ zip . pack
98
+ end
99
+
77
100
# Executable generators
78
101
#
79
102
# @param arch [Array<String>] The architecture of the system (i.e :x86, :x64)
You can’t perform that action at this time.
0 commit comments