我试图在Ruby中实现osquery的扩展。
我在Java、Node和Python中发现了一些类似的库和例子,但是在Ruby语言中没有什么有用的实现。
根据这个文档,有可能使用https://osquery.readthedocs.io/en/stable/development/osquery-sdk/#thrift-api:生成代码
到目前为止,我所做的步骤:
thrift -r --gen rb osquery.thrift生成代码这是这个类的代码
# include thrift-generated code
$:.push('./gen-rb')
require 'thrift'
require 'extension_manager'
socket = Thrift::UNIXSocket.new(<path_to_socket>)
transport = Thrift::FramedTransport.new(socket)
protocol = Thrift::BinaryProtocol.new(transport)
client = ExtensionManager::Client.new(protocol)
transport.open()
info = InternalExtensionInfo.new
info.name = "zzz"
info.version = "1.0"
extension = ExtensionManager::RegisterExtension_args.new
extension.info = info
client.registerExtension(extension, {'table' => {'zzz' => [{'name' => 'TEXT'}]}})要获得您可以使用的<path_to_socket>:
> osqueryi --nodisable_extensions
osquery> select value from osquery_flags where name = 'extensions_socket';
+-----------------------------------+
| value |
+-----------------------------------+
| /Users/USERNAME/.osquery/shell.em |
+-----------------------------------+当我试图使用osqueryi获取这个表时,我在运行select * from osquery_registry;时看不到该表。
有没有人可能已经实现了一个osquery扩展?我被困住了,我不知道怎么从这里开始。
发布于 2020-08-28 17:24:56
我不认为我见过任何人做红宝石的延伸,但一旦你有节俭的一面,这应该是相当简单的。
作为一种工具,osquery支持许多选项。所以没有一个方法可以做到这一点。一般说来,扩展作为自己的进程运行,并且通过节约套接字进行通信。
通常,它们非常简单,osquery使用适当的命令行参数直接调用扩展。这在您链接到的接受文档、--socket和--timeout的示例中得到了暗示。如果这样做,您将需要查看osquery的--extensions_autoload和--extensions_require选项。(我推荐这条路线)
较不常见的方法是使用--extensions_socket使用指定的套接字路径启动osquery。然后你的分机就可以使用了。这种方式比较常见的是扩展不能是一个简单的二进制,而是一个大的复杂系统。
发布于 2021-07-09 23:05:58
我发现自己通过红宝石玩节俭。如果我使用的是BufferedTransport,它似乎是可行的:
socket = Thrift::UNIXSocket.new('/tmp/osq.sock')
transport = Thrift::BufferedTransport.new(socket)
protocol = Thrift::BinaryProtocol.new(transport)
client = ExtensionManager::Client.new(protocol)
transport.open()
client.ping()
client.query("select 1")https://stackoverflow.com/questions/63628223
复制相似问题