ntmemoryapi 2.1.2__tar.gz → 2.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/PKG-INFO +2 -2
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/pyproject.toml +2 -2
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/src/ntmemoryapi/__init__.py +4 -4
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/src/ntmemoryapi/errors.py +32 -21
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/src/ntmemoryapi/misc.py +1 -1
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/README.md +0 -0
- {ntmemoryapi-2.1.2 → ntmemoryapi-2.1.5}/src/ntmemoryapi/embed.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: ntmemoryapi
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary: Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps
|
|
3
|
+
Version: 2.1.5
|
|
4
|
+
Summary: Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps.
|
|
5
5
|
Author: Xenely
|
|
6
6
|
Requires-Dist: psutil>=7.1.3
|
|
7
7
|
Requires-Python: >=3.10
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ntmemoryapi"
|
|
3
|
-
version = "2.1.
|
|
4
|
-
description = "Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps"
|
|
3
|
+
version = "2.1.5"
|
|
4
|
+
description = "Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Xenely"}
|
|
7
7
|
]
|
|
@@ -120,7 +120,7 @@ class MODULEENTRY32(ctypes.Structure):
|
|
|
120
120
|
def base(self) -> int:
|
|
121
121
|
"""Process module base address."""
|
|
122
122
|
|
|
123
|
-
return self.mod_base_addr
|
|
123
|
+
return self.mod_base_addr
|
|
124
124
|
|
|
125
125
|
@property
|
|
126
126
|
def size(self) -> int:
|
|
@@ -147,13 +147,13 @@ class MEMORY_BASIC_INFORMATION(ctypes.Structure):
|
|
|
147
147
|
def base_address(self) -> int:
|
|
148
148
|
"""Memory region base address."""
|
|
149
149
|
|
|
150
|
-
return self.m_base_address
|
|
150
|
+
return self.m_base_address
|
|
151
151
|
|
|
152
152
|
@property
|
|
153
153
|
def allocation_base(self) -> int:
|
|
154
154
|
"""Memory region allocation base."""
|
|
155
155
|
|
|
156
|
-
return self.m_allocation_base
|
|
156
|
+
return self.m_allocation_base
|
|
157
157
|
|
|
158
158
|
@property
|
|
159
159
|
def allocation_protect(self) -> int:
|
|
@@ -200,7 +200,7 @@ class PatternScanBuffer(ctypes.Structure):
|
|
|
200
200
|
("size", ctypes.c_size_t),
|
|
201
201
|
]
|
|
202
202
|
|
|
203
|
-
def read(self) -> list:
|
|
203
|
+
def read(self) -> list[int]:
|
|
204
204
|
"""Read all of the values located at buffer array."""
|
|
205
205
|
|
|
206
206
|
return list((ctypes.c_size_t * self.size).from_address(self.pointer))
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
# | Discord: xenely |
|
|
6
6
|
# +-------------------------------------+
|
|
7
7
|
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
# ==-------------------------------------------------------------------== #
|
|
9
|
-
#
|
|
12
|
+
# Base errors classes #
|
|
10
13
|
# ==-------------------------------------------------------------------== #
|
|
11
14
|
class NtError(Exception):
|
|
12
15
|
"""Exception that raises on `nt` functions calls fails."""
|
|
@@ -40,6 +43,30 @@ class NtError(Exception):
|
|
|
40
43
|
return "%s%08x" % (hex_prefix if hex_prefix is not None else "", self.status)
|
|
41
44
|
|
|
42
45
|
|
|
46
|
+
class MemoryError(NtError):
|
|
47
|
+
"""Exception that raises on virtual memory read fail."""
|
|
48
|
+
|
|
49
|
+
# ==--------------------------------== #
|
|
50
|
+
# Public methods #
|
|
51
|
+
# ==--------------------------------== #
|
|
52
|
+
def __init__(self, status: int, address: int, operation: typing.Literal["read", "write"]):
|
|
53
|
+
|
|
54
|
+
# Save initializer arguments as an attributes
|
|
55
|
+
self.address = address
|
|
56
|
+
self.operation = operation
|
|
57
|
+
|
|
58
|
+
# Call initializer of parrent class
|
|
59
|
+
super().__init__(None, status)
|
|
60
|
+
|
|
61
|
+
def __str__(self) -> str:
|
|
62
|
+
"""Overload triggered on `str` cast calls"""
|
|
63
|
+
|
|
64
|
+
return "Unalble to %s memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.operation, self.address, self.get_hex_status())
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ==-------------------------------------------------------------------== #
|
|
68
|
+
# Errors classes #
|
|
69
|
+
# ==-------------------------------------------------------------------== #
|
|
43
70
|
class OpenProcessError(NtError):
|
|
44
71
|
"""Exception that raises on process open fail."""
|
|
45
72
|
|
|
@@ -63,7 +90,7 @@ class OpenProcessError(NtError):
|
|
|
63
90
|
return "Unable to open process: %s" % self.message
|
|
64
91
|
|
|
65
92
|
|
|
66
|
-
class MemoryReadError(
|
|
93
|
+
class MemoryReadError(MemoryError):
|
|
67
94
|
"""Exception that raises on virtual memory read fail."""
|
|
68
95
|
|
|
69
96
|
# ==--------------------------------== #
|
|
@@ -71,19 +98,11 @@ class MemoryReadError(NtError):
|
|
|
71
98
|
# ==--------------------------------== #
|
|
72
99
|
def __init__(self, status: int, address: int):
|
|
73
100
|
|
|
74
|
-
# Save initializer arguments as an attributes
|
|
75
|
-
self.address = address
|
|
76
|
-
|
|
77
101
|
# Call initializer of parrent class
|
|
78
|
-
super().__init__(
|
|
79
|
-
|
|
80
|
-
def __str__(self) -> str:
|
|
81
|
-
"""Overload triggered on `str` cast calls"""
|
|
102
|
+
super().__init__(status, address, "read")
|
|
82
103
|
|
|
83
|
-
return "Unalble to read memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.address, self.get_hex_status())
|
|
84
104
|
|
|
85
|
-
|
|
86
|
-
class MemoryWriteError(NtError):
|
|
105
|
+
class MemoryWriteError(MemoryError):
|
|
87
106
|
"""Exception that raises on virtual memory read fail."""
|
|
88
107
|
|
|
89
108
|
# ==--------------------------------== #
|
|
@@ -91,13 +110,5 @@ class MemoryWriteError(NtError):
|
|
|
91
110
|
# ==--------------------------------== #
|
|
92
111
|
def __init__(self, status: int, address: int):
|
|
93
112
|
|
|
94
|
-
# Save initializer arguments as an attributes
|
|
95
|
-
self.address = address
|
|
96
|
-
|
|
97
113
|
# Call initializer of parrent class
|
|
98
|
-
super().__init__(
|
|
99
|
-
|
|
100
|
-
def __str__(self) -> str:
|
|
101
|
-
"""Overload triggered on `str` cast calls"""
|
|
102
|
-
|
|
103
|
-
return "Unalble to write memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.address, self.get_hex_status())
|
|
114
|
+
super().__init__(status, address, "write")
|
|
@@ -110,7 +110,7 @@ class DirectSyscallWrapper:
|
|
|
110
110
|
B8 %s %s 00 00
|
|
111
111
|
0F 05
|
|
112
112
|
C3
|
|
113
|
-
""" % tuple(
|
|
113
|
+
""" % tuple(syscall_id_bytes))
|
|
114
114
|
|
|
115
115
|
# Allocate buffer for function machine code
|
|
116
116
|
if not (shellcode_buffer := _VirtualAlloc(0, len(shellcode), 0x1000 | 0x2000, 0x04)):
|
|
File without changes
|
|
File without changes
|