├── CMakeLists.txt
├── LICENSE
├── README.md
├── examples
└── base_addr.c
├── include
└── ntoseye
│ └── ntoseye.h
├── media
└── ntoseye.png
├── ntoseye
├── capi.cpp
├── capi.hpp
├── cmd.cpp
├── cmd.hpp
├── config.hpp
├── curl.cpp
├── curl.hpp
├── dbg.cpp
├── dbg.hpp
├── gdb.cpp
├── gdb.hpp
├── guest.cpp
├── guest.hpp
├── host.cpp
├── host.hpp
├── log.hpp
├── main.cpp
├── mem.cpp
├── mem.hpp
├── pdb.cpp
├── pdb.hpp
├── termcolors.h
├── util.cpp
├── util.hpp
└── windefs.h
└── version.h.in
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15.0)
2 | project(ntoseye VERSION 0.2.0 LANGUAGES CXX)
3 |
4 | set(CMAKE_CXX_STANDARD 23)
5 |
6 | find_package(Zydis)
7 |
8 | configure_file(version.h.in version.h)
9 | include_directories(${CMAKE_CURRENT_BINARY_DIR})
10 | include_directories(${CMAKE_SOURCE_DIR}/include)
11 |
12 | file(GLOB GLOBBED_SOURCES CONFIGURE_DEPENDS "ntoseye/*.cpp")
13 |
14 | add_executable(ntoseye ${GLOBBED_SOURCES})
15 | target_link_libraries(ntoseye readline Zydis curl LLVM)
16 | target_link_options(ntoseye PRIVATE -rdynamic -g)
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 dmaivel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ntoseye 
4 |
5 | Windows kernel debugger for Linux hosts running Windows under KVM/QEMU.
6 |
7 | ## Features
8 |
9 | - Command line interface
10 | - WinDbg style commands
11 | - Kernel debugging
12 | - PDB fetching
13 | - Breakpointing
14 | - Plugin API (C)
15 |
16 | ### Supported Windows
17 |
18 | `ntoseye` currently only supports Windows 10 and 11 guests.
19 |
20 | ### Disclaimer
21 |
22 | `ntoseye` will ask you if you wish to download symbols (defaults to exports if user declines). It will only download symbols from Microsoft's official symbol server. All files which will be read/written to will be located in `$XDG_CONFIG_HOME/ntoseye`.
23 |
24 | ### Preview
25 |
26 | 
27 |
28 | # Getting started
29 |
30 | ## Dependencies
31 |
32 | | Name | Version |
33 | | ---- | ------- |
34 | | [CMake](https://cmake.org/) | 3.15+ |
35 | | [libreadline](www.gnu.org/software/readline/) | Latest |
36 | | [Zydis](https://github.com/zyantific/zydis) | Latest |
37 | | [LLVM](https://llvm.org/) | 15+ |
38 | | [curl](https://curl.se/) | Latest |
39 |
40 | > [!IMPORTANT]
41 | > A compiler with C++23 support is required. GDB is also required for control flow capabilities (e.g. breakpoints).
42 |
43 | ## Building
44 |
45 | ```bash
46 | git clone https://github.com/dmaivel/ntoseye.git
47 | cd ntoseye
48 | cmake -B build
49 | cmake --build build --config Release
50 | ```
51 |
52 | # Usage
53 |
54 | `ntoseye` takes in no arguments to launch. It is recommended that you run the following command before running `ntoseye` or a VM:
55 | ```bash
56 | echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
57 | ```
58 |
59 | Note that you may need to run `ntoseye` with `sudo` aswell.
60 |
61 | ## VM configuration
62 |
63 | Although it is not required, many features depend on `gdbstub` being enabled.
64 |
65 | #### QEMU
66 |
67 | Append `-s -S` to qemu command.
68 |
69 | #### virt-manager
70 |
71 | Add the following to the XML configuration:
72 | ```xml
73 |
74 | ...
75 |
76 |
77 |
78 |
79 |
80 | ```
81 |
82 | ## Keybinds
83 |
84 | | Key(s) | Description |
85 | | - | - |
86 | | tab | Tab completion. Either lists all available commands or attempts to complete the currently typed out command. |
87 | | ctrl+C | Attempt a breakpoint. Will terminate the debugger if in the middle of a download or hang. |
88 |
89 | ## Commands
90 |
91 | | Command | Description |
92 | |-----------------------------------|------------------------------------------------------------|
93 | | `!pte [VirtualAddress/Symbol]` | Display the page table entries of a given virtual address. |
94 | | `!process 0 0` | Display a list of the current active processes. |
95 | | `.process [/p /r] OR [AddressOfEPROCESS]` | Set the current process context. |
96 | | `break` | Breakpoint. |
97 | | `db [VirtualAddress/Symbol] [EndAddress/L]` | Display bytes at address. |
98 | | `g` | Continue from breakpoint. |
99 | | `lm` | List current modules. |
100 | | `n [10 OR 16]` | Set radix. 16 by default. |
101 | | `q` | Quit. |
102 | | `r OR r [Register names]` | Display registers. |
103 | | `reload_lua` | Reload lua scripts. |
104 | | `u [VirtualAddress/Symbol] [EndAddress/L]` | Display disassembly at address. |
105 | | `uf [VirtualAddress/Symbol] [EndAddress/L]` | Alias for `u` command. |
106 | | `x [Module!Function]` | Display symbols matching the string. Accepts wildcard. |
107 | | `~ OR ~ [ProcessorNumber]` | Display current processor number or set current processor. |
108 | | `:[CallbackName] ` | Call to Lua callback. |
109 |
110 | ## C API
111 |
112 | For plugins to be visible to `ntoseye`, they need to be stored in `$XDG_CONFIG_HOME/ntoseye/plugins/`. This folder is created automatically when you run `ntoseye` for the first time.
113 |
114 | For functionality, look at examples in `examples/` or the public header `include/ntoseye/ntoseye.h`.
115 |
116 | ## Credits
117 |
118 | Functionality regarding initialization of guest information was written with the help of the following sources:
119 |
120 | - [vmread](https://github.com/h33p/vmread)
121 | - [pcileech](https://github.com/ufrisk/pcileech)
122 |
--------------------------------------------------------------------------------
/examples/base_addr.c:
--------------------------------------------------------------------------------
1 | #include "../include/ntoseye/ntoseye.h"
2 | #include
3 |
4 | int print(int argc, char **argv)
5 | {
6 | NTProcess process = NT_GetCurrentProcess();
7 |
8 | printf("%lx\n", NT_ProcessGetBaseAddress(process));
9 |
10 | return NTOSEYE_COMMAND_SUCCESS;
11 | }
12 |
13 | __attribute__((constructor))
14 | void plugin_init()
15 | {
16 | NT_RegisterCallback(print, "print_base_addr");
17 | }
18 |
--------------------------------------------------------------------------------
/include/ntoseye/ntoseye.h:
--------------------------------------------------------------------------------
1 | #ifndef _NTOSEYE_H_
2 | #define _NTOSEYE_H_
3 |
4 | #include
5 |
6 | /*
7 | * to-do: these should be in a common file
8 | */
9 | #define NTOSEYE_COMMAND_SUCCESS 0
10 | #define NTOSEYE_COMMAND_INVALID_SYNTAX 1
11 | #define NTOSEYE_COMMAND_INVALID_ARGUMENT 2
12 | #define NTOSEYE_COMMAND_UNIMPLEMENTED 3
13 |
14 | typedef void *NTProcess;
15 | typedef int(*NTCallbackProc)(int argc, char **argv);
16 |
17 | #ifdef __cplusplus
18 | #define EXTERN extern "C"
19 | #else
20 | #define EXTERN extern
21 | #endif
22 |
23 | EXTERN NTProcess NT_GetCurrentProcess();
24 |
25 | EXTERN int NT_RegisterCallback(NTCallbackProc proc, char *name);
26 |
27 | EXTERN uint64_t NT_ProcessGetBaseAddress(NTProcess process);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/media/ntoseye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaivel/ntoseye/13bf0f9d400f1ae3ce346d718eba40ae7e37bc88/media/ntoseye.png
--------------------------------------------------------------------------------
/ntoseye/capi.cpp:
--------------------------------------------------------------------------------
1 | #include "capi.hpp"
2 | #include "cmd.hpp"
3 | #include "config.hpp"
4 | #include "mem.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 | #include