I installed osquery using:
Verified it works:
$ osqueryi
Using a virtual database. Need help, type'.help'
osquery>selecttimestamp from time;
+------------------------------+
| timestamp |
+------------------------------+
| Mon Apr 17 15:36:50 2023 UTC |
+------------------------------+
Copied the code from README:
importosqueryif__name__=="__main__":
instance=osquery.SpawnInstance()
instance.open()
instance.client.query("select timestamp from time;")When I ran above code, I get this error:
Traceback (mostrecentcalllast):
File"main.py", line5, in<module>instance.open()
File"./venv/lib/python3.8/site-packages/osquery/management.py", line137, inopenraiseException("Cannot start process from path: %s"% (self.path))
Exception: Cannotstartprocessfrompath: /usr/local/bin/osquerydI then noticed that osqueryi is simply a symlink to osqueryd which the above is looking for:
$ ls -a /usr/local/bin/osqueryi
lrwxr-xr-x 52 root 17 Apr 11:20 /usr/local/bin/osqueryi -> /opt/osquery/lib/osquery.app/Contents/MacOS/osqueryd
So I tried this:
importosqueryif__name__=="__main__":
instance=osquery.SpawnInstance("/usr/local/bin/osqueryi")
instance.open()
instance.client.query("select timestamp from time;")But, now I get different error:
Traceback (mostrecentcalllast):
File"./main.py", line6, in<module>instance.client.query("select timestamp from time;")
File"./venv/lib/python3.8/site-packages/osquery/extensions/ExtensionManager.py", line181, inqueryself.send_query(sql)
File"./venv/lib/python3.8/site-packages/osquery/extensions/ExtensionManager.py", line190, insend_queryself._oprot.trans.flush()
File"./venv/lib/python3.8/site-packages/thrift/transport/TTransport.py", line179, influshself.__trans.write(out)
File"./venv/lib/python3.8/site-packages/thrift/transport/TSocket.py", line172, inwriteraiseTTransportException(type=TTransportException.NOT_OPEN,
thrift.transport.TTransport.TTransportException: TransportnotopenWhat am I doing wrong? Why is running code from the README doesn't work??
I installed osquery using:
Verified it works:
Copied the code from README:
When I ran above code, I get this error:
I then noticed that
osqueryiis simply a symlink toosquerydwhich the above is looking for:$ ls -a /usr/local/bin/osqueryi lrwxr-xr-x 52 root 17 Apr 11:20 /usr/local/bin/osqueryi -> /opt/osquery/lib/osquery.app/Contents/MacOS/osquerydSo I tried this:
But, now I get different error:
What am I doing wrong? Why is running code from the README doesn't work??