Skip to content

Commit 8150d0d

Browse files
Update exploithawk.c
1 parent bd36fe2 commit 8150d0d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

exploithawk.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <dirent.h>
1111
#include <ncurses.h>
1212
#include <unistd.h>
13+
#include <sys/stat.h>
1314

1415
#define MAX_RESULTS 1000
1516
#define MAX_PATH 512
@@ -141,14 +142,27 @@ void *load_csv_thread(void *arg) {
141142
void scan_dir(const char *dir) {
142143
DIR *d = opendir(dir);
143144
if (!d) return;
145+
144146
struct dirent *entry;
145147
while ((entry = readdir(d)) != NULL) {
148+
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
149+
continue;
150+
151+
int is_dir = 0;
146152
if (entry->d_type == DT_DIR) {
147-
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
148-
char subdir[MAX_PATH];
149-
snprintf(subdir, sizeof(subdir), "%s/%s", dir, entry->d_name);
150-
scan_dir(subdir);
151-
}
153+
is_dir = 1;
154+
} else if (entry->d_type == DT_UNKNOWN) {
155+
char fullpath[MAX_PATH];
156+
snprintf(fullpath, sizeof(fullpath), "%s/%s", dir, entry->d_name);
157+
struct stat st;
158+
if (stat(fullpath, &st) == 0 && S_ISDIR(st.st_mode))
159+
is_dir = 1;
160+
}
161+
162+
if (is_dir) {
163+
char subdir[MAX_PATH];
164+
snprintf(subdir, sizeof(subdir), "%s/%s", dir, entry->d_name);
165+
scan_dir(subdir);
152166
} else {
153167
if (matches_search(entry->d_name, search_term)) {
154168
char fullpath[MAX_PATH];
@@ -157,6 +171,7 @@ void scan_dir(const char *dir) {
157171
}
158172
}
159173
}
174+
160175
closedir(d);
161176
}
162177

0 commit comments

Comments
 (0)