osquery
osquery exposes an operating system as a relational database so you can query processes, users, network connections and more with SQL.
Legal & ethical use. Use this tool only on systems, networks and data that you own or have explicit written permission to test. Unauthorised access or scanning can break computer-misuse laws (for example Pakistan's Prevention of Electronic Crimes Act, 2016, and equivalents elsewhere). Practise in your own lab or in authorised environments such as CTFs.
What it is used for
- Hunt for unexpected listening ports or startup items on lab hosts
- Build scheduled queries for monitoring
Key features
- SQL interface to OS data
- Cross-platform
- Scheduled queries and packs
Installation
Install packages from osquery.io/downloads.
Beginner usage guide
Start osqueryi and run a query for listening ports, then adapt it to your own questions.
Example commands
Run these only against your own lab or authorised targets. Placeholder addresses such as 192.0.2.x are documentation ranges.
Interactive query
osqueryi "SELECT pid, port, address FROM listening_ports LIMIT 10;"Shows processes listening on network ports.
References
Source verification
Last reviewed: 2026-10-27
Links checked over HTTP: 2026-10-27 07:51 UTC — official: 200, docs: 200, repo: 200
Commands were written from the official documentation and have not been executed on this site; test them in your lab.
