Intro
I am integrating EndpointSecurity Framework and observing ES_EVENT_TYPE_AUTH_EXEC
event.
I able to see the command arguments, but I am not able to read the command input.
Assuming that the command is as follow:
thirdPartyApp do something < ~/Desktop/file.txt
My code is: (msg is a value of type es_event_exec_t *
)
for (int i = 0; i < es_exec_arg_count(&msg->event.exec); i++) {
es_string_token_t arg = es_exec_arg(&msg->event.exec, i);
print("arg: %s",arg.data);
}
Challenge is
The code output is only:
thirdPartyApp do something , without < ~/Desktop/file.txt
The thing is, < ~/Desktop/file.txt is not an argument, its a redirect as described here
What did I try?
- I tried to read the env arguments too, but they were not helpful at all.
- I tried to read the file descriptors, and then to read the file using NSFileHandle but they all were empty, 0 bytes.
Waiting to here from you