Skip to content

Instantly share code, notes, and snippets.

@mgramin
Last active March 31, 2024 11:40
Show Gist options
  • Select an option

  • Save mgramin/0dd3872813047a27886d387a188781cd to your computer and use it in GitHub Desktop.

Select an option

Save mgramin/0dd3872813047a27886d387a188781cd to your computer and use it in GitHub Desktop.
Simple REST service for osquery
from flask import Flask, request
from flask_restful import Api, Resource
import osquery
class User(Resource):
@staticmethod
def get():
instance = osquery.SpawnInstance()
instance.open()
query = request.args.get('query', default='', type=str)
query = instance.client.query(query)
return query.response, 200
@staticmethod
def post():
instance = osquery.SpawnInstance()
instance.open()
query = request.data
query = instance.client.query(query)
return query.response, 200
app = Flask(__name__)
api = Api(app)
api.add_resource(User, "/exec")
app.run(host='0.0.0.0', debug=True, threaded=True, port=8082)
@mgramin
Copy link
Author

mgramin commented Jun 4, 2019

@RamrajSekar
Hi, its very simple:

curl -d 'select version from os_version' -H "Content-Type: application/json" -X POST http://127.0.0.1:8082/exec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment