dir
General:
- For all commands: Use /p to get a pause for large outputs to scroll over!
- Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a! Everytime! Use /a!
Usual commands:
- Search recursive:
dir /s /a *.txt - Show hidden files:
dir /ah - Show system files:
dir /as - Show file ownership information
dir /q - Show … more?!
dir -force - Show also alternate data streams:
dir /R- Read alternative data streams: If a file is listed like
root.txt:root.txt:$DATA, then you can read the file with more (yes, on Windows):more < root.txt:root.txt:$DATA
- Read alternative data streams: If a file is listed like
Therefore: Remember to use dir /R /as /ah -force.
tree
Start with creating a list of all directories and files. Download it. It’s way easier to look in a local editor and it’s stored for the future as well.
tree c:\ > C:\Windows\Temp\dsys\dirs.txt
dir /s /R /as /ah c:\ > C:\Windows\Temp\dsys\files.txt
(Download the files)
find (=grep)
Search for a string in an output, e.g. in a directory listing:
dir | find "eyfile"
Search one string in a single files:
find "assword" $file
Search a string out of a set of strings in a single file (Note: findstr supports regexp):
findstr "assword eyfile" $file
Grab line 101 from a large text file: Use findstr /n to output the textfile with line numbers, then filter for your number.
findstr /n $searchstring $file |find "101"
Find a string in a large file / output and get the lines around it:
type d.txt | findstr /n ^^ | findstr "Igor" // Search for a string to determine the line number. type d.txt | findstr /n ^^ | findstr "^323" // Here, the string appears at line 32318. 323 shows 100 lines around.
wc (word cound)
There is no wc command for Windows, but with the following, a line count can be displayed:
type $largefile | find /c /v ""
File system permissions
Check permissions with icacls:
icacls file.exe
Manual directory inspection
Now, check the following directories:
- C:\Users
- C:\Program Files [(x86)]
- Create a list with each non-standard program.
- Search for exploits.
- Search for sensitive informations in
- the files within the program directory
findstr /spin "assword" . - the registry (try to find the path(s) in the net)
reg query "HKCU\Software\SimonTatham\PuTTY\Sessions"
- the files within the program directory
- Check if program files are writeable:
certutil.exe -urlcache -split -f "http://$ownIP/accesschk.exe" accesschk.exe
accesschk.exe /accepteula -uws "Everyone" "C:\Program Files" - Check for unquoted service path. E.g. for C:\Program Files\app 2\app.exe:
- C:\Program.exe
- C:\Program Files\app.exe
- C:\Inetpub (or another server directory)
- Possible interesting files:
%windir%\debug\NetSetup.log #AD domain name, DC name, internal IP, DA account - Check drives with
wmic logicaldisk get caption || fsutil fsinfo drivesand then D:\ E:\ .… - Look into the trash:
dir C:\$Recycle.Bin /s /b /R
Advanced
- Search for files within an interesting time window:
powershell.exe -ExecutionPolicy ByPass -command "& { Get-ChildItem -ErrorAction SilentlyContinue -Path c:\ -Recurse | Where-Object -FilterScript { $_.LastWriteTime -ge (Get-Date '16 Mar 2017 00:00') } | Where-Object -FilterScript { $_.LastWriteTime -lt (Get-Date '18 Mar 2017 00:00') } }" - Find password strings:
findstr /si password *.* - Find recently changed files:
Get-ChildItem -Path c:\ -Recurse | Where-Object -FilterScript { $_.LastWriteTime -ge (Get-Date).AddHours(-24) } - Search for unattend.xml files / provisional files. These files are often created by Windows for background jobs and could contain credentials.
dir -force /as /s *nattend.xml
Leave a Reply
You must be logged in to post a comment.