-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Designing a API to read/write syscall's arguments #8
Comments
Have you explored the idea of OS specific SysCalls? Something like It is important to choose the right level of abstraction when designing such APIs. And at this level of abstraction we are very close to the OS implementation details. This is just an example:
where I do agree with the proposal of leaving the parameters as a list. The End User could build an extra abstraction layer to map his/her own SysCalls with the parameters names.
|
The PR #11 brings a first answer to this issue. The syscall class has now an It is defined in this way: class ArgumentMap:
CONVENTION = {
SyscallType.syscall: [
(SyscallArgumentType.register, 'rcx'),
(SyscallArgumentType.register, 'rdx'),
(SyscallArgumentType.register, 'r8'),
(SyscallArgumentType.register, 'r9'),
(SyscallArgumentType.memory, 5),
],
} The argument can be mapped in a register, or in memory. If the argument index is out of bounds, it will be fetched in memory anyway, as we don't know precisely what is the maximum number of parameters allow for a Windows syscall. |
Hi, I think there is another issue to be addressed, Best regards, S.P. |
Problem 1 : an API to access the syscall arguments
We need to design a API on top of the
Sycall
object that we are building from aNitro
eventl to provide a transparent way to get the syscall arguments for the user accross different operating systems and conventions.Let's take for example
NtOpenFile
MSDN definition:The arguments will be passed to the kernel in a specific way, which depends on
syscall
orsysenter
)Windows/Linux syscall arguments passing
References
Key findings
Problem 2 : Modifying the syscall arguments
An interesting feature of
Nitro
is the ability to modify the syscall arguments on the fly, and change the behavior of the guest.Following what we discovered previously, if we want to provide such an API, it has to cover 2 cases:
Windows
)Respectively, we have 2 solutions :
ioctl
to replace the registers valuelibvmi
'svmi_write_va
API to write the memoryCurrent design
This is how a
Nitro
syscall callback currently looks likeIssues
collect_args
is limited to theWindows/syscall
convention, which is hardcoded right now*rest, object_attributes = syscall.collect_args(3)
Proposal
A new callback interface has been designed previously.
The backend is now sent as a parameter.
Apart from that, if we want the
Syscall
object to be able to modify the arguments, we need to pass theNitro
object which provides the API overnitro
's ioctls, as well aslibvmi
.Also, it might be interesting to make use of
Python
's__getitem__
and__setitem__
methods, to provide alist
like API for the developer. He could access the arguments directly index them and this solves the previous issue raised aboutcollect_args
.What a use case could look like:
-> Behing the scene, how could we design the
Syscall
class to make an interface accross the various calling conventions that we saw at the beginning ?The text was updated successfully, but these errors were encountered: