File and Directory Discovery

May 1, 2024 ยท View on GitHub

ID E1083
Objective(s) Discovery
Related ATT&CK Techniques File and Directory Discovery (T1083)
Version 2.3
Created 2 August 2022
Last Modified 30 April 2024

File and Directory Discovery

Malware may enumerate files and directories or may search for specific files or in specific locations.

Methods

NameIDDescription
Log FileE1083.m01Malware may look for system log files.
Filter by ExtensionE1083.m02Malware may filter by extension (common in ransomware).

Use in Malware

NameDateMethodDescription
CryptoWall2014--The malware searches for user files before encrypting them. [1]
CryptoLocker2013--The malware searches for user files before encrypting them. [2]
TrickBot2016--The malware collects machine information and local files with specified file extensions. [3]
Matanbuchus2021--Malware verifies that the folder from the first stage loader exists on the system. The malware also checks for the path for the Opera web browser. If it exists, the malware exits. [4] [5]
GravityRAT2018--GravityRAT enumerates files on Windows. [6]
Hupigon2013--Hupigon enumerates files recursively. [6]
Hupigon2013E1083.m01Hupigon accesses the Windows event log. [6]
Kovter2016--Kovter gets file version info. [6]
Kovter2016E1083.m01Kovter accesses the Windows event log. [6]
SamSam2015--SamSam enumerates files on Windows. [6]
UP0072016--The malware enumerates files on Windows. [6]
BlackEnergy2007--The malware gets the common file path. [6]
Dark Comet2008--The malware gets file version info. [6]
Gamut2014--Gamut gets the common file path. [6]
GoBotKR2019--GoBotKR checks if a file exists. [6]
Locky Bart2017--The malware gets a file size. [6]
Mebromi2011--Mebromi gets a file size. [6]
Redhip2011--Redhip gets a file size. [6]
Rombertik2015--The malware gets the file version info. [6]
Shamoon2012--Shamoon gets a common file path. [6]
ElectroRAT2020--ElectroRat looks for wallets to steal cryptocurrency. [7]

Detection

Tool: capaMappingAPIs
get common file pathFile and Directory Discovery (E1083)kernel32.GetTempPath, kernel32.GetTempFileName, kernel32.GetSystemDirectory, kernel32.GetWindowsDirectory, kernel32.GetSystemWow64Directory, GetAllUsersProfileDirectory, GetAppContainerFolderPath, GetCurrentDirectory, GetDefaultUserProfileDirectory, GetProfilesDirectory, GetUserProfileDirectory, SHGetFolderPathAndSubDir, shell32.SHGetFolderPath, shell32.SHGetFolderLocation, shell32.SHGetKnownFolderPath, shell32.SHGetSpecialFolderPath, shell32.SHGetSpecialFolderLocation, System.IO.Directory::GetCurrentDirectory, System.Environment::GetFolderPath
get file version infoFile and Directory Discovery (E1083)version.GetFileVersionInfo, version.GetFileVersionInfoEx, System.Diagnostics.FileVersionInfo::GetVersionInfo, version.VerQueryValue, version.GetFileVersionInfoSize, version.GetFileVersionInfoSizeEx
get file sizeFile and Directory Discovery (E1083)kernel32.GetFileSize, kernel32.GetFileSizeEx
check if file existsFile and Directory Discovery (E1083)kernel32.GetFileAttributes, kernel32.GetLastError, shlwapi.PathFileExists, System.IO.File::Exists
enumerate files on LinuxFile and Directory Discovery (E1083)getdents, getdents64, opendir, readdir
enumerate files on WindowsFile and Directory Discovery (E1083)kernel32.FindFirstFile, kernel32.FindFirstFileEx, kernel32.FindFirstFileTransacted, kernel32.FindFirstFileName, kernel32.FindFirstFileNameTransacted, kernel32.FindNextFile, kernel32.FindNextFileName, kernel32.FindClose, ntdll.NtOpenDirectoryObject, ntdll.NtQueryDirectoryObject, RtlAllocateHeap, System.IO.DirectoryInfo::GetFiles, System.IO.DirectoryInfo::EnumerateFiles, System.IO.Directory::GetFiles, System.IO.Directory::EnumerateFiles, System.IO.Directory::EnumerateFileSystemEntries, System.IO.DirectoryInfo::GetDirectories, System.IO.DirectoryInfo::EnumerateDirectories, System.IO.Directory::GetDirectories, System.IO.Directory::EnumerateDirectories
enumerate files recursivelyFile and Directory Discovery (E1083)--
read data from CLFS log containerFile and Directory Discovery::Log File (E1083.m01)clfsw32.CreateLogFile, clfsw32.CreateLogMarshallingArea, clfsw32.ReadLogRecord, clfsw32.ReadNextLogRecord
access the Windows event logFile and Directory Discovery::Log File (E1083.m01)OpenEventLog, ClearEventLog, OpenBackupEventLog, ReportEvent
Tool: CAPEMappingAPIs
antisandbox_cuckoo_filesFile and Directory Discovery (E1083)--
antisandbox_threattrack_filesFile and Directory Discovery (E1083)--
antivm_directory_objectsFile and Directory Discovery (E1083)NtQueryDirectoryObject, NtOpenDirectoryObject
antivm_vmware_eventsFile and Directory Discovery (E1083)NtOpenEvent, NtCreateEvent
antivm_vmware_eventsFile and Directory Discovery::Log File (E1083.m01)NtOpenEvent, NtCreateEvent
antivm_vbox_devicesFile and Directory Discovery (E1083)--
antivm_vmware_devicesFile and Directory Discovery (E1083)--
antivm_vbox_filesFile and Directory Discovery (E1083)--
antivm_vmware_libsFile and Directory Discovery (E1083)LdrLoadDll
antiav_detectfileFile and Directory Discovery (E1083)--
antivm_vpc_filesFile and Directory Discovery (E1083)--
antivm_vbox_libsFile and Directory Discovery (E1083)LdrLoadDll
driver_filtermanagerFile and Directory Discovery (E1083)--
antisandbox_joe_anubis_filesFile and Directory Discovery (E1083)--
antivm_vmware_filesFile and Directory Discovery (E1083)--
antisandbox_fortinet_filesFile and Directory Discovery (E1083)--
antisandbox_sunbelt_filesFile and Directory Discovery (E1083)--
antianalysis_detectfileFile and Directory Discovery (E1083)--

E1083 Snippet

Discovery::File and Directory Discovery SHA256: 000b535ab2a4fec86e2d8254f8ed65c6ebd37309ed68692c929f8f93a99233f6 Location: 0x409A62
push    eax     ; argument to function containing file path to search
call    KERNEL32.DLL::GetFileAttributesA        ; Function to retrieve file attributes for file path indicated by eax
cmp     eax, -0x1       ; Test if function returned an error
jz      lab_00409a71    ; If the function failed (the file's attributes were not retrieved and the return value is -1), jump to the specified address to continue execution
test    al, 0x10        ; Test the lower 8 bits of the return value to check if the file is a directory
jnz     lab_00409a75    ; If the returned result is not a directory, jump to the specified address to continue execution

References

[1] https://news.sophos.com/en-us/2015/12/17/the-current-state-of-ransomware-cryptowall/

[2] https://www.secureworks.com/research/cryptolocker-ransomware

[3] https://www.securityartwork.es/wp-content/uploads/2017/07/Trickbot-report-S2-Grupo.pdf

[4] https://www.0ffset.net/reverse-engineering/matanbuchus-loader-analysis/

[5] https://www.cyberark.com/resources/threat-research-blog/inside-matanbuchus-a-quirky-loader

[6] capa v4.0, analyzed at MITRE on 10/12/2022

[7] https://www.intezer.com/blog/research/operation-electrorat-attacker-creates-fake-companies-to-drain-your-crypto-wallets/