Hi fellows, when I run my extension without Admini...
# extensions
p
Hi fellows, when I run my extension without Administrator privileges I get this error, which I expect, cos' the pipe was opened by an elevated process:
Unable to connect to \\.\pipe\osquery.em with uds_windows::UnixStream: Os { code: 10013, kind: PermissionDenied, message: "An attempt was made to access a socket in a way forbidden by its access permissions." }
But when I execute with Admin user or as the user guide explains to manually load an extension it cannot connect to the socket with this error:
Unable to connect to \\.\pipe\osquery.em with uds_windows::UnixStream: Os { code: 10061, kind: ConnectionRefused, message: "No connection could be made because the target machine actively refused it." }
I just checked the flags to include the path and name of the socket and enable the extension loading:
Copy code
--extensions_socket=\\.\pipe\osquery.em
--disable_extensions=false
I compiled the extension, moved it to the installed folder of osquery (
c:\Programs Files\osquery
) as
myshinny.ext.exe
and executed like this without success:
.\osqueryi.exe --allow-unsafe --extension myshinny.ext.exe
Then I tried to create a Extension folder, move the extensions inside it and apply the
icacls.exe
commands listed on the osquery's extension guide but again with no success. I'm trying to update the (https://github.com/zacbrown/osquery-rs) to support windows through (https://github.com/haraldh/rust_uds_windows/)
Unable to connect to \\.\pipe\shell.em with uds_windows::UnixStream: Os { code: 10061, kind: ConnectionRefused, message: "No connection could be made because the target machine actively refused it." }
m
although
--allow-unsafe
ought to have bypassed that problem and apparently it did not
Does the example extension work?
p
the example extension on the osquery-rs repo?
they are built to work on unix like system's
m
Oh, I meant checking that the example extension in the osquery core repo would load correctly as a sanity test, but I suppose there are several. https://github.com/osquery/osquery/tree/master/external/examples
the osquery extensions SDK changed since 3 years ago when it looks like zacbrown/osquery-rs was written, perhaps that is it
p
So the SDK in Windows uses the socket/pipe internally to communicate with osquery? I'll try to build those examples and investigate further, thanks for your time @Mike Myers
m
building osquery from source should build the example extensions automatically (I think)
in Windows, Thrift is implemented as a Named Pipe, whereas on POSIX it's a Unix Domain Socket yes
Ah, but
Unable to connect to \\.\pipe\osquery.em with uds_windows::UnixStream: Os { code: 10061, kind: ConnectionRefused, message: "No connection could be made because the target machine actively refused it." }
implies that the Rust code is trying to use a Unix Domain Socket abstraction instead of a Named Pipe
p
the uds_windows is a lib to open a af_linux socket in windows (since it got support in 2017), I dont think this gonna work in this case, do you? I don't have deep understand about those 2, but I think the communication differs between each other, what you think?
m
I don't think it's the right thing in this case. Is the Rust
thrift
crate trying to use that?
p
No
Zac created a custom server to connect to the socket via UnixSocket
But leave the Windows part unimplemented
m
A Windows named pipe has its own API. Here I'll find the osquery code that has the conditional stuff for Windows Thrift connections
oh, osquery just uses Thrift classes like
TPipeServer
, but Thrift itself handles the underlying Windows API
CreateNamedPipeA
Giving the Thrift rust crate a look, I am not sure they made a wrapper for
TPipeServer
here, only
TServer
p
that's why he created the custom LocalServer
m
I see. At least on the osquery side, the code is using the Thrift cpp library where
TPipeServer
exists and that's what it uses on Windows
Maybe one day the project can use this https://github.com/apache/thrift/pull/2327
Ah yea, confirmed: Rust doesn't have the Pipe implemented https://github.com/apache/thrift/blob/master/LANGUAGES.md
p
Fantastic mate, thanks again. You cover all the points. So in this point in time I cannot go further with this implementation.
👍 1