Commit graph

431 commits

Author SHA1 Message Date
rainmurk
d5f56e5fa0 Fix local SDK breakpoint PID resolution and reject zero CR3 2026-10-18 10:35:16 +08:00
sina
c3346c1853 show version in the help command
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-10-07 15:44:39 +02:00
Max Raulea
c561fd8c8a evaluate expressions in address arguments on 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
2026-10-04 21:46:13 +02:00
Max Raulea
cccd36c33b accept device and socket paths in .debug on Linux 2026-10-04 21:46:13 +02:00
Max Raulea
afcc9c8441 connect the kernel debugger over serial on Linux 2026-10-04 21:46:13 +02:00
sina
29398bd9cf update CHANGELOG and minor CPUID SDK fucntion fix 2026-10-04 21:46:13 +02:00
sina
1f175b1fd9 restore Linux directory listing and apply address check to kernel functions 2026-10-04 21:46:13 +02:00
sina
0c13e26835 Restore Linux change 2026-10-04 21:46:13 +02:00
Claude
b451e6c810 Locate files next to the executable on Linux
`SetupPathForFileName` is the "find a file beside my binary" helper: it is how
the driver path, the hwdbg test/script files, the exported
`hyperdbg_u_setup_path_for_filename` and (now) the PCI ID database are all
resolved. On Linux it was a stub that printed an error and returned FALSE, so
every one of those lookups failed. Implementing it also removes the blocker that
kept two neighbouring helpers stubbed, so all three are done here.

install-linux.cpp — SetupPathForFileName:

A call-for-call port of the Windows body. `readlink("/proc/self/exe")` is the
`GetModuleFileName(GetModuleHandle(NULL), ...)` counterpart, `strrchr(..., '/')`
replaces `strrchr(..., '\\')` to strip the program name, and `access(path, F_OK)`
replaces the `CreateFile(..., OPEN_EXISTING)` probe behind `CheckFileExists`.

Two things it does that the Windows version does not:

- BufferLength is honoured on every write. `readlink` truncates silently, so a
  result that fills the buffer is rejected instead of being handed back as a
  valid-looking path to the wrong file, and the directory + '/' + name + NUL
  total is checked before appending. install.cpp gets the second half of this
  from StringCbCat, but its GetModuleFileName truncation is unchecked.

- Windows-style separators in FileName are normalized to '/'. The names come
  from shared headers and are spelled the Windows way —
  HWDBG_TEST_READ_INSTANCE_INFO_PATH ("..\\..\\..\\..\\hwdbg\\...") and
  PCI_ID_DATABASE_PATH ("constants\\pci.ids"). Normalizing here keeps those
  constants shared and keeps the #ifdef out of every call site. Only the
  appended part is rewritten, so a backslash inside a real Linux directory name
  survives.

common.cpp — ListDirectory:

opendir/readdir with fnmatch for the wildcard, mirroring how FindFirstFileA
applies the pattern to the file name. No fnmatch flag is passed, so a leading
'.' is unremarkable and "." / ".." match a bare "*", as they do in the Win32
walk; a missing directory throws the same std::runtime_error as the
INVALID_HANDLE_VALUE branch. One deliberate difference: the result is sorted,
since readdir returns entries in file-system order and the caller (eval.cpp's
script-engine test harness) is easier to compare across runs when the order is
stable.

pci-id.cpp — GetVendorById:

The Linux branch now builds the database path with SetupPathForFileName and
calls the same GetVendorByIdStr as Windows. It had been left Windows-only
because wrapping just the two Win32 calls would have left strrchr looking for a
'\\' and silently resolving against the cwd; the normalization above removes
that objection. !pcitree and !pcicam resolve vendor and device names on Linux
whenever constants/pci.ids is deployed next to the binary.

Verified by extracting SetupPathForFileName and the Linux ListDirectory branch
into a standalone harness built with -fsanitize=address,undefined: 20 probes
covering the separator normalization, both CheckFileExists outcomes, the
exact-fit and one-byte-short buffer boundaries, a buffer too small for the
executable path itself, the NULL/zero-length arguments, and the four
ListDirectory cases (filtering, sorting, empty match, missing directory). All
pass with no sanitizer diagnostics. The three modified files were also compiled
with the project's own Linux CMake build. The Windows build is untouched: every
change is inside a non-Windows branch or in a file that is not in the Windows
project.

The ledger in hyperdbg/linux/PORTING_STATUS.md is updated accordingly;
GetConfigFilePath stays open, as it is the same walk behind a PWCHAR
out-parameter and remains blocked on the wide-char work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3C1DuhHtqK64eEkHjKCHM
2026-10-04 21:46:13 +02:00
Claude
578abcbeba Stop malformed command arguments from aborting the debugger
The remaining std::stoi() call sites in the user-mode helpers throw on
malformed and out-of-range input. None of the callers catch, and there is
no top-level handler, so a bad command argument terminates the process
instead of being rejected with an error message.

common/common.cpp:

- IsNumber() tested against the character set "[0123456789]", so the two
  square brackets were accepted as digits. It is used as the guard in
  front of stoi() by several callers, which turns the mistake into a
  crash: "[1]" passes validation and then throws std::invalid_argument.
  Removed the brackets from the set.

- ValidateIP() called stoi() on every octet. Together with the above,
  ".connect [1].2.3.4 50000" aborted the process; so did an octet long
  enough to overflow int, e.g. ".connect 99999999999.1.1.1". Replaced by
  a strtoul() range check, which saturates instead of throwing.

- CheckAddressCanonicality() compared with a strict "<" against the start
  of the higher-half canonical range, so the boundary address itself
  (0xFFFF800000000000 at a 48-bit VA width) was reported as user-mode.
  CheckAccessValidityAndSafety() would then probe a kernel address from
  user mode rather than refusing it.

- ListDirectory() called FindNextFileA() before consuming the match that
  FindFirstFileA() had already stored in FindData, so the first file of
  every listing was silently dropped. Turned into a do/while.

- isxdigit()/isdigit()/isspace() were handed a plain char; passing a
  negative value to the <ctype.h> functions is undefined behavior and
  trips the MSVC debug CRT on any input with a byte above 0x7f. Cast to
  UCHAR at the four call sites.

The same crash class at the call sites that use stoi() directly on user
input, all replaced with strtoul() so the existing range checks reject
the value instead of an exception escaping:

- connect.cpp (x2) and listen.cpp: TCP port validation.
- debug.cpp: serial baud rate.

Verified by extracting the affected functions from common.cpp and running
them under ASan/UBSan over a 316-probe corpus, before and after. The
baseline aborts with SIGABRT on three inputs; afterwards every probe
returns a defined result and exactly the seven intended lines differ.
The four modified files were also compiled with the project's own Linux
CMake build to confirm they build clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3C1DuhHtqK64eEkHjKCHM
2026-10-04 21:46:13 +02:00
sina
b7a05585c0 cleanup uout and interpreter commands
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-09-15 18:17:36 +02:00
sina
9e415a8ce5 change results of the io in and io out commands 2026-09-15 14:05:36 +02:00
sina
434a539868 change help messages of uin and uout commands 2026-09-15 13:59:46 +02:00
Sina Karvandi
019d85f7ee
Merge pull request #684 from FallinBinary/dev
Add dds, dqs and dps commands
2026-09-15 13:36:48 +02:00
FallinBinary
2031e665f8 Register dds, dps, dqs commands in the command table 2026-08-30 02:09:37 -07:00
FallinBinary
dfe1e53569 Update command help menu 2026-08-29 03:36:32 -07:00
FallinBinary
a52aa35986 Add dps command 2026-08-29 03:25:53 -07:00
FallinBinary
7193b95c86 Add dqs command 2026-08-29 03:19:00 -07:00
FallinBinary
7c0d9eaa1a Add dds command 2026-08-29 03:06:55 -07:00
Max Raulea
3faff1e1e2 kernel module compilation guide
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-08-26 18:02:47 +02:00
Sina Karvandi
fd8b9d8bc3
Merge pull request #676 from FallinBinary/dev
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
refactor dl, da and dw commands
2026-08-15 22:36:49 +02:00
FallinBinary
a78b0208e4 refactor dl, da and dw commands 2026-08-14 08:52:06 -07:00
Sina Karvandi
a79dd9f6cc
Merge pull request #675 from xmaple555/dev
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
update function parameter to the script engine
2026-08-14 17:16:52 +02:00
xmaple555
c40f57efa6 update function parameter to the script engine 2026-08-14 21:40:42 +08:00
Sina Karvandi
368f0302f4
Merge pull request #673 from HyperDbg/linux
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
Linux
2026-08-13 15:01:18 +02:00
xmaple555
d8e777cd39 update test script-semantic 2026-08-12 23:01:07 +08:00
Max Raulea
5d3f694942 Renamed asm-vmx-checks-gas-unix file
Renames .s to .S, this was needed because the fiel is otherwise deleted
by make clean
2026-08-11 10:33:23 +02:00
xmaple555
d53712638c revert hyperdbg-test 2026-08-11 00:23:02 +08:00
xmaple555
5fc25f10e5 add the test script-semantic CLI command 2026-08-10 23:47:40 +08:00
Sina Karvandi
80f224fa58
Merge pull request #671 from nikzad66/uin-uout-commands
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
Uin uout commands
2026-08-10 12:00:21 +02:00
sina
ffa170a964 add return for uin, uout, ucpuid exported functions 2026-08-09 21:13:11 +02:00
sina
3f0e70c575 move ucpuid, uin, and uout files 2026-08-09 20:52:41 +02:00
sina
c8a209d84b add different DW DA definition
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-08 16:38:16 +02:00
Sina Karvandi
b9efc41b9c
Merge pull request #666 from FallinBinary/dev
Add dw and da commands
2026-08-08 16:31:36 +02:00
Nikzad
2dfbf46e51 c/cpp files 2026-08-06 21:13:03 +03:30
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
Abolfazl
056559c0ac
Merge branch 'HyperDbg:dev' into dev 2026-08-01 21:03:50 -07:00
FallinBinary
92a8b5256b add da command 2026-08-01 21:01:47 -07: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
FallinBinary
1f50e5afe8 add dw command 2026-08-01 08:31:13 -07: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