Commit Graph

2561 Commits

Author SHA1 Message Date
66hh
c144f2f438 Adjust memory allocation method 2025-12-30 17:05:08 +08:00
66hh
536f2ce883 Adjust variable order 2025-12-29 00:54:31 +08:00
66hh
3cd461e2ab Add the debugger_hide attribute to emulator_thread 2025-12-29 00:52:59 +08:00
66hh
12e96c8921 Adjust memory allocation method 2025-12-29 00:31:49 +08:00
66hh
1c11921701 Add error handling to prevent the engine from throwing errors 2025-12-28 23:45:52 +08:00
66hh
478fb7b4dd Register NtWriteVirtualMemory 2025-12-28 20:52:43 +08:00
66hh
83d4cadf76 Modify memory API implementation 2025-12-28 20:48:26 +08:00
66hh
418c5abf49 Extract callback handling into a separate function 2025-12-28 19:51:45 +08:00
66hh
41b86f655b Replace write with try_write in the handle_query function 2025-12-28 19:44:02 +08:00
66hh
c3464dd5c3 Introduce try_read/try_write for emulator_object 2025-12-28 19:40:53 +08:00
66hh
f95081cb6e Introduce try_write_memory for the memory manager 2025-12-28 19:36:40 +08:00
66hh
020e7ca3f6 Fix the base address alignment issue 2025-12-28 19:14:42 +08:00
66hh
d83c602f19 Change data type to fix 32-bit build 2025-12-28 12:40:51 +08:00
66hh
2d24b4189d Fix VMP NtClose detection 2025-12-27 19:51:29 +08:00
66hh
95b17566a0 Add NtRaiseHardError error message logging 2025-12-27 17:17:24 +08:00
66hh
02298e2303 Fix illegal address write 2025-12-27 17:17:24 +08:00
66hh
55310c57ac Add additional path checks for NtOpenSection 2025-12-27 17:17:24 +08:00
66hh
98393c03d2 Add a check before the conversion path 2025-12-27 17:17:24 +08:00
66hh
ecc00216d6 Support ProcessInstrumentationCallback 2025-12-27 17:17:23 +08:00
Maurice Heumann
d3cb3f4995 Fix PEB32 (#639)
When emulating `WOW64` samples sometimes you can see a garbige like
this:

```
Executing syscall: NtQueryAttributesFile (0x3D) at 0x18009dd42 via 0x100037f1c (wow64.dll)
--> Querying file attributes: \??\C:\SH╠мхЯЦэР╜р░АC:\Windows\SYSTEM32\VCRUNTIME140.dll
```

This is because of incorrect `PEB32` creation that leads to damaging
several `UNICODE_STRING` fields in `ProcessParameters`.
This PR fixes that.
2025-12-25 12:29:07 +01:00
Maurice Heumann
8894f8dc4d Fix unicorn hooking (#637)
This PR fixes incorrect size when using `uc_hook_add`.

`uc_hook_add`'s memory range is inclusive on both sides. So we need to
adjust an ending address to keep correct size.

This is manifested, for example, when using gdb. If a breakpoint is set
on a 1-byte instruction, you won't be able to single-step the next
instruction because that instruction also triggers the breakpoint, which
the debugger doesn't expect.
2025-12-25 11:59:52 +01:00
ssvine
3686625fb1 Fix PEB32 2025-12-25 13:42:20 +03:00
ssvine
96851b20ed Fix unicorn hooking 2025-12-25 13:35:12 +03:00
Maurice Heumann
203eef19df Support extended variant of ProcessBasicInformation (#638)
This PR fixes getting `ProcessBasicInformation`.

When emulating a program that uses
[ProcessPrng](https://learn.microsoft.com/ru-ru/windows/win32/seccng/processprng)
function from `BCryptPrimitives.dll`, an error occurs:

```
Unimplemented syscall: NtCallbackReturn - 0x5 (raw: 0x8000005)
```

`BCryptPrimitives.dll` checks whether the running process is a [secure
process](https://learn.microsoft.com/en-us/windows/win32/procthread/isolated-user-mode--ium--processes).
If it is, then `iumbase.dll` is loaded. `iumbase.dll` depends on
`iumdll.dll` that's like an `ntdll.dll` for secure processes, and it has
its own subset of system calls with different syscall numbers. So,
`0x8000005` is not `NtCallbackReturn`, it is `IumCrypto`.

But why does `BCryptPrimitives.dll` get into trouble? It calls
`NtQueryInformationProcess` with class `ProcessBasicInformation` and
`ProcessInformationLength == 0x40`. It turned out that it is a special
case and it's even documented in the aforemantioned link, look for the
definition of the function `IsSecureProcess`.
2025-12-25 11:15:44 +01:00
ssvine
8438a1f456 Support extended variant of ProcessBasicInformation 2025-12-24 18:33:49 +03:00
Maurice Heumann
5488acadfc Update YouTube embed link to include language parameter 2025-12-24 15:14:04 +01:00
momo5502
e3efcb9186 Don't show related content 2025-12-24 10:53:36 +01:00
momo5502
1b06d440f2 Add video 2025-12-24 10:48:01 +01:00
momo5502
cc44894e33 Fix lock 2025-12-24 10:47:50 +01:00
momo5502
f0f223faaa Remove error 2025-12-24 08:58:15 +01:00
momo5502
b4406d9b41 Collect more DLLs 2025-12-23 12:45:44 +01:00
momo5502
6da563d1ca Collect imagehlp.dll 2025-12-23 12:32:57 +01:00
Maurice Heumann
bc175b4a88 Fixes for section mapping and registry (#635) 2025-12-23 11:50:54 +01:00
momo5502
5d84f86eaf Fix warnings 2025-12-23 11:31:51 +01:00
momo5502
35b7839ec8 Support section offsets 2025-12-23 10:50:07 +01:00
momo5502
db3a89a0da Support KeyCachedInformation 2025-12-23 09:31:10 +01:00
momo5502
b1f7efb8c1 Ignore partial disconnect in AFD driver 2025-12-22 16:14:12 +01:00
momo5502
5ebf2dfd81 Support skipping syscall logging 2025-12-22 16:13:58 +01:00
momo5502
66cfe980d7 Ignore ThreadPriorityBoost 2025-12-22 14:39:44 +01:00
momo5502
90343077da Fix ordinals 2025-12-22 14:02:15 +01:00
momo5502
169fcaa8a5 Add DLLs 2025-12-22 13:51:18 +01:00
Maurice Heumann
596af43c62 Revise warning on malware analysis and isolation
Updated warning about host isolation in Sogen and recommended using the web version for added safety.
2025-12-22 08:03:09 +01:00
Maurice Heumann
0a74ef584f Update README with sandbox execution warning
Added a warning about sandbox execution limitations.
2025-12-22 07:55:55 +01:00
Maurice Heumann
1708212af9 Translate file paths before usage in section.cpp (#634)
Emulated applications are currently able to access files from the host
system, rather than being restricted to the virtualized file system, by
using `Section` related Syscalls. This behavior appears to have been
introduced in:

- 2024-12-13: [Prepare better section support
(syscalls.cpp:582)](719a50444e (diff-96c7de348bdc06e650bdc371a600a91f80594d4201afd7a28ffa160fa755be9dR582))
- 2025-10-13: [Comprehensive WOW64 subsystem implementation
(section.cpp:141)](65eecf1cfd (diff-415eed3b4b314dc10cc9f7926687770be53799766bc9a4edca2a7f4a45477169R141)))

Because the emulator is [advertised for malware
analysis](https://github.com/momo5502/sogen/blob/main/README.md), this
unintended access path could be considered a security concern.

This PR only fixes two current misuses of an API that interacts with the
host system. As a long term solution, APIs that interact with host
resources should consistently use C++ types that enforce translation of
resource identifiers (e.g., file and registry paths) into their emulated
equivalents. This would help prevent future misuse and ensure that
emulated applications remain isolated from the host environment.
2025-12-22 07:51:10 +01:00
momo5502
69ddd7a93b Small fixes 2025-12-22 07:42:34 +01:00
momo5502
cfebd2f35f Fix WinVerifyTrust 2025-12-21 20:37:42 +01:00
Maurice Kayser
db7548d130 Translate paths before usage in section.cpp 2025-12-21 00:00:00 +00:00
momo5502
ca15abd8ef Add missing syscalls 2025-12-07 11:22:37 +01:00
momo5502
568ca68481 Ignore ProcessPriorityClass 2025-12-06 11:12:19 +01:00
Maurice Heumann
28f3fa0aa0 Fix deserialization of optional WOW64 emulator_object members (#633)
Adds default constructor to `emulator_object` for optional member
deserialization.
Restores `memory_interface` pointer for WOW64 structures after
deserialization.
2025-12-06 08:24:38 +01:00