@@ -21,6 +21,7 @@ def initialize(info={})
21
21
) )
22
22
register_options (
23
23
[
24
+ OptBool . new ( "AddEntropy" , [ false , "Add entropy token to file and directory names." , false ] ) ,
24
25
OptString . new ( "BaseFileName" , [ true , "File/dir base name" , "meterpreter-test" ] )
25
26
] , self . class )
26
27
end
@@ -132,7 +133,12 @@ def test_net_config
132
133
133
134
def test_fs
134
135
vprint_status ( "Starting filesystem tests" )
135
-
136
+ if datastore [ "AddEntropy" ]
137
+ entropy_value = '-' + ( 'a' ..'z' ) . to_a . shuffle [ 0 , 8 ] . join
138
+ else
139
+ entropy_value = ""
140
+ end
141
+
136
142
it "should return the proper directory separator" do
137
143
sysinfo = session . sys . config . sysinfo
138
144
if sysinfo [ "OS" ] =~ /windows/i
@@ -167,7 +173,8 @@ def test_fs
167
173
end
168
174
169
175
it "should create and remove a dir" do
170
- dir_name = "#{ datastore [ "BaseFileName" ] } -dir"
176
+ dir_name = "#{ datastore [ "BaseFileName" ] } -dir#{ entropy_value } "
177
+ vprint_status ( "Directory Name: #{ dir_name } " )
171
178
session . fs . dir . rmdir ( dir_name ) rescue nil
172
179
res = create_directory ( dir_name )
173
180
if ( res )
@@ -180,7 +187,8 @@ def test_fs
180
187
end
181
188
182
189
it "should change directories" do
183
- dir_name = "#{ datastore [ "BaseFileName" ] } -dir"
190
+ dir_name = "#{ datastore [ "BaseFileName" ] } -dir#{ entropy_value } "
191
+ vprint_status ( "Directory Name: #{ dir_name } " )
184
192
session . fs . dir . rmdir ( dir_name ) rescue nil
185
193
res = create_directory ( dir_name )
186
194
@@ -208,7 +216,8 @@ def test_fs
208
216
209
217
it "should create and remove files" do
210
218
res = true
211
- file_name = datastore [ "BaseFileName" ]
219
+ file_name = "#{ datastore [ "BaseFileName" ] } #{ entropy_value } "
220
+ vprint_status ( "File Name: #{ file_name } " )
212
221
res &&= session . fs . file . open ( file_name , "wb" ) { |fd |
213
222
fd . write ( "test" )
214
223
}
@@ -228,7 +237,8 @@ def test_fs
228
237
229
238
it "should upload a file" do
230
239
res = true
231
- remote = "#{ datastore [ "BaseFileName" ] } -file.txt"
240
+ remote = "#{ datastore [ "BaseFileName" ] } -file#{ entropy_value } .txt"
241
+ vprint_status ( "Remote File Name: #{ remote } " )
232
242
local = __FILE__
233
243
vprint_status ( "uploading" )
234
244
session . fs . file . upload_file ( remote , local )
@@ -254,8 +264,10 @@ def test_fs
254
264
255
265
it "should move files" do
256
266
res = true
257
- src_name = datastore [ "BaseFileName" ]
258
- dst_name = "#{ datastore [ "BaseFileName" ] } -moved"
267
+ src_name = "#{ datastore [ "BaseFileName" ] } #{ entropy_value } "
268
+ vprint_status ( "Source File Name: #{ src_name } " )
269
+ dst_name = "#{ src_name } -moved"
270
+ vprint_status ( "Destination File Name: #{ dst_name } " )
259
271
260
272
# Make sure we don't have leftovers from a previous run
261
273
session . fs . file . rm ( src_name ) rescue nil
@@ -279,8 +291,10 @@ def test_fs
279
291
280
292
it "should copy files" do
281
293
res = true
282
- src_name = datastore [ "BaseFileName" ]
283
- dst_name = "#{ datastore [ "BaseFileName" ] } -copied"
294
+ src_name = "#{ datastore [ "BaseFileName" ] } #{ entropy_value } "
295
+ vprint_status ( "Source File Name: #{ src_name } " )
296
+ dst_name = "#{ src_name } -copied"
297
+ vprint_status ( "Destination File Name: #{ dst_name } " )
284
298
285
299
# Make sure we don't have leftovers from a previous run
286
300
session . fs . file . rm ( src_name ) rescue nil
@@ -304,7 +318,8 @@ def test_fs
304
318
305
319
it "should do md5 and sha1 of files" do
306
320
res = true
307
- remote = "#{ datastore [ "BaseFileName" ] } -file.txt"
321
+ remote = "#{ datastore [ "BaseFileName" ] } -file#{ entropy_value } .txt"
322
+ vprint_status ( "Remote File Name: #{ remote } " )
308
323
local = __FILE__
309
324
vprint_status ( "uploading" )
310
325
session . fs . file . upload_file ( remote , local )
0 commit comments