Endpoint visibility

Lessons on osquery, Velociraptor, and Wazuh: what a log instant, a notebook query, a rule id, or a file-change type does not prove.

  • 25 lessons
  • 4.5 h of reading
  • 3 topics

An alert names a host; the investigation needs facts from it: processes, listeners, scheduled tasks, recent file changes. These lessons start with one lab machine and grow to fleet-wide scheduled queries and hunts.

Install agents only on machines you administer. Endpoint telemetry includes user activity, so agree retention and access with whoever owns those machines.

  1. 01osqueryi: ask a host questions in SQLUse osqueryi on a lab Linux or Windows host to answer triage questions in SQL: which processes listen on the network, which binaries are deleted from disk, and what starts at boot.11 min
  2. 02osqueryd schedules: turn a question into fleet telemetryConfigure osqueryd with scheduled queries, read its differential result logs, and ship only additions and removals so a fleet-wide view of new listeners or startup items stays small.11 min
  3. 03osquery: what one result row is evidence ofAn osqueryi row is the columns you selected, on that host, when you ran the SQL. Write the host, the UTC time, and the query. A column you left out is not a fact.11 min
  4. 04osqueryd: added and removed are changes in the resultaction added means the row was not in the previous result. action removed means it left that result. Neither line says why, and the first run marks every current row added.11 min
  5. 05osquery: the schedule name is not the SQLA results line names the schedule key, not the statement. Write the key, the time, and the SQL from the config that was loaded. Do not invent the columns from the key’s name.11 min
  6. 06osquery: the gap between lines is not the intervalTwo result lines have two unixTime values. The schedule interval lives in the config. Write the measured gap and the configured interval separately, and do not correct one to match the other.12 min
  7. 07osquery: the host identifier is not a selected columnThe host identifier on a result line is who the daemon says sent it. A hostname column is a value the SQL returned. Write both, and do not replace the identifier with that column.11 min
  8. 08osquery: the counter is not the row countThe counter on a result line is how many times that query has run in the current epoch. One line is one row. Write the counter as an execution count, and do not read it as how many rows came back.11 min
  9. 09osquery: calendarTime and unixTime are one instantOn one result line, calendarTime and unixTime are the same moment in two writings. They are not two events. Write one instant, and do not subtract them to invent a duration.11 min
  1. 01Velociraptor: stand up a lab server and collect from one endpointRun Velociraptor’s self-contained lab mode, enrol a test client, and collect process, network, and prefetch artifacts from it, keeping the collection results as evidence.12 min
  2. 02Velociraptor hunts: one VQL question across every lab endpointWrite a VQL query in a notebook, wrap it as a custom artifact, and run it as a hunt across lab endpoints to find every host with a suspicious scheduled task or run key.12 min
  3. 03Velociraptor: read the collection status before the rowsAn empty Velociraptor table can mean a finished artifact found nothing, or that the collection never measured the host. Write the flow state, the artifact name, and the client id before you write “nothing was there.”12 min
  4. 04Velociraptor: the hostname is not the client idThe client id is the server’s identifier for an enrollment. The hostname is a string the client reported. Write the client id. Do not merge two enrollments because they reported the same name.11 min
  5. 05Velociraptor: the parameters are part of the requestA hunt or collection result is for the parameter values that were sent. Write those values from the request. The hunt’s display name does not say what was asked.12 min
  6. 06Velociraptor: the hunt id is not one client’s flowA hunt id is the fleet job. Each client’s rows belong to that client’s flow id. Write both. Do not quote one client’s rows under only the hunt id.11 min
  7. 07Velociraptor: last seen is not the collection timeLast seen is when the client last checked in. The flow start and end are when that collection ran. Write both clocks, and do not describe yesterday’s rows as if they were taken at the check-in.12 min
  8. 08Velociraptor: the notebook text is not the flowThe VQL in a notebook today is the text saved there now. A finished flow used the definition it stored when it ran. Write which one you opened, and do not explain an old flow with a query you edited later.12 min
  1. 01Wazuh: watch configuration files and write a local ruleTurn on Wazuh file integrity monitoring for a lab server’s configuration folders, test a custom rule with wazuh-logtest, and read the resulting alert in alerts.json.12 min
  2. 02Wazuh: rule.level is the rule’s number, not the incidentAn alerts.json object means a rule matched. Write rule.id, the agent, the path, and whether user or process fields are present. The level and the description are text the rule author set.11 min
  3. 03Wazuh: the agent id is not the agent nameagent.id is the manager’s id for an enrollment. agent.name is a label. Write the id. A rebuilt lab host can reuse the name with a new id, and the alerts are not one series.11 min
  4. 04Wazuh: a file hash on an alert is not a verdictA hash on a file-integrity alert is the digest the agent stored for that path at that time. Write the algorithm, the hash, and the path. The digest does not say the file is unwanted.11 min
  5. 05Wazuh: location is the path the agent reportedThe location field is the log or file path the agent reported. It is not a path on the manager, and it is not the agent name. Write it next to the agent id.11 min
  6. 06Wazuh: full_log is the raw linefull_log is the text the agent sent. Fields under data are what the decoder extracted. A word that appears only in the raw line is not a decoded field, and an empty field does not erase the raw line.12 min
  7. 07Wazuh: the rule id is not the levelrule.id is which rule matched. rule.level is the number that rule carries. They are different fields. Write both, and do not look up rule 12 when the level is 12 and the id is something else.11 min
  8. 08Wazuh: the syscheck event is the change typeOn a file-integrity alert, the syscheck event value says added, modified, or deleted as the agent reported it. It is not a verdict about the file. Write the word with the path.11 min