1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-24 18:16:24 +01: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) {
try {
File pathfile = Loader.expand(path);
if (!pathfile.exists() || !pathfile.isDirectory()) {
pathfile = new File(path);
if (!pathfile.exists() || !pathfile.isDirectory()) {
File pathFile = Loader.expand(path);
if (!pathFile.exists() || !pathFile.isDirectory()) {
pathFile = new File(path);
if (!pathFile.exists() || !pathFile.isDirectory()) {
throw new IOException("Path not found: " + path);
}
}
path = pathfile.getCanonicalPath();
String[] lst = new File(path).list();
path = pathFile.getCanonicalPath();
pathFile = new File(path);
String[] lst = pathFile.list();
List glob = new ArrayList();
if (lst == null) {
return glob;
@ -81,7 +82,7 @@ public class stdapi_fs_search implements Command {
if (lst[i] == null) {
continue;
}
File file = new File(lst[i]);
File file = new File(pathFile, lst[i]);
if (recurse && file.isDirectory()
// don't follow links to avoid infinite recursion
&& file.getCanonicalPath().equals(file.getAbsolutePath())) {