Forfiles.exe

Selects and executes a command on a file or set of files. This command is useful for batch processing.

Paths

  • C:\Windows\System32\forfiles.exe
  • C:\Windows\SysWOW64\forfiles.exe

Commands

Execute

Executes specified command since there is a match for notepad.exe in the c:\windows\System32 folder.

Use case: Use forfiles to start a new process to evade defensive counter measures

Privileges: User

forfiles /p c:\windows\system32 /m notepad.exe /c "{CMD}"

ADS

Executes the evil.exe Alternate Data Stream (AD) since there is a match for notepad.exe in the c:\windows\system32 folder.

Use case: Use forfiles to start a new process from a binary hidden in an alternate data stream

Privileges: User

forfiles /p c:\windows\system32 /m notepad.exe /c "{PATH_ABSOLUTE}:evil.exe"

Detection

Resources