On this page 24 sections
  1. What findstr does
  2. Case-insensitive searching
  3. Show line numbers
  4. Recursive search
  5. Skip binary files
  6. Recommended CTF combination
  7. Search for an exact string
  8. Search several strings at once
  9. Search configuration files
  10. Search configuration keywords
  11. Search assignment-style values
  12. Search XML configuration
  13. Search JSON and YAML
  14. Search scripts
  15. Search only filenames containing matches
  16. Search the current user profile
  17. Search ProgramData
  18. Search IIS web applications
  19. PowerShell history
  20. Search Windows Panther files
  21. Pipe dir output into findstr
  22. Filename search versus content search
  23. Targeted search before full filesystem search
  24. findstr limitations
01

What findstr does

findstr searches text inside files. It is the native Windows CMD equivalent of a basic grep workflow and is extremely useful when analysing configuration files, scripts, logs and CTF artefacts.

Search a file
findstr "flag" file.txt
02

Case-insensitive searching

/i ignores uppercase and lowercase differences. This is useful when the exact capitalisation of a value is unknown.

Ignore case
findstr /i "flag" file.txt
03

Show line numbers

/n shows the line number where each match was found.

Show matching lines and numbers
findstr /in "flag" file.txt
04

Recursive search

/s searches matching files in the current directory and every subdirectory.

Recursive flag search
findstr /si "flag" *.*
05

Skip binary files

/p skips files containing non-printable characters. This reduces noise when recursively searching large directory trees.

Recursive text search
findstr /sip "flag" *.*
06

Recommended CTF combination

Combining /s, /p, /i and /n gives recursive searching, skips many binary files, ignores case and displays line numbers.

Search recursively for flag
findstr /spin "flag" *.* 2>nul
07

Search for an exact string

/c treats the supplied text as a single search string. It is especially useful when searching strings containing spaces or specific flag prefixes.

Search flag prefix
findstr /spin /c:"flag{" *.* 2>nul
Exact phrase
findstr /spin /c:"CTF{" *.* 2>nul
08

Search several strings at once

Multiple /c options allow several interesting values to be searched in a single command.

Common CTF indicators
findstr /spin /c:"flag{" /c:"CTF{" /c:"proof" /c:"user.txt" *.* 2>nul
09

Search configuration files

Instead of scanning every file type, restricting findstr to common configuration extensions is faster and produces cleaner output.

Configuration search
findstr /spin /c:"flag{" *.ini *.cfg *.conf *.config *.xml *.json *.yml *.yaml 2>nul
10

Search configuration keywords

Configuration files frequently contain key-value pairs. In CTF environments useful search terms include password, secret, token, key and connection strings.

Interesting configuration values
findstr /spin /c:"password" /c:"passwd" /c:"secret" /c:"token" /c:"api_key" *.ini *.cfg *.config *.xml *.json *.yml *.yaml 2>nul
11

Search assignment-style values

Searching for assignment syntax can reduce matches from documentation or comments.

Common key/value patterns
findstr /spin /c:"password=" /c:"passwd=" /c:"secret=" /c:"token=" /c:"key=" *.ini *.cfg *.conf *.config 2>nul
12

Search XML configuration

Windows and .NET applications frequently use XML-based configuration files.

Search XML for passwords
findstr /spin /c:"password" *.xml *.config 2>nul
Connection strings
findstr /spin /c:"connectionString" *.config *.xml 2>nul
13

Search JSON and YAML

Modern applications commonly store configuration in JSON or YAML files.

JSON and YAML secrets
findstr /spin /c:"password" /c:"secret" /c:"token" *.json *.yml *.yaml 2>nul
14

Search scripts

Batch and PowerShell scripts can reveal application paths, usernames, scheduled operations and other useful CTF context.

Search PowerShell scripts
findstr /spin /c:"flag{" /c:"password" /c:"token" *.ps1 2>nul
Search batch scripts
findstr /spin /c:"flag{" /c:"password" *.bat *.cmd 2>nul
15

Search only filenames containing matches

/m prints only the names of files containing matching text. This is useful for reducing output before manually inspecting interesting files.

Files containing flag
findstr /sim /c:"flag{" *.* 2>nul
Configuration files containing password
findstr /sim /c:"password" *.ini *.cfg *.config *.xml 2>nul
16

Search the current user profile

Changing into the user profile before recursively searching keeps the scope manageable.

Move to user profile
cd /d "%USERPROFILE%"
Search for flags
findstr /spin /c:"flag{" *.* 2>nul
17

Search ProgramData

ProgramData is a useful application configuration location on Windows.

Move to ProgramData
cd /d C:\ProgramData
Search configuration values
findstr /spin /c:"flag{" /c:"password" /c:"secret" /c:"token" *.ini *.cfg *.config *.xml *.json 2>nul
18

Search IIS web applications

On Windows web servers, web.config and application files under inetpub are useful targets during authorised lab enumeration.

Move to IIS web root
cd /d C:\inetpub\wwwroot
Search web files
findstr /spin /c:"flag{" /c:"password" /c:"connectionString" *.* 2>nul
19

PowerShell history

PowerShell history is plain text and can be searched directly when it exists and permissions allow access.

Search current history
findstr /i /n /c:"password" /c:"token" /c:"flag" "%APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" 2>nul
20

Search Windows Panther files

Windows installation and deployment configuration can exist under C:\Windows\Panther. In training environments these files are worth reviewing separately.

Search Panther XML files
findstr /spin /c:"password" /c:"username" C:\Windows\Panther\*.xml 2>nul
21

Pipe dir output into findstr

dir and findstr also work together when the goal is to filter filenames and paths rather than file contents.

Interesting filenames
dir C:\Users /s /b /a-d 2>nul | findstr /i "flag proof password config backup"
22

Filename search versus content search

Piping dir into findstr searches the path or filename itself. Running findstr directly against files searches their contents. Understanding this difference avoids confusion during enumeration.

Search filenames
dir /s /b 2>nul | findstr /i "flag"
Search file contents
findstr /spin /c:"flag{" *.* 2>nul
23

Targeted search before full filesystem search

Searching an entire C: drive recursively can be slow and noisy. Start with user profiles, ProgramData, web roots and known application directories before expanding the scope.

User profile first
cd /d "%USERPROFILE%" && findstr /spin /c:"flag{" *.* 2>nul
ProgramData next
cd /d C:\ProgramData && findstr /spin /c:"flag{" *.txt *.ini *.cfg *.config *.xml *.json 2>nul
24

findstr limitations

findstr is useful but its regular-expression engine is much more limited than grep, ripgrep or PowerShell Select-String. It may also behave poorly with binary files, Unicode encodings and very long lines. Use it primarily as a fast native Windows search tool.