Osquery
osquery.io
osquery.io
It has its quirks, but there's practically no part of the system you shouldn't be able to get information about using WQL[2].
[1] https://msdn.microsoft.com/en-us/library/ms186146(vs.80).asp...
OSquery can pump results into a DB that you look through, WMI I've got to check for myself what's turned on, did it all report etc.
A driver for wmi in osquery would be a great addition.
https://news.ycombinator.com/item?id=14343967
Previous discussions:
Release: https://news.ycombinator.com/item?id=8528460
Windows release: https://news.ycombinator.com/item?id=12600790
(Links courtesy of https://news.ycombinator.com/item?id=14344549)
Personally upvoted because it's news to me that it supports Windows now, and because it still appears to be very actively developed despite existing for years now.
More details here: https://www.bro.org//bro4pros2017/Haas_OSquery_Bro4Pros2017....
Your example is why we're building our visual playbook system. In this case, query your network scanner for open ports, and then feed the identified hosts into more targeted osquery calls.
By default, osquery uses glog, which means it'll output the results to a local file that you can ship anywhere you want. There's also logging plugins to help you push the results of scheduled queries to other systems.
Once you have that data flowing through your pipelines you can start doing security/anomaly detection on things.
I haven't finished the work yet, but my employer will be feeding the log results into our ELK stack.
There are other frontends like 'doorman' which allow for ad hoc queries. That is a little more work to stand up.
The osquery events seem to solve these kind of monitoring/alerting problems. But I didn't find easily find their documentation.
I just started working at Kolide (http://kolide.com) a couple weeks ago where we're building a whole product on top of osquery. I'm constantly surprised by "can it do (x)" and the answer is almost always yes. It's pretty solid!
"If there are no USB devices added or removed to the laptop, this query would never log a result again. The query would still run every 60 seconds but the results would match the previous run and thus no state change would be detected. If a USB memory stick was inserted and left in the laptop for 60 seconds the daemon would log"
So if you unplug your evil USB earlier, this won't tell you.
I wonder if they've heard of udev.
I'm sure it was sarcastic snark, but of course they have heard of udev: https://github.com/facebook/osquery/search?q=udev.