1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-04-18 07:11:12 +02:00

Fix a regression I added in the search behavior

Bad Spencer bad
This commit is contained in:
Spencer McIntyre 2024-10-09 12:41:50 -04:00
parent 924f586608
commit ff617cf147

@ -64,15 +64,16 @@ public class stdapi_fs_search implements Command {
public static List findFiles(String path, String mask, boolean recurse, Integer startDate, Integer endDate) { public static List findFiles(String path, String mask, boolean recurse, Integer startDate, Integer endDate) {
try { try {
File pathfile = Loader.expand(path); File pathFile = Loader.expand(path);
if (!pathfile.exists() || !pathfile.isDirectory()) { if (!pathFile.exists() || !pathFile.isDirectory()) {
pathfile = new File(path); pathFile = new File(path);
if (!pathfile.exists() || !pathfile.isDirectory()) { if (!pathFile.exists() || !pathFile.isDirectory()) {
throw new IOException("Path not found: " + path); throw new IOException("Path not found: " + path);
} }
} }
path = pathfile.getCanonicalPath(); path = pathFile.getCanonicalPath();
String[] lst = new File(path).list(); pathFile = new File(path);
String[] lst = pathFile.list();
List glob = new ArrayList(); List glob = new ArrayList();
if (lst == null) { if (lst == null) {
return glob; return glob;
@ -81,7 +82,7 @@ public class stdapi_fs_search implements Command {
if (lst[i] == null) { if (lst[i] == null) {
continue; continue;
} }
File file = new File(lst[i]); File file = new File(pathFile, lst[i]);
if (recurse && file.isDirectory() if (recurse && file.isDirectory()
// don't follow links to avoid infinite recursion // don't follow links to avoid infinite recursion
&& file.getCanonicalPath().equals(file.getAbsolutePath())) { && file.getCanonicalPath().equals(file.getAbsolutePath())) {