A penetration tester has gained access to a compromised Windows server. The tester needs to search all .log files in the C:\ProgramData\AppLogs\ directory and its subdirectories for the IP address 10.100.50.25. The output must include the line number for each match to help with contextual analysis. Which of the following commands would most efficiently achieve this task?
The correct command, findstr /s /n "10.100.50.25" C:\ProgramData\AppLogs\*.log, is the most efficient method. The /s switch performs a recursive search through subdirectories, and the /n switch includes the line number for each match. Using findstr without /s fails to search subdirectories. Using grep is incorrect because it is not a native Windows command. Piping output from the strings command is less direct and does not provide the required line numbers.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `/s` switch do in the findstr command?
Open an interactive chat with Bash
Why is the `/n` switch important in the findstr command?
Open an interactive chat with Bash
Why can’t the `grep` command be used in this scenario?