Skip to content

Commit 03fcfc4

Browse files
committed
add a test to check if the file exist
1 parent fbb85c0 commit 03fcfc4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/post/windows/gather/file_in_raw_ntfs.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ def run
4343
end
4444

4545
file_path = datastore['FILE_PATH']
46+
47+
r = client.railgun.kernel32.GetFileAttributesA(file_path)
48+
49+
if r['GetLastError'] != 0
50+
print_error("The file does not exist, use file format C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts")
51+
return nil
52+
end
53+
4654
drive = file_path[0, 2]
4755

4856
r = client.railgun.kernel32.CreateFileA("\\\\.\\#{drive}", "GENERIC_READ", "FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE",

0 commit comments

Comments
 (0)