Capturing password spray logins from /var/log/auth.log

CS0-004 By islever Editorial Last updated

Given a scenario, analyze indicators of potential malicious activity. Given a scenario, implement incident response techniques.

Short answer

D The analyst should run `cat /var/log/auth.log | grep "User1" > linux-events.txt` to capture both successful and unsuccessful User1 logins in the linux-events flat file.

Question

A SOC analyst investigates the results of a password spray test. The analyst must identify Linux systems that have successful and unsuccessful logins with username "User1" and create an output report named "linux-events" of all the events to a flat file. The analyst issues ls /var/log/. Which of the following commands should the analyst use to meet the report output requirements?
  1. cat /var/log/sssd | grep "User1" > linux-events.txt
  2. cat /var/log/faillog.log | grep "User1" > linux-events.txt
  3. cat /var/log/syslog | grep "User1" > linux-events.txt
  4. cat /var/log/auth.log | grep "User1" > linux-events.txt Correct Answer

Key Takeaways

Password-spray investigation reporting hinges on choosing the Linux log that records both accepted and rejected authentication events for the sprayed account. The correct command is cat /var/log/auth.log | grep "User1" > linux-events.txt (option D), because auth.log consolidates sshd and PAM success and failure records, whereas sssd is a service path, faillog covers only failures, and syslog is a less precise catch-all.

Expert Analysis

/var/log/auth.log on Debian/Ubuntu-style Linux records both accepted and rejected authentication events (SSH, PAM, sudo), so cat... | grep "User1" > linux-events.txt produces the required flat-file report covering successful and unsuccessful logins.

The deciding constraint in this scenario is that the report must contain both successful and unsuccessful logins for the username User1, and it must be written to a flat file named linux-events. Among the four candidate sources, only /var/log/auth.log consolidates every authentication outcome in one stream. A password spray test against SSH or other PAM-backed services produces Accepted password for User1 from... lines on success and Failed password for User1 from... lines on failure, and both of those lines land in auth.log on Debian/Ubuntu systems. Piping that file through grep "User1" therefore captures the complete login history for the sprayed account, and the > redirection satisfies the flat-file output requirement.

Option A, cat /var/log/sssd, fails on path validity: sssd is the directory containing the System Security Services Daemon's configuration and cache files, not a log stream, so cat on it produces no event lines at all. Even if the intent were SSSD's own debug log, that source covers only the identity-provider daemon's output and would miss the sshd and PAM acceptance/rejection records that a password spray actually generates. Option B, cat /var/log/faillog.log, fails on the success/failure coverage requirement: faillog-style data is failure-oriented (and on traditional systems /var/log/faillog is even a binary utmp-backed file rather than text), so it cannot yield the successful logins the analyst must report. Option C, cat /var/log/syslog, fails on precision rather than on outright absence — syslog is the general catch-all daemon log, and while authentication messages can be mirrored there depending on rsyslog rules, the dedicated authentication log is the authoritative, guaranteed source; a broad syslog may also be rotated or filtered such that the accepted/rejected pairs are not reliably present.

One mechanism this scenario relies on but does not spell out is the distinction between the file the shell opens and the process that writes it: sshd does not write auth.log directly. Instead, sshd and PAM call syslog/logger, rsyslog receives the facility-priority pair (typically auth/authpriv), and an rsyslog rule routes those facilities to /var/log/auth.log while everything else goes to syslog. That routing rule is precisely why auth.log is guaranteed to hold both Accepted and Failed records for User1 while syslog holds only what the ruleset happens to forward — and why an analyst running ls /var/log/ should pick the authentication-specific file over the generic one when the question names login outcomes. The correct command is therefore cat /var/log/auth.log | grep "User1" > linux-events.txt, matching option D.

Official Reference

https://manpages.debian.org/latest/rsyslog/rsyslog.conf.html

This link opens the official vendor documentation in a new tab.

Exam Strategy

When a Linux log-forensics question names both successful and unsuccessful events, first eliminate options whose source cannot contain one of the two outcomes: failure-only files (faillog), service directories (sssd), or catch-all logs (syslog) that lack a guaranteed authentication rule. Then confirm the remaining option's file is a real text log written via rsyslog for the auth/authpriv facilities. Finally, verify the redirection target matches the requested report name exactly, since the shell's > is what satisfies the flat-file output requirement.

Practice All CS0-004 Questions

Access 101 questions with complete answers and detailed explanations.

View Full CS0-004 Practice Test →

← Back to CS0-004 Study Guide