On this page 19 sections
  1. What dir does
  2. Show all files
  3. Recursive enumeration
  4. Bare output
  5. Files only
  6. Search filenames for common CTF terms
  7. Why 2>nul is useful
  8. Search a specific user profile
  9. Interesting user directories
  10. Enumerate all user profiles
  11. Configuration file extensions
  12. Search several interesting extensions
  13. ProgramData
  14. AppData
  15. Web server files
  16. Windows Panther
  17. PowerShell history
  18. Search the entire drive as a fallback
  19. CTF workflow
01

What dir does

dir lists files and directories from Windows Command Prompt. During CTFs and authorised enumeration it is useful for quickly mapping a filesystem, locating unusual files and identifying configuration files before inspecting their contents.

List current directory
dir
02

Show all files

The /a option includes files with special attributes such as hidden and system files.

Show all files
dir /a
Only hidden files
dir /a:h
Only system files
dir /a:s
03

Recursive enumeration

/s searches recursively through subdirectories. This is one of the most useful options during filesystem enumeration.

Recursive directory listing
dir /s
04

Bare output

/b produces bare output containing only paths or filenames. It is much easier to pipe into other commands such as findstr.

Bare listing
dir /b
Recursive full paths
dir /s /b
05

Files only

/a-d excludes directories and returns only files.

Recursive file listing
dir /s /b /a-d
06

Search filenames for common CTF terms

Before searching file contents, filename enumeration can reveal obvious artefacts such as flag.txt, proof.txt, user.txt or configuration backups.

Search for flag filenames
dir /s /b *flag* 2>nul
Search for user files
dir /s /b *user* 2>nul
Search for proof files
dir /s /b *proof* 2>nul
Search for configuration filenames
dir /s /b *config* 2>nul
07

Why 2>nul is useful

Recursive searches often encounter directories that the current user cannot access. Redirecting STDERR to nul hides access-denied messages and keeps the output readable.

Suppress errors
dir C:\ /s /b *flag* 2>nul
08

Search a specific user profile

Searching a user profile is usually faster and less noisy than immediately scanning the entire system drive.

Current user profile
dir "%USERPROFILE%" /s /b 2>nul
Search for flags
dir "%USERPROFILE%\*flag*" /s /b 2>nul
09

Interesting user directories

Desktop, Documents and Downloads are common locations for CTF artefacts, scripts, notes and configuration files.

Desktop
dir "%USERPROFILE%\Desktop" /a /s /b 2>nul
Documents
dir "%USERPROFILE%\Documents" /a /s /b 2>nul
Downloads
dir "%USERPROFILE%\Downloads" /a /s /b 2>nul
10

Enumerate all user profiles

C:\Users reveals which local user profiles exist and can provide additional locations worth inspecting.

List users
dir C:\Users
Enumerate user files
dir C:\Users /s /b /a-d 2>nul
11

Configuration file extensions

Configuration data is commonly stored in INI, CFG, CONF, CONFIG, XML, JSON, YAML and script files.

INI files
dir C:\Users\*.ini /s /b 2>nul
Configuration files
dir C:\Users\*.config /s /b 2>nul
XML files
dir C:\Users\*.xml /s /b 2>nul
JSON files
dir C:\Users\*.json /s /b 2>nul
12

Search several interesting extensions

A small FOR loop can enumerate several common configuration and script extensions without manually repeating every command. In interactive CMD use a single percent sign.

Configuration and script files
for %e in (txt ini cfg conf config xml json yml yaml ps1 bat cmd) do @dir C:\Users\*.%e /s /b 2>nul
13

ProgramData

C:\ProgramData stores application-wide configuration and data. In CTF environments it is often worth checking because installed applications may leave configuration, log or backup files here.

Enumerate ProgramData
dir C:\ProgramData /a /s /b 2>nul
Find configuration files
dir C:\ProgramData\*.config /s /b 2>nul
Find XML files
dir C:\ProgramData\*.xml /s /b 2>nul
14

AppData

Applications frequently store per-user configuration in AppData. Both Roaming and Local can contain application settings, scripts, caches and configuration artefacts.

Roaming AppData
dir "%APPDATA%" /s /b 2>nul
Local AppData
dir "%LOCALAPPDATA%" /s /b 2>nul
15

Web server files

On IIS systems the default web root is commonly C:\inetpub\wwwroot. Web application files can reveal configuration files, scripts and CTF artefacts.

Enumerate IIS web root
dir C:\inetpub\wwwroot /a /s /b 2>nul
Find web.config
dir C:\inetpub\wwwroot\web.config /s /b 2>nul
16

Windows Panther

Windows setup information may remain under the Panther directories. In training environments these files can be useful enumeration targets.

Panther directory
dir C:\Windows\Panther /a /s /b 2>nul
Search unattended installation files
dir C:\Windows\Panther\*unattend* /s /b 2>nul
17

PowerShell history

PowerShell command history can reveal commands previously executed by the current user. The default PSReadLine history commonly exists below the roaming AppData directory.

Locate PowerShell history
dir "%APPDATA%\Microsoft\Windows\PowerShell\PSReadLine" /a /s /b 2>nul
18

Search the entire drive as a fallback

A full recursive search can produce a large amount of output and should generally come after targeted enumeration.

Search entire drive for flag filenames
dir C:\*flag* /s /b 2>nul
Search for text files
dir C:\*.txt /s /b 2>nul
19

CTF workflow

A practical workflow is to enumerate the current profile first, inspect application and web directories next, search interesting filenames and extensions, and only perform a full-drive recursive search if targeted searches do not reveal anything.

Step 1 — user profile
dir "%USERPROFILE%" /a /s /b 2>nul
Step 2 — interesting filenames
dir "%USERPROFILE%\*flag*" /s /b 2>nul
Step 3 — ProgramData
dir C:\ProgramData /a /s /b 2>nul
Step 4 — entire drive if needed
dir C:\*flag* /s /b 2>nul