From af89b273e68e2988e5ad7773dbae1a6b95cf0061 Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Wed, 6 Nov 2024 17:25:32 -0500 Subject: [PATCH] Handle deleting symlinks differently on Windows --- .../meterpreter/stdapi/stdapi_fs_delete_dir_V1_7.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi/stdapi_fs_delete_dir_V1_7.java b/java/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi/stdapi_fs_delete_dir_V1_7.java index a52dea3a3..24c5c0a55 100644 --- a/java/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi/stdapi_fs_delete_dir_V1_7.java +++ b/java/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi/stdapi_fs_delete_dir_V1_7.java @@ -7,7 +7,11 @@ public class stdapi_fs_delete_dir_V1_7 extends stdapi_fs_delete_dir { @Override protected boolean deleteSymlink(File file) throws IOException { - Files.delete(file.toPath()); - return true; + String osName = System.getProperty("os.name"); + if (osName != null && osName.toLowerCase().contains("windows")) { + Files.delete(file.toPath()); + return true; + } + return file.delete(); } }