SQL · Log Investigation

SQL: Filtering Data for Security Investigations

Used SQL filters to investigate suspicious logins and to list exactly which machines needed security updates.

Case study · Google Cybersecurity Professional CertificateSQLMariaDBAND / OR / NOTLIKE
SQL: Filtering Data for Security Investigations
6
targeted queries
2
tables investigated
4
filter operators
S

Situation

An organisation's database held login attempts and employee records. There had been a possible incident after business hours, and several departments needed security updates on their machines.

T

Task

Write SQL queries that pull exactly the records each investigation or update needs, from tables too large to review by hand.

A

Action

  • Found failed login attempts after 18:00 by combining conditions with AND.
  • Pulled login attempts on the day of a suspicious event and the day before, using OR.
  • Excluded an expected country stored in two formats (MEX and MEXICO) using NOT and LIKE 'MEX%'.
  • Listed machines for targeted patching by department and building, using LIKE 'East%'.
R

Result

  • Turned large tables into the precise lists the security team needed, in seconds.
  • Later reused these skills in the SOC Analyst Toolkit and approached them from the attacker's side with a SQL-injection detection rule.

Theme Colors