Commit graph

393 commits

Author SHA1 Message Date
sina
ffbfc0416a Revert NewTemp modifications and adjust error messages
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-08-02 11:01:19 +02:00
Sina Karvandi
625e75719e
Merge branch 'dev' into claude/code-audit-improvements-prdq23 2026-08-02 10:50:02 +02:00
sina
a24c8c0a91 cleanup for resync serial codes and update CHANGELOG.md
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-08-01 20:49:02 +02:00
Claude
1abdde7702
Fix memory-safety and robustness issues in script engine and PCI ID parser
Code audit of the script engine's scanner/token handling and of the PCI ID
database parser. Each of the issues below was reproduced against the current
code before the fix and re-checked afterwards.

script-engine/scanner.c

  * An unterminated string literal ("abc or L"abc) hung the scanner in an
    endless loop: sgetc() returns EOF without consuming input, and neither
    string loop tested for it, so the token grew until allocation failed.
    Both loops now stop at EOF and report the token as UNKNOWN.

script-engine/common.c

  * AppendByte()/AppendWchar() doubled Token->MaxLen before checking whether
    the larger buffer was actually allocated. After a failed allocation MaxLen
    described memory that did not exist and the next append wrote past the end
    of the old buffer. MaxLen is now committed only on success.

  * CopyToken() allocated strlen(Value) + 1 bytes but carried over the source
    token's Len and MaxLen, so the copy's advertised capacity did not match its
    allocation, and WSTRING payloads were truncated at their first embedded
    null byte. The copy is now sized from Len/MaxLen and copied by length, with
    a fallback to the string length for the grammar tokens in parse-table.c,
    which only initialize Type and Value.

  * NewToken() set MaxLen to the value length, which is zero for an empty
    value. The 'Len >= MaxLen - 1' test in the append routines is unsigned, so
    a zero MaxLen wrapped and disabled buffer growth entirely.

  * IsUnderscore() tested 'c >= '_'', which also accepted the backtick, the
    lowercase letters, '{', '|', '}', '~' and DEL. Register scanning uses it,
    so '@rax|1' was lexed as one malformed register name instead of a register,
    an operator and a number. The pseudo-register path already compared against
    '_' directly.

  * NewTokenList() did not check the allocation of its Head buffer.

  * NewTemp() kept the last handed-out id in a static, so an exhausted temp
    list produced a token aliasing a temporary still in use, and it derived
    MaxTempNumber from an out-of-range index. It also dereferenced the new
    token without a null check.

  * FreeTemp() indexed the MAX_TEMP_COUNT-entry map with an unchecked value
    parsed out of the token text.

  * RotateLeftStringOnce() wrote to str[-1] when handed an empty string.

libhyperdbg/debugger/misc/pci-id.cpp

  * The database file was read into a malloc(Length) buffer that was never
    null-terminated, while ReadLine() walks it with strchr(). Looking up an
    absent vendor scans to the end and reads past the allocation.

  * The matched Vendor was allocated with malloc() and its Devices list head
    was only assigned once a device line was parsed, so a vendor with no
    device entries left it uninitialized and FreeVendor() walked a garbage
    pointer.

  * FreeVendor() released the device and subdevice lists but never the Vendor
    itself, leaking one per lookup for every enumerated PCI device.

  * The file handle leaked when the buffer allocation failed, ftell() and
    fread() results were unused, and several error paths leaked the Vendor or
    the not-yet-linked Device/SubDevice.

  * strncmp() compared sizeof(VendorId) bytes, which is the size of the
    pointer rather than the length of a vendor id.

  * ReadLine() passed an unclamped count to strncpy_s(), which triggers the
    invalid parameter handler for a line longer than the destination.

  * GetVendorById() ignored the GetModuleFileName() result and overwrote the
    tail of the path buffer without checking the room left in it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3C1DuhHtqK64eEkHjKCHM
2026-08-01 14:22:52 +00:00
munraimix
b2b98033ef Resync libhyperdbg's serial receivers on framing overflow too
The debuggee-side hyperkd fix stops the driver flooding, but the same
delimiter-only framing with a blind retry loop also lives in the
user-mode receivers. Mirror the resync there so an unclean disconnect
does not flood the console either: KdReceivePacketFromDebuggee,
KdReceivePacketFromDebugger, and the ListeningSerialPortInDebuggee loop.
On overflow with no end-of-buffer marker, warn once per episode and
discard to the next frame boundary (bounded by SERIAL_RESYNC_MAX_BYTES)
instead of returning into the still-desynced stream.

Refs #661
2026-07-27 22:40:06 +10:00
Max Raulea
1a9a62a916 Forgot to add the new linux stubs to tracked files, so here it is 2026-07-24 22:10:08 +02:00
Max Raulea
f938929a8c Empty Linux stub for the keystone library 2026-07-24 21:20:44 +02:00
Max Raulea
600eaa47ba update doc and added stub for vendorID pci-id.cpp file, TODO on linux 2026-07-24 21:11:23 +02:00
Max Raulea
4bf987a596 Added missing files to the CMake build file and sweeped them for the Platform functions and guarded windows only code 2026-07-24 21:06:04 +02:00
Max Raulea
7ea5eb6f2b gcc enum init fix {0} -> {} 2026-07-24 19:36:31 +02:00
Max Raulea
f5f822a46f Added the hwdbg files to the cmake files and replaced the platform files, RTLzeroMemory 2026-07-24 19:21:06 +02:00
Max Raulea
7141e23aad Added unix implementation of asm-vmx-checks.asm, and made naming convention for both files. Updated the Porting status and updated the build files.
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-24 18:27:26 +02:00
Sina Karvandi
8e1288949b
Merge pull request #657 from HyperDbg/linux
Linux
2026-07-23 15:44:56 +02:00
sina
7911465b93 cleanup ucpuid command codes 2026-07-23 10:03:35 +02:00
Nikzad
b1b9680ce6 cpuid: some changes for improvement 2026-07-22 21:21:17 +03:30
Max Raulea
f1a923406c new linux guards
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-07-22 11:46:23 +02:00
Max Raulea
6683c2dc3d New socket platform API and named-pipe linux file 2026-07-22 11:32:39 +02:00
Max Raulea
1abac35edc new email and some changes 2026-07-22 11:05:07 +02:00
Max Raulea
6f7bc287fe Guards and Documentation 2026-07-22 10:16:22 +02:00
Max Raulea
5fdd2e7738 rdmsr file and updates status 2026-07-22 10:02:29 +02:00
sina
d4132ee7db fix UInt32 convesion for negative (signed) values 2026-07-21 16:57:26 +02:00
Max Raulea
a4da625e05 fix build
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-21 15:57:23 +02:00
Max Raulea
926070135d Sweeps and extra guards and some new platform functionsd 2026-07-21 15:53:34 +02:00
sina
39c4b2f127 update and cleanup CPUID 2026-07-21 15:12:04 +02:00
Sina Karvandi
6324c1d718
Merge pull request #650 from nikzad66/feature-cpuid-command
Feature cpuid command
2026-07-21 14:28:37 +02:00
Sina Karvandi
fe9a6f39e4
Merge pull request #654 from HyperDbg/linux
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
Linux
2026-07-21 14:05:03 +02:00
xmaple555
d44c726dff update variable type and add float type in script enginr 2026-07-20 23:21:34 +08:00
Max Raulea
a29e210ab0 Porting status update and terminate thread platform call
Some checks are pending
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-20 12:32:10 +02:00
Max Raulea
bb059c724a Big Sweep of 1:1 platform function changes 2026-07-20 12:27:14 +02:00
Max Raulea
218ade8f24 1:1 platform swaps 2026-07-20 12:15:34 +02:00
Max Raulea
c13f45f8b0 CpuIdEx replacements 2026-07-20 12:12:21 +02:00
xmaple555
ec5fe7cc8a add float in script engine 2026-07-20 15:03:45 +08:00
Sina Karvandi
8db1b75b4f
Merge pull request #649 from xmaple555/mydev
Some checks are pending
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
Add struct in script engine
2026-07-19 22:34:41 +02:00
Nikzad
632db21290 user: implement ucpuid command in user mode- Add ucpuid.cpp with leaf/sub-leaf decoding
- Implement CPUID command parser and dispatcher
- Add remote CPUID support via KdSendUserCpuidPacketToDebuggee()
- Implement response handler in kernel-listening.cpp
- Add proper validation for FunctionId and SubFunctionId
- Support hex and decimal input formats
2026-07-19 18:15:43 +03:30
Max Raulea
860f736bd2 Added guards and compilation flag in cmake 2026-07-19 11:11:09 +02:00
Max Raulea
dd38a30d22 New Platform functions and maybe missed CpuID wrapper function? 2026-07-19 11:05:12 +02:00
xmaple555
8b6d8181a5 add struct in script engine 2026-07-19 09:39:37 +08:00
Max Raulea
dde0429355 fix windows build
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-07-18 19:32:49 +02:00
Max Raulea
0c7adbd244 New platform ioctl func and some sweeps of already existing platform functions 2026-07-18 19:20:56 +02:00
Max Raulea
db3064cb24 Sweeps of PLatform functions 2026-07-18 17:09:52 +02:00
Max Raulea
d6f70eecd9 Added driver install for linux stub, and new platform functions and 1:1 mappings 2026-07-18 16:38:09 +02:00
Max Raulea
3805190db8 ud.cpp, new additions to platform API and guards
Some checks are pending
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-18 15:01:56 +02:00
Max Raulea
1e19826b6c Linux PE-parser variant, gets distinguished in cmake so windows build is untouched. PE-parsing left for future work in linux build. 2026-07-18 11:57:09 +02:00
Max Raulea
72e18d7ad1 1:1 conversion and stubbed w_char issue, to be fixed later 2026-07-18 11:28:08 +02:00
Max Raulea
38a59b795f Some new lib calls and reverted sleep macro to function
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-17 17:54:05 +02:00
Sina Karvandi
b48c535e11
Merge pull request #641 from HyperDbg/linux
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
compiling kd.cpp on linux
2026-07-16 21:10:35 +02:00
Max Raulea
2a2425dc68 compiling kd.cpp on linux
Some checks failed
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-07-16 15:00:03 +02:00
sina
01b6f1ca32 fix double enable error and create a new window for suspended process
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-07-12 18:46:33 +02:00
sina
07630fc05a add PT initialization to a separate thread 2026-07-12 15:16:29 +02:00
sina
00c81606fa add pname to PT 2026-07-12 13:54:47 +02:00