Introduction To Windows Command Line

Cyberkur Syiem 0 Reputation points
2023-05-26T05:31:28.6966667+00:00

Question: User4 has a lot of files and folders in their Documents folder. The flag can be found within one of them.

:\Users\user4\Documents\3\11\24\flag.txt

C:\Users\user4\Documents\3\11\25\flag.txt

C:\Users\user4\Documents\3\11\26\flag.txt

C:\Users\user4\Documents\3\11\27\flag.txt

C:\Users\user4\Documents\3\11\28\flag.txt

C:\Users\user4\Documents\3\11\29\flag.txt

C:\Users\user4\Documents\3\11\30\flag.txt

C:\Users\user4\Documents\3\2\flag.txt

C:\Users\user4\Documents\3\2\20\flag.txt

C:\Users\user4\Documents\3\2\21\flag.txt

C:\Users\user4\Documents\3\2\22\flag.txt

C:\Users\user4\Documents\3\2\23\flag.txt

C:\Users\user4\Documents\3\2\24\flag.txt

C:\Users\user4\Documents\3\2\25\flag.txt

C:\Users\user4\Documents\3\2\26\flag.txt

C:\Users\user4\Documents\3\2\27\flag.txt

C:\Users\user4\Documents\3\2\28\flag.txt

C:\Users\user4\Documents\3\2\29\flag.txt

C:\Users\user4\Documents\3\2\30\flag.txt

C:\Users\user4\Documents\3\3\flag.txt

C:\Users\user4\Documents\3\3\20\flag.txt

C:\Users\user4\Documents\3\3\21\flag.txt

C:\Users\user4\Documents\3\3\22\flag.txt

C:\Users\user4\Documents\3\3\23\flag.txt

C:\Users\user4\Documents\3\3\24\flag.txt

C:\Users\user4\Documents\3\3\25\flag.txt

C:\Users\user4\Documents\3\3\26\flag.txt

C:\Users\user4\Documents\3\3\27\flag.txt

C:\Users\user4\Documents\3\3\28\flag.txt

C:\Users\user4\Documents\3\3\29\flag.txt

C:\Users\user4\Documents\3\3\30\flag.txt

C:\Users\user4\Documents\3\4\flag.txt

C:\Users\user4\Documents\3\4\20\flag.txt

C:\Users\user4\Documents\3\4\21\flag.txt

C:\Users\user4\Documents\3\4\22\flag.txt

C:\Users\user4\Documents\3\4\

yesterday i asked about this one: i asked that there are more than 30 flag.txt along with the sub-files but only one of them is having a text inside and the rest is empty. so to read all these is not possible. how would i give a cmd command to read this?

you suggested me the command but is not working. when i simply type (findstr C:\Users\user4\flag.txt) it simply takes more time.

so how can i search and find the right answer and save the time as well?

thank you.

Windows 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,779 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,382 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,403 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Cyberkur Syiem 0 Reputation points
    2023-05-26T06:03:32.35+00:00

    findstr [/b] [/e] [/l | /r] [/s] [/i] [/x] [/v] [/n] [/m] [/o] [/p] [/f:flag.txt] [/c:<string>] [/g:flag.txt] [/d:<dirlist>] [/a:<colorattribute>] [/off[line]] <strings> [C:][Users\user4\Documents]flag.txt[ ...]

    The system cannot find the file specified.

    findstr C:\Users\user4\Documents\flag.txt (this one doesn't even show anything)

    0 comments No comments

  2. Rich Matheisen 45,111 Reputation points
    2023-05-26T15:29:45.2166667+00:00

    Since you've asked this question and placed a "Windows Server PowerShell" tag on it, why limit yourself to using the old MS-DOS stuff?

    Get-ChildItem C:\Users\user4\Documents -Include Flag.txt -Recurse -File |
        ForEach-Object{
            if (Select-String -Path $_.FullName -SimpleMatch -Pattern FLAG -Quiet){
                Write-Host "Found 'FLAG' in file $($_.FullName)"
            }
        }
    
    
    
    

    Replace the "FLAG" with whatever string you're looking for.

    0 comments No comments

  3. s67533650 5 Reputation points
    2024-04-30T22:53:28.5333333+00:00

    Hey bro, so i got the answer on this way:

    1: I change from CMD to PS

    2 Filter all objects with the .txt extension and concatenate to Sort-Object to filter all files:

    
    PS C:\Users\user4\Documents> Get-ChildItem -Path C:\Users\user4\Documents\ -Filter "*.txt" -Recurse -File | Sort-Object -Property LastWriteTime
    
    

    3: Once you got the path you can move to the directory and use "type" or "more" to read the file

    
    type flag.txt
    
    

    I wish i can help because i was like 30min finding the way.

    :slight_smile:

    0 comments No comments