Last active
March 31, 2024 11:40
-
-
Save mgramin/0dd3872813047a27886d387a188781cd to your computer and use it in GitHub Desktop.
Simple REST service for osquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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