Glen
10/25/2023, 2:47 PMbioutil
command, but that isn’t great for change detection. Maybe there’s a way to query changes via asl
logging? Asking here because possibly someone has already figured this out?seph
Glen
10/26/2023, 1:25 PMseph
seph
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WinBio\AccountInfo\%\EnrolledFactors
, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\NgcPin\Credentials\%\EncryptedPassword
, and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\FaceLogonEnrolledUsers\%
Glen
10/26/2023, 6:17 PMlog stream
filters.
Very specifically adding a fingerprint on osx for touchid can be found using this super specific filter:
log stream --predicate 'subsystem == "com.apple.preference.passwordpref" && eventMessage CONTAINS[c] "BiometricKitUIEnrollResult 4"'
Do you know how I could get this via osquery?
This doc helped me query this log: https://eclecticlight.co/2016/10/17/log-a-primer-on-predicates/Glen
10/26/2023, 6:19 PMlog stream --predicate 'subsystem == "com.apple.preference.passwordpref" && eventMessage CONTAINS[c] "removeFingerprintWithUUID"'
Glen
11/01/2023, 7:01 PMunified_logs
table. Do you have or know of example code querying that I could use? re your commentBrad Girardeau
11/01/2023, 7:14 PMselect * from unified_log where
timestamp > -1 and
max_rows = 1000 and
predicate = 'subystem == ...';
The challenges with that simple query are:
• Across your schedule, you can only have 1 query with timestamp > -1
, otherwise they will steal each others long entries, because the last read log entry is a global value for osquery
◦ You have to be particularly careful that the SQL planner doesn't split this up to run two queries behind the scenes too -- generally only use AND conditions and confirm with osqueryi --planner
• When the query first runs, it will scan the entire unified log, which takes several minutes and uses gigabytes of memory. This causes osquery watchdog to kill the query (and anecdotally this maybe triggers a bug in Apple's framework, it doesn't seem to like to be interrupted in the middle of querying)Brad Girardeau
11/01/2023, 7:23 PMwith now_ts as (
select unix_time as t from time
),
filtered_log as (
select * from unified_log where
timestamp > -1 and
timestamp > (select t - 720 from now_ts) and
max_rows = 10000 and
predicate = concat(
'([event predicate1]) || ',
'([event predicate2])'
)
),
event_type1 as (
select
'event_type1' as event_type, timestamp, message from filtered_log where ...
),
event_type2 as (
select
'event_type2' as event_type, timestamp, message from filtered_log where ...
)
select * from event_type1 union
select * from event_type2
This does a single query to the unified log to get a copy of different event types that pass any of multiple initial filtering predicates, then further tables query each of the events of interest into a common set of columns (using json_object
for comes in handy there).
It only goes back in the log for at most 12 minutes to keep runtime and resource usage more under control, so just accepting some event loss here outside that lookback. I'd like to dig in more and get that 12 minutes up to a few hours at least. Already had to bump watchdog settings especially for memory (~3.5GB) to avoid this getting denylisted on most machines, and does get denylisted for ~5% of our fleet on any given day still. Some apps just seem to spew a huge amount of noise into this log. You could try being even more permissive in watchdog settings, at risk of more problems from a bad query elsewhereGlen
11/01/2023, 8:11 PMBrad Girardeau
11/01/2023, 9:12 PM