• 01 June 2024 (1 messages)
  • @ma_jiajue #6414 04:33 PM, 01 Jun 2024
    OK,thank you
  • 03 June 2024 (3 messages)
  • @dr_r00t3r #6416 11:49 AM, 03 Jun 2024
    Joined.
  • @mumeda #6417 02:05 PM, 03 Jun 2024
    Joined.
  • @Saedarshi #6418 03:25 PM, 03 Jun 2024
    Joined.
  • 04 June 2024 (75 messages)
  • @HeisAliM #6419 09:30 AM, 04 Jun 2024
    Joined.
  • @HughEverett #6420 12:57 PM, 04 Jun 2024
    Guys,
    Has anyone previously seen any sample of setting up a TSS (Task State Segment) for a hypervisor?

    https://github.com/HyperDbg/HyperDbg/blob/834b43ece965c75bd65761386384a539bd1a3973/hyperdbg/hprdbghv/code/memory/Segmentation.c#L123C5-L123C6
  • Been working on setting a separate TSS (instead of Windows TSS) for HyperDbg, but not sure if I correctly implemented it since the interrupt stack is not within the range. 🤔
  • It still perfectly works but if we're unsure about the correctness of the implementation, it probably causes weird problems in the future.
  • @HughEverett #6423 01:01 PM, 04 Jun 2024
    (05:19:52.472 - core : 0 - vmx-root? no) [+] Information (SegmentPrepareHostGdt:123) | Host Interrupt Stack, from: ffffe58189199000, to: ffffe5818919cff0
    (05:19:52.472 - core : 1 - vmx-root? no) [+] Information (SegmentPrepareHostGdt:123) | Host Interrupt Stack, from: ffffe581891ab000, to: ffffe581891aeff0
    (05:19:52.472 - core : 3 - vmx-root? no) [+] Information (SegmentPrepareHostGdt:123) | Host Interrupt Stack, from: ffffe581891cf000, to: ffffe581891d2ff0
    (05:19:52.472 - core : 2 - vmx-root? no) [+] Information (SegmentPrepareHostGdt:123) | Host Interrupt Stack, from: ffffe581891bd000, to: ffffe581891c0ff0

    (05:24:27.278 - core : 0 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:177) | Host exception, RIP=fffff804383f5a8e, RSP=ffffe58189192ed0, Vector=3
    (05:24:27.333 - core : 1 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:177) | Host exception, RIP=fffff804383f5a8e, RSP=ffffe581891a4ed0, Vector=3
    (05:24:27.259 - core : 2 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:177) | Host exception, RIP=fffff804383f5a8e, RSP=ffffe581891b6ed0, Vector=3
    (05:24:27.278 - core : 3 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:177) | Host exception, RIP=fffff804383f5a8e, RSP=ffffe581891c8ed0, Vector=3
  • @honorary_bot do have any idea about this?
  • The problem here is that the exception stack is not within the core's allocated range.
  • @honorary_bot #6427 01:08 PM, 04 Jun 2024
    I don’t remember from top of my head, gonna have to recheck in the evening. So you’ve set up tss stack pointers, but the exception stack is switched to something different in exception?
  • Yes, exactly
  • @HughEverett #6429 01:09 PM, 04 Jun 2024
    As stack grows downward, probably I should put the latest (aligned byte address) of the stack. But it seems that Intel didn't mention it. So, not sure whether I should put the base address or the end of the stack.
  • @honorary_bot #6430 01:09 PM, 04 Jun 2024
    It’s likely just a misconfiguration, but I’ll check how I do that
  • @honorary_bot #6431 01:10 PM, 04 Jun 2024
    Do you index cores by apic id?
  • @HughEverett #6432 01:10 PM, 04 Jun 2024
    Still, the base address as the stack doesn't make sense since the processor doesn't have any idea about the end of the stack.
  • By KeGetCurrentProcessorNumberEx, not sure if it's based on APIC ID or not.
  • @honorary_bot #6434 01:13 PM, 04 Jun 2024
    Surely it's from prcb, so i'd need to check prcb init code, which is more than 2 minutes :\
  • But both VMCS HOST IDT exception handler and the code that I wrote use the same core number, so does it make any difference? 🤔
  • @honorary_bot #6436 01:18 PM, 04 Jun 2024
    You're right, just wanted to make sure
  • @honorary_bot #6437 01:23 PM, 04 Jun 2024
    Wait a sec, you were asking about TSS first, but then you're talking about IDT and exceptions
  • @honorary_bot #6438 01:24 PM, 04 Jun 2024
    Also, which exception are you testing?
  • Vector number 3 (#BP)
  • A breakpoint within VMX-root mode.
  • @honorary_bot #6441 01:26 PM, 04 Jun 2024
    PULSE_STATUS VmUtilAllocateStack(uint64_t aStackSize, uint64_t *aStackBase)
    {
    if (aStackBase == NULL)
    return PULSE_STATUS_INVALID_PARAMETER;

    if ((aStackSize < PAGE_4K_SIZE) || (aStackSize > g_vmm.LoaderParams.CoreRegionSize))
    return PULSE_STATUS_INVALID_PARAMETER;

    *aStackBase = PoolAllocPages(aStackSize / PAGE_4K_SIZE);
    if (*aStackBase == NULL)
    return PULSE_STATUS_INSUFFICIENT_RESOURCES;

    return PULSE_STATUS_SUCCESS;
    }

    PULSE_STATUS VmUtilAllocateInitStack(uint64_t aStackSize, uint64_t *aStackBase)
    {
    PULSE_STATUS status = PULSE_STATUS_SUCCESS;
    status = VmUtilAllocateStack(aStackSize, aStackBase);
    if (status != PULSE_STATUS_SUCCESS)
    return status;

    *aStackBase = *aStackBase + (aStackSize - 8);

    return PULSE_STATUS_SUCCESS;
    }
  • @honorary_bot #6442 01:26 PM, 04 Jun 2024
    If it helps
  • @honorary_bot #6443 01:27 PM, 04 Jun 2024
    pTss->Rsp0 = pHostCpu->Stack;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST1));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST2));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST3));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
  • Can you also share what you configured for HOST_GDT_BASE and how you configured other fields of pTss?
  • @honorary_bot #6445 01:31 PM, 04 Jun 2024
    Is it a VMCS field? Sorry, I did that in 2015, so I don't really remember :)
  • Just wanna re-check it with my configuration since I did the exact same config but it seems the stack RSP of exception is not within range for some other reasons.
  • No, just the value of HOST_GDTR_BASE
  • I only configured IoMapBaseAddress to 100 (which is incorrect btw, but it doesn't matter in my case) and pTss->Rsp0 = pHostCpu->Stack; which is also allocated by function above.
  • @HughEverett #6449 01:33 PM, 04 Jun 2024
    Since we previously use Windows GDT and IDT as Host GDT and IDT, right now I changed the implementation to configure our own GDT, IDT.
  • Yeah, but what structy is it in?
  • @honorary_bot #6451 01:34 PM, 04 Jun 2024
    or is it gdtr reg?
  • GDTR reg (for host) needs to have some entries (and the TSS should be here).
  • @HughEverett #6453 01:36 PM, 04 Jun 2024
    The TSS itself has other bits (in its entry on GDT, like LowSegmentLimit etc. ) I'm not sure if I correctly configured that.
  • Since basically I did the same in HyperDbg but still the stack is not within the expected range, I think it might be an issue with the actual TSS entry configuration in GDT.
  • @honorary_bot #6455 01:44 PM, 04 Jun 2024
    Let me step back a bit. It is still not clear to me what you're trying to achieve.
  • @honorary_bot #6456 01:44 PM, 04 Jun 2024
    Sp you set up a dedicated gdtr for vmx root mode, right?
  • Yes
  • @honorary_bot #6458 01:45 PM, 04 Jun 2024
    Then the OS runs in a vmx non root (guest) mode, right?
  • Yes
  • @honorary_bot #6460 01:45 PM, 04 Jun 2024
    So, you want to trap a breakpoint, but does it occur in vmx root on vmx non root mode?
  • And I wanted to build a dedicated gdt for Host.
  • It occurs in vmx root mode.
  • @honorary_bot #6463 01:47 PM, 04 Jun 2024
    You have also filled vmcs like this?
    if (__vmx_vmwrite(VMCE_HOST_GDTR_BASE, g_vmm.pCpu[CpuSlot].HostCpu.DescTables) != 0)
    return PULSE_STATUS_VMWRITE_FAILED;
    if (__vmx_vmwrite(VMCE_HOST_IDTR_BASE, g_vmm.pCpu[CpuSlot].HostCpu.InterruptDesc) != 0)
    return PULSE_STATUS_VMWRITE_FAILED;
    if (__vmx_vmwrite(VMCE_HOST_TSS_BASE, g_vmm.pCpu[CpuSlot].HostCpu.Tss) != 0)
    return PULSE_STATUS_VMWRITE_FAILED;
  • @HughEverett #6464 01:47 PM, 04 Jun 2024
    Since we configured TSS stack for IST3, the breakpoint should be handled with host ID (the one dedicated to HyperDbg) but the rsp of the arrived breakpoint is not within the expected range.
  • @honorary_bot #6465 01:48 PM, 04 Jun 2024
    Is your root mode operating in Rind0 mode?
  • Ignore the structs, the just should be some address
  • Yes exactly. And what I need is how you filled/configureed g_vmm.pCpu[CpuSlot].HostCpu.Tss and g_vmm.pCpu[CpuSlot].HostCpu.DescTable.
  • ?
  • // Task entries
    uint64_t tssAddr = &(pIdtEntry[256]);
    PCPU_TSS_DESCRIPTOR64 pTssEntry = (PCPU_TSS_DESCRIPTOR64)(&(pGdtEntry[VMM_HOST_TASK_SEG_DESC_NUM]));
    pTssEntry->P = 1;
    pTssEntry->S = 0;
    pTssEntry->Type = SYS_SEG_TYPE_AVAIL_TSS64;
    pTssEntry->LimitLow = sizeof(CPU_TSS64);
    pTssEntry->LimitHigh = 0;
    pTssEntry->BaseLow = tssAddr & 0xFFFF;
    pTssEntry->BaseMid = (tssAddr >> 16) & 0xFF;
    pTssEntry->BaseHigh = (tssAddr >> 24) & 0xFF;
    pTssEntry->BaseAddrHigh64 = (tssAddr >> 32) & 0xFFFFFFFF;
    pTssEntry->AVL = 0;
    pTssEntry->G = 0;
    pTssEntry->DPL = 0;
    pTssEntry->DB = 0;
    pTssEntry->L = 0;

    // TSS
    pHostCpu->Tss = tssAddr;
    PCPU_TSS64 pTss = (PCPU_TSS64)(tssAddr);
    pTss->IoMapBaseAddress = 100; // 104 ?
    pTss->Rsp0 = pHostCpu->Stack;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST1));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST2));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
    status = VmUtilAllocateInitStack(0x1000, &(pTss->IST3));
    if (status != PULSE_STATUS_SUCCESS)
    return status;
  • Rind0 mode?
  • @honorary_bot #6471 01:53 PM, 04 Jun 2024
    ring 0
  • Yes, but curious to know, could run in any different modes? 🤨
  • Well that's why it's working like that
  • @honorary_bot #6474 01:54 PM, 04 Jun 2024
    You have no ring transition
  • @honorary_bot #6475 01:54 PM, 04 Jun 2024
    You're already in ring 0
  • @honorary_bot #6476 01:54 PM, 04 Jun 2024
    So no stack switch for you
  • Of course you could run VMX root ring 3
  • But it's a breakpoint (so shouldn't it use Tss.IST3?)
  • Didn't knew that 😳
  • Like a user-mode application running in VMX root mode?
  • @honorary_bot #6481 01:56 PM, 04 Jun 2024
    From top of my head - only NMIs, double faults and smth else would have a separate stack
  • @honorary_bot #6482 01:57 PM, 04 Jun 2024
    Don't really remember about int3, but it makes sense not to switch the stack for it
  • You can create an operating system running in VMX root, right? It would have both kernel and user mode
  • Ah, if it's the way you say, then that's why the stack is not within the range.
  • @honorary_bot #6485 01:58 PM, 04 Jun 2024
    yes, it just uses your current rsp
  • So, basically the implementation is correct.
  • @honorary_bot #6487 01:59 PM, 04 Jun 2024
    So stack switch is for NMI, DebugOrTrap (int1 though, not 3), double fault, machine check
  • @honorary_bot #6488 01:59 PM, 04 Jun 2024
    It makes sense to swap stack for int1, because you can trap task switcch with debug registers
  • @honorary_bot #6489 01:59 PM, 04 Jun 2024
    but int3 is just a code breakpoint
  • @HughEverett #6490 02:00 PM, 04 Jun 2024
    Makes sense.
  • Anyway, thank you for always being helpful. You saved me a lot of time for this.
  • @honorary_bot #6492 02:02 PM, 04 Jun 2024
    No problem!
  • @honorary_bot #6493 02:02 PM, 04 Jun 2024
  • 05 June 2024 (2 messages)
  • @HughEverett #6494 05:24 PM, 05 Jun 2024
    Hello everyone,

    I've made a somehow big update in the HyperDbg. Now, it utilizes a dedicated HOST IDT and HOST GDT, different than the Windows IDT/GDT. This update will address a specific category of bypasses for HyperDbg, although there are still many bypasses to address. This change influences the handling of interrupts, especially NMIs for halting cores in VMX root-mode. lt may introduce instability issues in various systems, potentially leading to crashes. If you're using HyperDbg, please switch to the 'dev' branch and re-build and test it to help us identify any problems. Currently, it works well on my 12th Gen machine, but I'm uncertain if it's universally stable. If you encounter any crashes or BSODs, please notify me before the release of v0.9 (the next version). The best way to test it is using events (EPT hooks) with a high rate of execution (e.g., using !epthook on nt!ExAllocatePoolWithTag and meanwhile pause the debuggee).

    The 'dev' branch:
    https://github.com/HyperDbg/HyperDbg/tree/dev

    GitHub built artifact for those who can't build:
    https://github.com/HyperDbg/HyperDbg/actions/runs/9384856535
    GitHub - HyperDbg/HyperDbg at dev

    State-of-the-art native debugging tool. Contribute to HyperDbg/HyperDbg development by creating an account on GitHub.

  • None
  • 06 June 2024 (3 messages)
  • @6206881392 #6496 07:49 AM, 06 Jun 2024
    Joined.
  • @HughEverett #6497 09:11 AM, 06 Jun 2024
    One more thing to mention, if you guys encounter "invalid address error", this new instruction is for fixing it:

    https://docs.hyperdbg.org/tips-and-tricks/considerations/accessing-invalid-address
    Accessing Invalid Address | HyperDbg Documentation

    Considerations for accessing memory in different modes

  • The primary difference is that previously (before v0.9), the '.pagein' command doesn't guarantee locking all the cores and immediately after the '.pagein' command, you couldn't apply any events (e.g., !epthook or !monitor) but since HyperDbg uses a dedicated Host IDT at its newest version, it is guaranteed to lock all the cores after running the '.pagein' command. Hence, you shouldn't have any problem applying events after forcing OS to bring the pages into the page-table or make them present in the current process's memory.
  • 08 June 2024 (3 messages)
  • @katana98 #6499 01:25 AM, 08 Jun 2024
    Joined.
  • @HughEverett #6500 09:30 AM, 08 Jun 2024
    Hi guys!

    As a new feature, starting from v0.9 HyperDbg will support monitoring EPT hooks on physical addresses (previously it only supported virtual addresses), mainly through the 'MemoryType' parameter. You can now use it from the 'dev' branch.

    https://docs.hyperdbg.org/commands/extension-commands/monitor
  • This is mainly useful for those who want to monitor PCIe buffers.
  • 09 June 2024 (5 messages)
  • @shonkerc #6502 09:52 AM, 09 Jun 2024
    Joined.
  • @HughEverett #6503 11:16 AM, 09 Jun 2024
    HyperDbg v0.9 is released! ✨

    It features monitoring physical addresses for tracking read/write to PCI-e and IOMMU buffers. Plus, HyperDbg now uses a dedicated Host IDT/GDT.

    🔗 Check it out: https://github.com/HyperDbg/HyperDbg/releases/tag/v0.9.0

    📖 Read more:
    https://docs.hyperdbg.org/commands/extension-commands/monitor

    # Added
    - The !monitor command now physical address hooking
    - hwdbg is merged to HyperDbg codebase
    - strncmp(Str1, Str2, Num), and wcsncmp(WStr1, WStr2, Num) functions in script engine

    # Changed
    - Using a separate HOST IDT in VMCS (not OS IDT)
    - Using a dedicated HOST GDT and TSS Stack
    - Checking for race-condition of not locked cores before applying instant-events and switching cores
    - The error message for invalid address is changed (more information)
    - Fix the problem of not locking all cores after running the '.pagein' command
    Release v0.9.0 · HyperDbg/HyperDbg

    HyperDbg v0.9.0 is released! If you’re enjoying HyperDbg, don’t forget to give a star 🌟 on GitHub! Please visit Build & Install to configure the environment for running HyperDbg. Check out the ...

  • @395437265 #6504 01:06 PM, 09 Jun 2024
    Joined.
  • @CreedTX #6505 02:00 PM, 09 Jun 2024
    Joined.
  • @sovietw0rm #6506 06:31 PM, 09 Jun 2024
    Joined.
  • 10 June 2024 (2 messages)
  • @Kevinalian #6507 11:21 AM, 10 Jun 2024
    Joined.
  • @yyds1337 #6508 01:45 PM, 10 Jun 2024
    Joined.
  • 12 June 2024 (1 messages)
  • @395437265 #6509 07:34 PM, 12 Jun 2024
    Hi, maybe i missed something in manual - looks like hyperdbg is showing only 64 kernel modules, how better to debug SysWOW64 apps ?
  • 13 June 2024 (98 messages)
  • HyperDbg supports debugging 32-bits apps. You just need to use special commands (e.g., 'u32' instead of 'u' for disassembling codes), but in case if you use the wrong command ('u32' on a 64-bit app or 'u' on a 32-bit app, it will show a message and notify you. Other than everything is similar to debugging a 64 bit app.
  • About kernel modules, is there any 32 bit driver on a 64 bit machine? If I remember correctly that's not possible in Windows. 🤔
  • @rozv11e #6512 02:52 AM, 13 Jun 2024
    Joined.
  • @instw0 #6513 07:18 AM, 13 Jun 2024
    Joined.
  • @395437265 #6514 08:40 AM, 13 Jun 2024
    here is screen from process monitor, i dont see those modules neither in user or kernel mode
  • @honorary_bot #6515 08:41 AM, 13 Jun 2024
    @HughEverett hey man! I don’t know why I recalled it now, but remember you were asking about vmx root ring3 mode? The obvious example is when you’re running VMware workstation on windows. When you launch a VM, your Windows becomes a vmx root, right? That basically means it keeps working in vmx root, while still having kernel and user modes ;)
  • Not sure if I understand it correctly, what is this screen?
  • HyperDbg doesn't support 32 bit operating systems but it fully supports 32 bit applications in 64 bit operating systems.
  • Oh, that's interesting. Initially I thought that they virtualize the entire system and handle these things from Host Kernel-mode, but this kind of design (using Host User-mode) is really cool. 👌
  • @395437265 #6519 03:46 PM, 13 Jun 2024
    here is full screen. guest is w10 x64. process monitor shows all loaded modules by particular process (like WSOCK32.dll in which im interested), but i cant find any reference to it in hpyerdbg
  • Did you try the 'lm' command in HyperDbg? Isn't it what you need?

    https://docs.hyperdbg.org/commands/debugging-commands/lm
    lm (view loaded modules) | HyperDbg Documentation

    Description of the 'lm' command in HyperDbg.

  • @395437265 #6521 03:49 PM, 13 Jun 2024
    1: kHyperDbg> lm m sock
    user mode
    start entrypoint path

    ==============================================================================

    kernel mode
    start size name path

    fffff803`35ba0000 18000 vsock.sys \SystemRoot\system32\DRIVERS\vsock.sys
    fffff804`15471282 0F 01 C1 vmcall
  • @395437265 #6522 03:50 PM, 13 Jun 2024
    thats all
  • The 'lm' command has a 'pid' argument, did you try that?

    By default if you're in the context of hyperdbg-cli.exe then it shows the modules of the hyperdbg process. You can check it by using the '.process' command.
  • @HughEverett #6524 03:53 PM, 13 Jun 2024
    HyperDbg> lm um m kernel pid 1240
    user mode
    start entrypoint path

    00007ffd88860000 00007ffd888770d0 C:\Windows\System32\KERNEL32.DLL
    00007ffd865f0000 00007ffd865f92c0 C:\Windows\System32\KERNELBASE.dll
  • @395437265 #6525 03:53 PM, 13 Jun 2024
    0: kHyperDbg> g
    debuggee is running...
    fffff804`15471282 0F 01 C1 vmcall

    1: kHyperDbg> .process pid 1cb0
    press 'g' to continue the debuggee, if the pid or the process object address is valid then the debuggee will be automatically paused when it attached to the target process

    1: kHyperDbg> g
    debuggee is running...
    switched to the specified process
    00000000`759d8e34 89 44 8F F0 mov dword ptr ds:[edi+ecx*4-0x10], eax

    0: kHyperDbg> lm m sock
    user mode
    start entrypoint path

    ==============================================================================

    kernel mode
    start size name path

    fffff803`35ba0000 18000 vsock.sys \SystemRoot\system32\DRIVERS\vsock.sys
    fffff804`15471282 0F 01 C1 vmcall
  • Use it like: lm m sock pid 1cb0
  • @395437265 #6527 03:55 PM, 13 Jun 2024
    1: kHyperDbg> lm m sock pid 1cb0
    err, error not found (0)

    ==============================================================================

    kernel mode
    start size name path

    fffff803`35ba0000 18000 vsock.sys \SystemRoot\system32\DRIVERS\vsock.sys
    fffff804`15471282 0F 01 C1 vmcall

    same.. i definetly know, that process is trying to hide itself, thats why user mode might be empty..
  • You mean the process uses some kind of anti-debugging techniques?
  • @395437265 #6529 03:56 PM, 13 Jun 2024
    yes
  • @395437265 #6530 03:56 PM, 13 Jun 2024
    it fails instantly when i attach any other debugger
  • @395437265 #6531 03:58 PM, 13 Jun 2024
    i managed to intercept some kernel calls like AfdTLStartBufferedVcSend, but i dont see trace, that leads to process executable
  • HyperDbg simply reads the user mode modules list from PEB but it's highly probable that due to an anti-debugging technique the process hides it's PEB.
  • WSOCK32.dll is user module, so you can simply read it's address from any other processes.
  • @395437265 #6534 04:00 PM, 13 Jun 2024
    hm.. good idea actually. i wonder why process monitor sees its modules..
  • The addresses remain constant in Windows (before you restart), which is in contrast to Linux (which creates new ASLR addresses each time you run a new process).
  • Yep, that's interesting. I don't have any idea where they gather their user-mode modules list. 🤔
  • @395437265 #6537 04:01 PM, 13 Jun 2024
    yea.. will try to compile simple send as 32 bit app and see
  • @395437265 #6538 04:01 PM, 13 Jun 2024
    thanx
  • Also, if you have problem loading symbol files for your target process, try to run a similar 32-bit process (that loads WSOCK32.dll) and then HyperDbg even if you switch to other processes, still uses the old symbol table. Which will be useful for your case.
  • @395437265 #6540 04:06 PM, 13 Jun 2024
    perfect! with 32bit simple send

    0: kHyperDbg> lm m sock pid 0x814
    user mode
    start entrypoint path

    00000000742b0000 00000000742ba0a0 c:\Windows\SysWOW64\mswsock.dll

    ==============================================================================

    kernel mode
    start size name path

    fffff803`35ba0000 18000 vsock.sys \SystemRoot\system32\DRIVERS\vsock.sys
    fffff804`15471282 0F 01 C1 vmcall

    1: kHyperDbg> g
    debuggee is running...
  • @395437265 #6541 04:07 PM, 13 Jun 2024
    not wsock, but looks like im somwhere near
  • @395437265 #6542 04:17 PM, 13 Jun 2024
    0: kHyperDbg> x mswsock!*
    damn... will need to inspect this dll
  • Does it work? Is your process corrupting symbol hashes?
  • @395437265 #6544 04:36 PM, 13 Jun 2024
    for some reason, hyperdbg isnt trying to load symbols for that dll.. its from simple send
  • @395437265 #6545 04:36 PM, 13 Jun 2024
    ida downloads symbols just fine
  • @395437265 #6546 04:41 PM, 13 Jun 2024
    hmm

    1: kHyperDbg> .process pid 0814
    press 'g' to continue the debuggee, if the pid or the process object address is valid then the debuggee will be automatically paused when it attached to the target process

    1: kHyperDbg> g
    debuggee is running...
    switched to the specified process
    ntkrnlmp!ExpQueueWorkItem+0x37:
    fffff803`30cc8617 8B 05 43 40 A3 00 mov eax, dword ptr ds:[<ntkrnlmp!KiIrqlFlags (fffff803`316fc660)>]

    1: kHyperDbg> bp 00007ffc`3bc92320
    err, edit memory request has invalid address based on current process layout, the address might be valid but not present in the ram (c000000c)

    1: kHyperDbg> x ws2_32!send
    00007ffc`3bc92320 ws2_32!send

    1: kHyperDbg>

    0814 is simple send...
  • @395437265 #6547 04:42 PM, 13 Jun 2024
    why it cant set brakepoint there ?
  • @395437265 #6548 04:43 PM, 13 Jun 2024
    1: kHyperDbg> bp 00007ffc`3bc92320 pid 0814
    err, edit memory request has invalid address based on current process layout, the address might be valid but not present in the ram (c000000c)
    this also fails
  • Are you sure the address is valid?
  • @395437265 #6550 04:48 PM, 13 Jun 2024
    x ws2_32!send
    00007ffc`3bc92320 ws2_32!send
  • @395437265 #6551 04:49 PM, 13 Jun 2024
    doesn`t this guarantee that address is valid ?
  • @395437265 #6553 04:50 PM, 13 Jun 2024
    nope :) will try
  • @395437265 #6554 04:54 PM, 13 Jun 2024
    yess.. now it set-up that breakepoint
  • @395437265 #6555 04:54 PM, 13 Jun 2024
    thanks again :)
  • @395437265 #6556 06:55 PM, 13 Jun 2024
    1: kHyperDbg> x mswsock!WSPSend
    00000000`746be0a0 mswsock!WSPSend

    1: kHyperDbg> g
    debuggee is running...
    fffff807`ef9d1282 0F 01 C1 vmcall

    1: kHyperDbg> !epthook mswsock!WSPSend script {
    > printf("mswsock WSPSend PROC %x NAME %s\n",$proc,$pname);
    > }
    err, invalid address (c0000005)

    1: kHyperDbg> !epthook 00000000`746be0a0 script {
    > printf("mswsock WSPSend PROC %x NAME %s\n",$proc,$pname);
    > }
    err, invalid address (c0000005)

    1: kHyperDbg> .pagein mswsock!WSPSend
    the page-fault is delivered to the target thread
    press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...

    1: kHyperDbg> g
    debuggee is running...

    vm immediately restarts :(
  • @395437265 #6557 06:58 PM, 13 Jun 2024
    looks like some windows service doesnt like pagefault
  • Are you sure that you're using the latest version v0.9?
  • @395437265 #6559 07:05 PM, 13 Jun 2024
    lemme check...
  • I'm pretty sure I changed the error message for invalid access
  • Once you run HyperDbg it shows the version + build.
  • @395437265 #6562 07:07 PM, 13 Jun 2024
    ow.. 0.8.4
  • Could you test the same command (which restarts your computer immediately) with v0.9?
  • @395437265 #6564 07:08 PM, 13 Jun 2024
    sec..
  • @395437265 #6565 07:21 PM, 13 Jun 2024
    1: kHyperDbg> x mswsock!WSPSend
    00000000`74fae0a0 mswsock!WSPSend

    1: kHyperDbg> .pagein mswsock!WSPSend
    the page-fault is delivered to the target thread
    press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...

    1: kHyperDbg> g
    debuggee is running...
    immediate restart
  • @395437265 #6566 07:22 PM, 13 Jun 2024
    both server and client is 0.9
  • Crashed?
  • @395437265 #6568 07:24 PM, 13 Jun 2024
    yes. just after last g
  • No BSOD? Just restart?
  • @395437265 #6570 07:25 PM, 13 Jun 2024
    yes, vmware immediatly starts system again
  • 🤔
  • Could you change the flag of the '.pagein'?

    Use it like:
    .pagein u Address

    And if it crashed again:
    .pagein pf Address

    https://docs.hyperdbg.org/commands/meta-commands/.pagein
    .pagein (bring the page into the RAM) | HyperDbg Documentation

    Description of the '.pagein' command in HyperDbg.

  • I'm gonna see whether it's a #PF misconfiguration or a VMware error. Because generally, we're just injecting page-fault, it shouldn't crash the vCpu. 🤔
  • @HughEverett #6574 07:30 PM, 13 Jun 2024
    And one more thing, are you sure that you're using the '.pagein' in a valid process?
  • I mean you might accidentally inject the page-fault while HyperDbg is in its own process (hyperdbg-cli.exe), in this case, a crash is inevitable.
  • @HughEverett #6576 07:32 PM, 13 Jun 2024
    Since the address is not valid/assigned in hyperdbg-cli.exe's CR3.
  • @HughEverett #6577 07:32 PM, 13 Jun 2024
    You could check the current process by using the '.process' command.
  • @395437265 #6578 07:33 PM, 13 Jun 2024
    understood, let me try
  • @395437265 #6579 07:35 PM, 13 Jun 2024
    1: kHyperDbg> .sym reload pid 0x1b60
    interpreting symbols and creating symbol maps
    symbol table updated successfully

    1: kHyperDbg> .process pid 0x1b60
    press 'g' to continue the debuggee, if the pid or the process object address is valid then the debuggee will be automatically paused when it attached to the target process

    1: kHyperDbg> g
    debuggee is running...
    switched to the specified process
    ntkrnlmp!IopResetEvent+0x2e:
    fffff801`0642d7ee 48 8D 70 FD lea rsi, ds:[rax-0x03]

    0: kHyperDbg> .process
    process id: 1b60
    process (_EPROCESS): ffffaf8f`53e7a080
    process name (16-Byte): simple_send.ex

    0: kHyperDbg> x mswsock!WSPSend
    00000000`741de0a0 mswsock!WSPSend

    0: kHyperDbg> .pagein u mswsock!WSPSend
    the page-fault is delivered to the target thread
    press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...

    0: kHyperDbg> g
    debuggee is running...

    crash
  • And it also crashes without 'u' in the '.pagein'?
  • @395437265 #6581 07:39 PM, 13 Jun 2024
    yes, let me try pf
  • I think I understand the problem. This crash happens probably because you halted the process in the kernel-mode right before switching to another process.
  • @honorary_bot #6583 07:42 PM, 13 Jun 2024
    @HughEverett seems like you have a symbol engine. Do you use MS DIA?
  • @395437265 #6584 07:42 PM, 13 Jun 2024
    1: kHyperDbg> x mswsock!WSPSend
    00000000`741ce0a0 mswsock!WSPSend

    1: kHyperDbg> .pagein pf mswsock!WSPSend
    the page-fault is delivered to the target thread
    press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...

    1: kHyperDbg> g
    debuggee is running...

    crash...
  • You need to grab the execution in other ways (other than using .process).
  • Do you start the process using the '.start' command?
  • @395437265 #6587 07:43 PM, 13 Jun 2024
    no
  • Could you try to start it with the '.start' command? and once HyperDbg halted your process, reaching to the entry point, use the '.pagein'.
  • Yes, HyperDbg uses DIA SDK.
  • Or if you can halt the process any other ways, like putting breakpoint somewhere or any other methods, then use the '.pagein'. I think the problem is with the state we intercept the execution using the '.process' command. 🤔
  • One option is using the '!monitor' command with 'x' attribute on the memory range of the main module of the target process. In this case, if you're main module fetches instructions, then HyperDbg halts debuggee for you.

    https://docs.hyperdbg.org/commands/extension-commands/monitor
  • @395437265 #6593 07:52 PM, 13 Jun 2024
    i know about monitor, lets try load another function first
  • @395437265 #6594 07:53 PM, 13 Jun 2024
    .start is not an option with real process, it might work with simple_send, but antidebugger does not allow to start process properly when i use .start, tried that
  • Are you sure? The way that we start process is not same as other debuggers.
  • @395437265 #6596 07:55 PM, 13 Jun 2024
    i will try to reproduce a bit later, lets try with other function first
  • @HughEverett #6597 07:55 PM, 13 Jun 2024
    HyperDbg doesn't use the DEBUG flag for the CreateProcess win32 API.
  • If you couldn't fix the issue, I'll come with more options/solutions tomorrow. I'm gonna go sleep now. 😴💤
    Will continue tomorrow ✋
  • @395437265 #6599 07:56 PM, 13 Jun 2024
    sure, good night!
  • @395437265 #6600 08:26 PM, 13 Jun 2024
    1: kHyperDbg> .process pid 2064
    press 'g' to continue the debuggee, if the pid or the process object address is valid then the debuggee will be automatically paused when it attached to the target process

    1: kHyperDbg> g
    debuggee is running...
    switched to the specified process
    ntkrnlmp!ExpAcquireSpinLockExclusive+0x96:
    fffff807`2f82bbb6 8B 17 mov edx, dword ptr ds:[rdi]

    1: kHyperDbg> .sym reload pid 2064
    interpreting symbols and creating symbol maps
    symbol table updated successfully

    0: kHyperDbg> x mswsock!WSPSend
    00000000`74b3e0a0 mswsock!WSPSend
    somwhere in instructions above, process changes to debug-cli
    0: kHyperDbg> bp 00000000`74b3e0a0
    err, edit memory request has invalid address based on current process layout, the address might be valid but not present in the ram (c000000c)

    0: kHyperDbg> .process
    process id: 22b0
    process (_EPROCESS): ffffbe09`11cd6080
    process name (16-Byte): hyperdbg-cli.e

    0: kHyperDbg> .process pid 2064
    press 'g' to continue the debuggee, if the pid or the process object address is valid then the debuggee will be automatically paused when it attached to the target process

    0: kHyperDbg> g
    debuggee is running...
    switched to the specified process
    ntkrnlmp!KiSwapThread+0x56d:
    fffff807`2f838a9d 48 8B C3 mov rax, rbx

    0: kHyperDbg> x mswsock!WSPSend
    00000000`74b3e0a0 mswsock!WSPSend

    0: kHyperDbg> bp 00000000`74b3e0a0
    —here fine
    0: kHyperDbg>

    something like that :)
  • @395437265 #6601 08:27 PM, 13 Jun 2024
    but im not loading page
  • @395437265 #6602 08:32 PM, 13 Jun 2024
    (and it works perfect for "real" process)
  • @395437265 #6603 09:07 PM, 13 Jun 2024
    so.. looks like any invalid command and also "x" switches process to hyperdebug cli, thats causing problems with loading page
  • @6190448061 #6604 10:06 PM, 13 Jun 2024
    Joined.
  • @6190448061 #6605 10:08 PM, 13 Jun 2024
  • @6190448061 #6606 10:09 PM, 13 Jun 2024
    Good morning everyone. Have a nice day.
  • 14 June 2024 (26 messages)
  • No, neither the 'x' command nor an invalid command switch to another process, all of them stick to the current running process without continuing debuggee.
  • Didn't get it, does it fix the problem? 🤨
  • @6306026391 #6610 04:22 AM, 14 Jun 2024
    Joined.
  • @395437265 #6611 06:51 AM, 14 Jun 2024
    Yes, problem fixed. Probably it is due to sym reload, as process runs for some time and then stops again, but in debugcli process.
  • @395437265 #6612 06:54 AM, 14 Jun 2024
    Also I don't know if this is expected behavior - symbols for user mode 32 bit process, does not load automatically, I need to call sym reload each time, to get them appear in x
  • .sym reload will continue the debuggee the debuggee but .sym load doesn't continue it.

    https://docs.hyperdbg.org/commands/meta-commands/.sym
  • @HughEverett #6614 12:08 PM, 14 Jun 2024
    You just need to run '.sym reload' one time and after that the symbol table remains constant until next '.sym reload'.
  • Yes, this is expected behavior since by default once you load HyperDbg it transfers only 64-bit symbols.
  • @395437265 #6616 12:11 PM, 14 Jun 2024
    ah.. but seems .load still doesnt load 32b symbols, but anyway, im quite fine with reload :)
  • .sym load load symbol files based on the current symbol table that is available in the debugger (host) not debuggee. If you need a specific process (e.g., a 32-bit process in your case) you need to use the '.sym reload' since the details of the symbols are not available at the debugger (host).
  • @395437265 #6618 12:17 PM, 14 Jun 2024
    so, if i just copy symbol dir from debugee to debugger it shall be ok ?
  • No still it needs to '.sym reload' to build a symbol table. You can add symbols manually if you want.
  • @395437265 #6620 12:24 PM, 14 Jun 2024
    oh.. good!
  • But still I think the best way is to '.sym reload' one time (e.g., start the process and then .sym reload pid xxx), then use the symbol table for the rest of your debugging commands.
  • @395437265 #6623 12:32 PM, 14 Jun 2024
    yeah, im doing so already :)
  • @xmaple555 #6625 02:39 PM, 14 Jun 2024
    I recently back to write windows kernel. Is github copilot useful for developing kernel ?
  • @honorary_bot #6626 02:50 PM, 14 Jun 2024
    (Strong IMHO) I'd rather have full understanding and control over my code. Especially given the fact that windows kernel programming environment has a lot of extra limitations of what you can do.
  • Agree. I'm using it for almost one month, although it's helpful in some cases but doesn't make good suggestions most of the times.
  • @xmaple555 #6628 02:54 PM, 14 Jun 2024
    whatever, it is free for me
  • @honorary_bot #6629 02:55 PM, 14 Jun 2024
    It's not about the money :)
  • @6306026391 #6630 03:48 PM, 14 Jun 2024
    is it feasible to use hyperdbg for reversing user mode applications that have heavy anti-debug protections currently?

    I've tried starting and attaching to notepad with local VMI but my system crashes in 10 - 30 seconds, I get it's listed as unstable & under development but wondering if I'm missing anything or other ways to reverse user mode apps
  • HyperDbg is currently stable, with most of its functionalities now available in Debugger Mode rather than VMI Mode.

    I recommend starting with OST2 videos, as HyperDbg is little bit different than classic Windows debuggers and requires users to be familiar with some specific concepts and considerations before using it.

    https://www.youtube.com/playlist?list=PLUFkSN0XLZ-kF1f143wlw8ujlH2A45nZY
  • @6306026391 ↶ Reply to #6631 #6632 03:58 PM, 14 Jun 2024
    Thanks! Will start watching
  • @395437265 ↶ Reply to #6630 #6633 08:35 PM, 14 Jun 2024
    im trying to reverse heavy protected app, that loads itself to kernel layer and installs rootkit protection, nevertheless, im very close to break inside app code now. though i use vmware not vmi mode
  • @395437265 #6634 08:36 PM, 14 Jun 2024
    so that's quite a tool :)
  • 15 June 2024 (31 messages)
  • @AlejoMartinez74 #6635 12:30 PM, 15 Jun 2024
    Joined.
  • @instw0 #6636 02:48 PM, 15 Jun 2024
    guys, I'm sorry for the noob question, I'm just getting into the subject.... Is the hypervisor essentially a driver program for configuring ept? ept virtual memory virtualization?
  • Hi there! Kind of yes, but not just that. I'd say it's a software that manages some sort of virtualization overall. If we're talking about Intel specifically, it's a software for managing VMX mode execution of CPU (put aside platform and external devices for now). EPT is a feature of VMX. There are many other features as well.
  • @instw0 #6638 03:02 PM, 15 Jun 2024
    if I understood correctly, are all hooks based on artificial error generation of ept pages? with subsequent processing...
  • @honorary_bot #6639 03:08 PM, 15 Jun 2024
    If you're familiar with a concept of page faults, then it's the same thing, it's just not an exception but rather a "VMX event"
  • @honorary_bot #6640 03:09 PM, 15 Jun 2024
    I mean yes, you could say so
  • @instw0 #6641 03:20 PM, 15 Jun 2024
    I wanted to clarify, to enable the hypervisor you need to do vmx on -> settings vmcs -> vmlauch?
  • @honorary_bot #6642 03:27 PM, 15 Jun 2024
    Yes
  • @instw0 #6643 03:50 PM, 15 Jun 2024
    I have an OS running, then I execute VMX ON from the driver in this OS... the processor stops the execution of the OS and my driver... how can I return control to the driver? Do you need to write out the logic in advance to exit the vmx root mode?
  • You have to fill out the VMCS properly and completely and set handlers for vmx exits first.
  • @honorary_bot #6645 03:58 PM, 15 Jun 2024
    Unfortunately, partial implementation of the hypervisor is not feasible
  • @instw0 #6646 04:01 PM, 15 Jun 2024
    it turns out that the rip register is set in the structure?
  • @instw0 #6647 04:04 PM, 15 Jun 2024
    asked the question incorrectly, after configuring the structures, it is necessary to somehow specify which code will be virtualized (the current system or a pointer to another area)
  • @honorary_bot #6648 04:04 PM, 15 Jun 2024
    So you have a concept of host mode and a guest mode
  • @honorary_bot #6649 04:05 PM, 15 Jun 2024
    Host mode is where hypervisor is executed, guest is where a guest OS is executing
  • @honorary_bot #6650 04:05 PM, 15 Jun 2024
    whenever you execute vmlaunch instruction, you enter vmx guest mode
  • @honorary_bot #6651 04:06 PM, 15 Jun 2024
    for that you need to initialize vmcs guest fields
  • @honorary_bot #6652 04:06 PM, 15 Jun 2024
    then, in order to return to host mode, some sort of vmexit event is needed in guest mode
  • @honorary_bot #6653 04:07 PM, 15 Jun 2024
    and surely you need properly configured vmx host vmcs fields
  • @honorary_bot #6654 04:07 PM, 15 Jun 2024
    hopefully this clarifies how vmx works
  • As an additional resource, you might also find the "Hypervisor from Scratch" tutorial helpful in understanding how VMX works. You can access it here:

    https://rayanfam.com/tutorials/
    Tutorials

    We write about Windows Internals, Hypervisors, Linux, and Networks.

  • @instw0 #6656 04:38 PM, 15 Jun 2024
    so it turns out that you need an event to switch to host mode? And to return back to the guest mode, do you need to configure the structures again?
  • @instw0 #6657 04:41 PM, 15 Jun 2024
    and it turns out that the structures VMX specify a pointer to the code that needs to be executed in guest mode (not necessarily OS)
  • It depends on the type of the VMX event, like sometimes you need to readjust RIP value or something, but in general you don't need to reconfigure much between vmresumes
  • @instw0 #6659 04:59 PM, 15 Jun 2024
    is the execution code configured in ept?
  • @instw0 #6660 05:58 PM, 15 Jun 2024
    I would like to run my own piece of code other than the guest os...
  • @honorary_bot #6661 06:21 PM, 15 Jun 2024
    EPT describes guest physical memory to host physical memory mapping
  • What mode do you want to run your code in?
  • @6190448061 #6663 09:59 PM, 15 Jun 2024
  • @6190448061 #6664 09:59 PM, 15 Jun 2024
    Good morning everyone. Have a nice day.
  • Good Moring Ting Zhang Qi
  • 16 June 2024 (43 messages)
  • @instw0 ↶ Reply to #6662 #6666 02:53 AM, 16 Jun 2024
    Good day!I have a shellcode in memory and I want to transfer control only to it.... just like vmware, qemu, their hypervisor, the kernel transfers control to a separate piece of memory, rather than virtualizing the host system
  • @instw0 #6667 03:08 AM, 16 Jun 2024
    when we virtualize the current system, we adjust it to the physical memory of the current one. But what if you only need to virtualize a piece of code
  • @instw0 #6668 05:33 AM, 16 Jun 2024
    and another question, if we virtualize the host system, how will the monitor driver inside the host handle commands, for example vm exit
  • Hi! Still not sure what you mean by "virtualize"
  • @honorary_bot #6671 10:12 AM, 16 Jun 2024
    You have a CPU, right. When VMX is enabled, you can execute either in VMX root or VMX non-root (guest) mode.
  • @honorary_bot #6672 10:12 AM, 16 Jun 2024
    If you have a shell code, you may just execute it as either VMX root or VMX guest
  • @honorary_bot #6673 10:14 AM, 16 Jun 2024
    Do you imply physical memory virtualization?
  • @395437265 #6674 10:14 AM, 16 Jun 2024
    hi guys, am i stupid or thats not possible - when i use !epthook, can i print stack trace? i know that pause() will lose context, but is it possible to print trace when hook is triggered?
  • @instw0 ↶ Reply to #6672 #6675 10:14 AM, 16 Jun 2024
    you need to provide a link to it in vmxcs, right?
  • Yes, I've mentioned it here
  • @instw0 #6677 10:17 AM, 16 Jun 2024
    and if I virtualize my current system, how do I exit this mode? do I need to set some kind of pause condition in the vmcs structure?
  • @honorary_bot #6678 10:21 AM, 16 Jun 2024
    By virtualizing the current system, do you mean entering to VMX guest mode with a custom EPT?
  • @honorary_bot #6679 10:22 AM, 16 Jun 2024
    Sorry to choke you on that one, but it's much easier to understand each other when you use common technical terms, which come from Intels Software Developers Manual in this case
  • @instw0 ↶ Reply to #6678 #6680 10:24 AM, 16 Jun 2024
    if I virtualized the current system, how do I exit this mode? (host->guest->host?)
  • @honorary_bot #6681 10:27 AM, 16 Jun 2024
    There are many vmexit conditions available in VMX. Like cpuid instruction for instance. I'd recommend skimming through vol 3 chapter 28 of Intel's SDM.
  • You cannot use the 'k' command within a !epthook script since it's a command not a script function, but you can write the functionality of the printing callstack by using a simple script.
  • I think I wrote something similar for one of my projects years ago, lemme check.
  • @395437265 #6684 10:31 AM, 16 Jun 2024
    basically i need to go trough rsp, right ?
  • @HughEverett #6685 10:32 AM, 16 Jun 2024
    ? n = 5;
    ? m = 50;
    ? for (j = 0; j != m; j++) {
    temp = @rsp + (j * 8);

    printf("%llx", temp);

    for (i = 0; i != n; i++) {

    is_valid = check_address(temp);

    if (is_valid == 1) {

    temptemp = temp;
    temp = poi(temp);

    is_valid2 = check_address(temp);

    if (is_valid2 == 1) {

    printf("-> %llx", temp);
    } else {
    test1 = db(temptemp);
    test2 = db(temptemp + 1);
    if (test1 > 1f && test1 < 7f) {
    if (test2 == 0x0) {
    printf(" (%ws)", temptemp);
    } else {
    printf(" (%s)", temptemp);
    }
    }
    }

    } else {
    break;
    }
    }
    printf("\n");
    }
  • Yes, you basically need something like the above script.
  • @montagne1337 #6689 10:36 AM, 16 Jun 2024
    hey there, is it possible to discard handling of cpuid instruction in the hypervisor and leave it to the cpu?
  • Unfortunately not, it is an unconditional vm exit
  • As @honorary_bot mentioned it's an unconditional VM-exit but generally HyperDbg won't touch the results of CPU's CPUID registers. So, the problem here is just VM-exit timing, other than that HyperDbg won't modify the CPUID results (we just set the hypervisor bit, and Hypervisor signature which can be ignored by a simple script).
  • @montagne1337 #6693 10:41 AM, 16 Jun 2024
    then is there any way to prevent the guest from spamming cpuid instruction, it absolutely kills performance
  • @montagne1337 #6694 10:41 AM, 16 Jun 2024
    I have a specific program which does that
  • @montagne1337 #6695 10:41 AM, 16 Jun 2024
    if ran without hypervisor, performance is okay
  • Why don't you nop those CPUID instruction?
  • @montagne1337 #6697 10:43 AM, 16 Jun 2024
    I believe it uses cpuid to get information from it plus time measurements
  • You can write a HyperDbg script to nop all occurrence of CPUIDs. Something like this:

    !cpuid pid XX {
    // CPUID = 0F A2
    eb(@rip, 90);
    eb(@rip + 1, 90);
    }
  • You can also find the execution of RDTSC/RDTSCP instructions for timing by using the !tsc command and nop it similar to the above script. Also, manual investigation might be needed to avoid breaking the process's semantics.

    https://docs.hyperdbg.org/commands/extension-commands/tsc
    !tsc (hook RDTSC/RDTSCP instruction execution) | HyperDbg Documentation

    Description of the '!tsc' command in HyperDbg.

  • Man, btw, there is a tiny case where you should still adjust cpuid result for the guest. You need to readjust cr4.osxsave and cr4.pke to reflect not the host mode, but the guest mode when returning data to the guest. Those cpuid bits depend on cr4: leaf 1 and leaf 7 respectively
  • I think its not possible if the function which executes cpuid is virtualized
  • like what kind of virtualization? you mean obfuscated?
  • @montagne1337 #6703 10:52 AM, 16 Jun 2024
    yes, these proprietary software protectors bruh
  • Maybe we should introduce techincal terms in this chat in order us to understand each other better? :)
  • 😅
  • @395437265 ↶ Reply to #6685 #6706 11:03 AM, 16 Jun 2024
    If I debug 32 bit, app shall i reduce instruction length to 4?
  • yes
  • not instruction length actually, memory size is the correct term
  • @395437265 #6709 11:07 AM, 16 Jun 2024
    Yea, got it, j*8 => j*4 to print out 32 bit chunks
  • 17 June 2024 (93 messages)
  • @instw0 #6710 06:27 AM, 17 Jun 2024
    hi all! is it possible in hyperdbg to somehow disable interrupt processing (or at least single step) so that single step is processed in the try catch block
  • Yes, you need to disable exceptions/faults/traps (not exactly interrupts in HyperDbg terms). Anyway, both of them are possible in HyperDbg by using the !exception and !interrupt commands along with short-circuiting.

    Please check:
    https://docs.hyperdbg.org/commands/extension-commands/exception
    https://docs.hyperdbg.org/tips-and-tricks/misc/event-short-circuiting
    !exception (hook first 32 entries of IDT) | HyperDbg Documentation

    Description of the '!exception' command in HyperDbg.

  • You need something like this:

    !exception 1 pid XX {
    event_sc(1);
    }
  • @instw0 #6713 06:47 AM, 17 Jun 2024
    if the kernel module?
  • Other than, if you're dealing with the Debugger Mode, you can also tell HyperDbg not to intercept Traps or Breakpoints and later short-circuit it by the !exception command. Something like :

    test breakpoint off
    test trap off
  • No difference, works the same in both user-mode and kernel-mode.
  • @instw0 #6716 07:12 AM, 17 Jun 2024
    how disabled hardware braikpoint?
  • @instw0 #6717 07:12 AM, 17 Jun 2024
    example ba e in windbg
  • Use the '!dr' command along with short-circuiting mechanism:

    https://docs.hyperdbg.org/commands/extension-commands/dr
    !dr (hook access to debug registers) | HyperDbg Documentation

    Description of the '!dr' command in HyperDbg.

  • @instw0 #6719 07:17 AM, 17 Jun 2024
    !dr script {events_sc(1)} ?
  • @HughEverett #6720 07:17 AM, 17 Jun 2024
    @instw0 check these videos:
    https://www.youtube.com/watch?v=OBcTwRkCE68&list=PLUFkSN0XLZ-kF1f143wlw8ujlH2A45nZY&index=50
    https://www.youtube.com/watch?v=Z6HAO4btkCM&list=PLUFkSN0XLZ-kF1f143wlw8ujlH2A45nZY&index=60
    Dbg3301: HyperDbg 08 06 Debug Register Monitoring

    View the full free MOOC at https://ost2.fyi/Dbg3301. This course is an introductory guide to HyperDbg debugger, guiding you through the initial steps of using HyperDbg, covering essential concepts, principles, debugging functionalities, along with practical examples and numerous reverse engineering methods that are unique to HyperDbg. Whether you have an interest in reverse engineering or seek to elevate your reverse engineering skills with hypervisor-assisted approaches, this course provides a solid foundation for starting your journey.

  • exactly
  • Just make sure to use a printf to make sure it works as expected since I never test short-circuiting with the '!dr' events.
  • @HughEverett #6723 07:18 AM, 17 Jun 2024
    But it should work
  • @instw0 #6724 07:22 AM, 17 Jun 2024
    1: kHyperDbg> !dr script {events_sc(1)}
    Line 0:
    events_sc(1)
    ^
    Undefined Function
  • add semicolon
  • @instw0 #6726 07:24 AM, 17 Jun 2024
    1: kHyperDbg> !dr script {events_sc(1);}
    Line 0:
    events_sc(1);
    ^
    Undefined Function
    )))
  • @HughEverett #6727 07:24 AM, 17 Jun 2024
    event_sc
  • @instw0 #6728 07:25 AM, 17 Jun 2024
    1: kHyperDbg> !dr script {event_sc(1);}
    (10:21:19.363 - core : 1 - vmx-root? yes) [!] Error (KdDispatchAndPerformCommandsFromDebugger:2263) | Err, checksum is invalid
  • @instw0 #6729 07:25 AM, 17 Jun 2024
    vmware+windbg+hyperdbg
  • reconnect to HyperDbg? This error is not related to this event.
  • @HughEverett #6731 07:26 AM, 17 Jun 2024
    Another unrelated error happened there.
  • @instw0 #6732 07:28 AM, 17 Jun 2024
    i run vmware + windbg + hyperdbg
  • @instw0 #6733 07:28 AM, 17 Jun 2024
    add two ba in windbg
  • use it like :

    !dr script {
    event_sc(1);
    printf("ignoring debug reg modification from %s, pid: %x\n", $pname, $pid);
    }
  • It's okay, you just need to tell HyperDbg not to intercept breakpoints/traps if you want to use Windbg.
  • this one
  • @instw0 #6737 07:36 AM, 17 Jun 2024
    they don't come to windbg now))))
  • What do you mean?
  • @instw0 #6739 07:37 AM, 17 Jun 2024
    when I put hardware breakpoints in windbg they don't come with the command !dr script {event_sc(1);}
  • @instw0 #6740 07:38 AM, 17 Jun 2024
    in windbg
  • You mean HyperDbg didn't intercept hardware breakpoint accesses? or it ignore them successfully as expected?
  • @instw0 #6742 07:40 AM, 17 Jun 2024
    he successfully ignores them, but they don't come to windbg either)))
  • @instw0 #6743 07:40 AM, 17 Jun 2024
    and in windbg, I kind of need them)
  • you mean once you try to access them (view the list of debug breakpoints) windbg won't show them?
  • @instw0 #6745 07:42 AM, 17 Jun 2024
    He doesn't stop there... I wanted the hardware breakpoints to be caught by windbg, not hyperdbg.
  • I don't understand what you're trying to do. 🙂

    If you want to ignore them using the '!dr' command, then why do you expect them to be triggered?
  • HyperDbg can also manually inject #DBs which is how debug breakpoint registers notify about their trigger events.

    https://docs.hyperdbg.org/commands/scripting-language/functions/events/event_inject
    event_inject | HyperDbg Documentation

    Description of the 'event_inject' function in HyperDbg Scripts

  • @instw0 ↶ Reply to #6746 #6748 08:05 AM, 17 Jun 2024
    the hypervisor does not seem to handle the single step exception correctly (rflags.tf ) . I wanted to try to do processing through windbg
  • Why? HyperDbg's 't' command has problem? 🤨
  • @HughEverett #6750 08:06 AM, 17 Jun 2024
    Is it also the same for the instrumentation step-in (the 'i' command)?
  • @instw0 #6751 08:07 AM, 17 Jun 2024
    A Common Missight in Most Hypervisors

    Generally, when a hypervisor encounters a VM exit, it is because it needs to emulate the effects of an instruction, be it CPUID, RDMSR, or E...

  • @instw0 #6752 08:07 AM, 17 Jun 2024
    trap flag after popfd
  • @instw0 #6753 08:07 AM, 17 Jun 2024
    in code
  • @HughEverett #6754 08:08 AM, 17 Jun 2024
    Ah, got it.
  • @instw0 #6755 08:09 AM, 17 Jun 2024
    is the error related to the fact that exceptions are not processed in time?
  • When you run (test trap off) HyperDbg won't handle traps anymore. Everything is passed to the OS (Windbg).
  • No the problem is that cpuid will cause VM-exit before trap flag by default in Intel processors.
  • @instw0 #6758 08:15 AM, 17 Jun 2024
    that is, the hypervisor incorrectly executes vm exit with the TF flag?
  • CPUID unconditionally cause a VM-exit and in HyperDbg a trap flag (#DB) will also cause a VM-exit but in Intel processors, CPUID has precedence over #DB (or more accurately RFLAGs.TF), that's why HyperDbg first receives and handles CPUIDs then processor triggers trap flag.
  • I'm thinking of a fast patch to this. Are you currently stepping through these instructions? I mean how do you test it?
  • @instw0 #6761 08:23 AM, 17 Jun 2024
    vmprotect
  • @instw0 #6762 08:23 AM, 17 Jun 2024
    driver with vmprotect
  • I think this can be handled by a combination of the '!exception' command and the '!cpuid' command, but not sure. 🧐
  • @instw0 #6765 08:29 AM, 17 Jun 2024
    я хочу понять саму проблему.... Получается если мы в гипервизоре выполняем инструкции вызывающие vm exit (cpuid, rdtsc ...), то hyperdbg вылетает, так как cpuid c tflags.tf обрабатывается не правильно
  • @instw0 #6767 08:30 AM, 17 Jun 2024
    in theory, the cpuid instruction should be processed first, then exception
  • Wait a moment, I'll make a patch, and will let you know.
  • @HughEverett #6769 08:50 AM, 17 Jun 2024
    @instw0 pls checkout to this branch and recompile HyperDbg:
    https://github.com/HyperDbg/HyperDbg/tree/trap-cpuid
    GitHub - HyperDbg/HyperDbg at trap-cpuid

    State-of-the-art native debugging tool. Contribute to HyperDbg/HyperDbg development by creating an account on GitHub.

  • Let me know if it fixes the issue, I added this check to this branch (but not test it):
    https://github.com/HyperDbg/HyperDbg/commit/ddbf929aa2043d0a65887e4fd428bfe6afddd43f
    detect and handle CPUIDs with TRAP flag · HyperDbg/HyperDbg@ddbf929

    State-of-the-art native debugging tool. Contribute to HyperDbg/HyperDbg development by creating an account on GitHub.

  • @instw0 ↶ Reply to #6770 #6771 09:17 AM, 17 Jun 2024
    no, it didn't fix the problem (
    after CPUID :
    RAX:00000000000906E9
    RBX:0000000000100800
    RCX:000000007FFAFBBF
    RDX:00000000BFEBFBFF
    RIP:FFFFF8085560F443
    tsc : FFFFF808556C0296
    tsc : FFFFF808556C0296
    tsc : FFFFF808556C0296
    tsc : FFFFF808556C0296
    tsc : FFFFF808556C0296
    tsc : FFFFF808556C0296
    tsc : FFFFF808556841C2
    tsc : FFFFF808555F5F8C
    tsc : FFFFF80855592581
    fffff808`55592584 68 12 6C 45 A9 push 0xFFFFFFFFA9456C12

    0: kHyperDbg>
  • Don't use the '!tsc' for now, just try to see if HyperDbg shows this message or not?

    Does it show this message?
  • @instw0 ↶ Reply to #6772 #6773 09:35 AM, 17 Jun 2024
    no (((
    debuggee is running...
    NtQuerySystemInformation : FFFFF805B9C2457F RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9E11A29 RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9E8952D RCX: 0000000000000023
    New NtQuerySystemInformation : FFFFF805B9E8952D RCX: 0000000000000000
    NtQuerySystemInformation : FFFFF805B9E61046 RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9F33FF4 RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9C2457F RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9E11A29 RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9C2457F RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9E11A29 RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9C2457F RCX: 000000000000000B
    NtQuerySystemInformation : FFFFF805B9E11A29 RCX: 000000000000000B
    after CPUID :
    RAX:0000000000000001
    RBX:FFFFF38D666824E2
    RCX:FFFFFFFFFFF8F03A
    RDX:00000000000000C5
    RIP:FFFFF805B9E8F443
    new CPUID :
    RAX:00000000000906E9
    RBX:0000000000100800
    RCX:000000007FFAFBBF
    RDX:00000000BFEBFBFF
    RIP:FFFFF805B9E8F443
    after CPUID :
    RAX:00000000000906E9
    RBX:0000000000100800
    RCX:000000007FFAFBBF
    RDX:00000000BFEBFBFF
    RIP:FFFFF805B9E8F443
    fffff805`b9e12583 90 nop
  • So, the way that VMProtect detects hyperviosr (HyperDbg) is not based on this trick.
  • @instw0 #6775 09:46 AM, 17 Jun 2024
    if I use windbg, then it will stop at single step. if I run events->ignore handing single step then everything works fine
  • @instw0 #6776 09:49 AM, 17 Jun 2024
    + hyperdbg crashes after cpuid and the entire system needs to be rebooted
  • @instw0 #6777 10:22 AM, 17 Jun 2024
    after CPUID :
    RAX:00000000000906E9
    RBX:0000000000100800
    RCX:000000007FFAFBBF
    RDX:00000000BFEBFBFF
    RIP:FFFFF805C0BFF443
    exception : FFFFF805C0B82583
    with !exception
  • @xmaple555 #6778 10:40 AM, 17 Jun 2024
    @HughEverett hi, not really understand scala language. Is scala code developed in visual studio community ? and Do i need FPGA to run hwdbg ?
  • @instw0 #6779 10:40 AM, 17 Jun 2024
    the rdtsc operation performs the same as cpuid vm exit?
  • It depends, CPUID is an unconditional VM-exit but RDTSC/RDTSCP only cause VM-exit when you use the !tsc command in HyperDbg.
  • Hi,
    Scala is used as a part of porting HyperDbg into the hardware (Chip & FPGA) debugging (hwdbg). It is mainly written based on the Chisel language: https://www.chisel-lang.org

    If you want to test and use hardware debugging, then you need an FPGA. Basically, this Scala code that I wrote for hwdbg generates Verilog and SystemVerilog (HDL) codes that are synthesizable into FPGAs.

    For the issue I posted on GitHub early today, I didn't mean to modify the Scala code, I just meant to show you how I implemented the evaluation engine in hardware, so basically a simple modification on the INC++ and DEC++ operands in the C code is needed.

    I wrote the evaluation engine in Scala (https://github.com/HyperDbg/HyperDbg/blob/45b88f652d071e0f3c11b1f84b8a2a2d6556972a/hwdbg/src/main/scala/hwdbg/script/eval.scala#L97).

    The concept is the same, HyperDbg makes a script buffer using C/C++ codes and once the script buffer is ready, we'll send it to the hwdbg (through either Serial port or shared BlockRAM). The generated hardware part (the Scala code) is responsible for running those script buffers that we generated in the script engine.
    Chisel | Chisel

    Software-defined hardware

  • @395437265 #6782 11:23 AM, 17 Jun 2024
    @HughEverett By the way, is it even possible to dump debugee whole process memory, like creating big buffer in Ram, and dump that into file, as process continues? Transferring over serial connection is no option for sure :)
  • HyperDbg has a dump command (previously requested by @ricnar) and documented:

    https://docs.hyperdbg.org/commands/extension-commands/dump
    !dump (save the physical memory into a file) | HyperDbg Documentation

    Description of '!dump' command in HyperDbg.

  • But it transfer buffer over serial.
  • @395437265 #6785 11:25 AM, 17 Jun 2024
    yes, i know that
  • @395437265 #6786 11:25 AM, 17 Jun 2024
    thats issue
  • @395437265 #6787 11:25 AM, 17 Jun 2024
    2mb transfer is around minute or so
  • If you need any other kind of implementation, I think you can easily implement it by creating a new command based on this dump command.
  • @HughEverett #6789 11:27 AM, 17 Jun 2024
    and of course, create a PR so everyone can use it. 🙂
  • @395437265 #6790 11:27 AM, 17 Jun 2024
    ok, will see :) thanks
  • @instw0 ↶ Reply to #6769 #6791 01:08 PM, 17 Jun 2024
    I'm sorry, the main branch was copied without corrections.
  • @instw0 #6794 01:15 PM, 17 Jun 2024
    I can't copy the updated branch
  • just do
    git clone https://github.com/HyperDbg/HyperDbg.git
    cd HyperDbg
    git checkout trap-cpuid
  • @instw0 #6796 02:06 PM, 17 Jun 2024
    no loginfo after cpuid, but "popfq" with 000346(trap single step) is before rdtsc
  • @instw0 #6797 05:47 PM, 17 Jun 2024
    guys are the debugging commands p, t, i implemented via hooks ept?
  • Could you share disassembly of instructions after popfq?
  • No, none of them are related to EPT hooks.
  • @instw0 ↶ Reply to #6799 #6800 05:51 PM, 17 Jun 2024
    rflag?
  • Let me send you a link about its design.
  • Please check this doc:
    https://research.hyperdbg.org/assets/documents/kernel-debugger-design-1st-edition.pdf
  • It explains how these commands (specially the instrumentation step-in) is implemented.
  • 18 June 2024 (8 messages)
  • @instw0 ↶ Reply to #6803 #6805 04:23 AM, 18 Jun 2024
    through the eflags register like other debuggers + mtf?
  • @instw0 #6806 04:50 AM, 18 Jun 2024
    and how is the nmi controller related to debugging the program code(step-in, step-over)
  • @instw0 #6807 10:23 AM, 18 Jun 2024
    and another question is there an event(!cpu) check in the function DispatchEventCpuid(VIRTUAL_MACHINE_STATE * VCpu)
  • Only the 'i' command (instrumentation step-in) uses MTF (Monitor Trap Flag). Other stepping command like 't' is implemented same as WinDbg by using RFLAGS's TF.
  • NMI is not realted to step-in or step-over, HyperDbg just uses NMI to halt (pause) all cores in the Debugger Mode.
  • Not sure if I correctly understand what you mean. 🤔
    What is event(!cpu)?
  • @instw0 ↶ Reply to #6810 #6811 01:30 PM, 18 Jun 2024
    when we use events !cpuid, !rdtsc do we configure the vmxcs structure to vm-exit when an event occurs?
  • @instw0 #6812 01:32 PM, 18 Jun 2024
    then we process it in vmm as a debugger interrupt?
  • 19 June 2024 (25 messages)
  • For !tsc Yes, for !cpuid No. CPUID is unconditional VM-exit. Here is a list of instructions with unconditional VM-exit.
  • We process it as VM-exit, not interrupt.
  • @instw0 #6815 04:35 AM, 19 Jun 2024
    how do you keep track of instructions that don't cause the VM to exit? example RDTCS, vmcall...
  • @instw0 #6816 04:36 AM, 19 Jun 2024
    read msr in vmxcs?
  • RDTSC is configured from VMCS, VMCALL is unconditional VM-exit and !msrread !msrwrite use MSR Bitmaps. Take a look at Hypervisor From Scratch, I think it gives you an idea how HyperDbg works internally:

    https://rayanfam.com/tutorials/
    Tutorials

    We write about Windows Internals, Hypervisors, Linux, and Networks.

  • @zhang_derek #6818 05:56 AM, 19 Jun 2024
    win10 bluescreen,
  • @zhang_derek #6819 05:57 AM, 19 Jun 2024
    How to fix
  • You need to provide more details. What is the generation of your processor? which version of Windows? and how to reproduce it?
  • @instw0 ↶ Reply to #6817 #6821 07:34 AM, 19 Jun 2024
    yes, I've read it, I just wanted to clarify that the debugger is at the event !cpuid, !rdtsc set conditions in the vmxsc structure? then vmm receives a notification(or vmexit)?
  • @instw0 #6822 07:36 AM, 19 Jun 2024
    it's just that cpuid causes an unconditional vmexit anyway, and in the case of !rdtsc?
  • Not related to hyperdbg, but vmprotect does not care if you break at cpuid or at the nop. https://github.com/jmpoep/vmprotect-3.5.1/blob/d8fcb7c0ffd4fb45a8cfbd770c8b117d7dbe52b5/runtime/core.cc#L771
  • @instw0 ↶ Reply to #6823 #6824 08:09 AM, 19 Jun 2024
    RDTSC?
  • Conditions checks for each extension command is basically software-side implemented. RDTSC/RDTSCP cause conditional VM-exits (not remember, either on primary or secondary proc-based VMCS controls).
  • @HughEverett #6828 11:33 AM, 19 Jun 2024
    Development progress update: hwdbg has reached the point where it can run HyperDbg scripts (dslang) for chip/FPGA debugging. Still under development!

    https://github.com/HyperDbg/HyperDbg/tree/dev/hwdbg
  • @xmaple555 we need to think of the best way to parse scripts of the hwdbg debugger. The registers and pseudo-registers of the hwdbg is different from x64 registers. 🤔
  • Basically, hwdbg registers are like @hw_pin0, @hw_pin1, @hw_pin2, ..., @hw_pinX and @hw_port0, @hw_port1, @hw_port2, ..., @hw_portX. We need to find the best way of adding these registers (and new pseudo-registers) to the parser.
  • @instw0 ↶ Reply to #6826 #6832 12:47 PM, 19 Jun 2024
    accordingly !vmcall, !dr... they also cause the exit from the virtual machine (vmexit)
  • VMCALL is unconditional, !dr needs configuration. Pls check this file as it's the file responsible for configuring events:

    https://github.com/HyperDbg/HyperDbg/blob/master/hyperdbg/hprdbgkd/code/debugger/events/ApplyEvents.c
    HyperDbg/hyperdbg/hprdbgkd/code/debugger/events/ApplyEvents.c at master · HyperDbg/HyperDbg

    State-of-the-art native debugging tool. Contribute to HyperDbg/HyperDbg development by creating an account on GitHub.

  • @395437265 #6834 08:30 PM, 19 Jun 2024
    hey there, im trying to build solution and getting:
  • @395437265 #6835 08:30 PM, 19 Jun 2024
    have latest VS SDK and WDK
  • @395437265 #6836 08:44 PM, 19 Jun 2024
    i commented out definitions in ntioapi.h, but i dont know if it is valid solution
  • @395437265 #6837 08:46 PM, 19 Jun 2024
    it conflicted with winnt.h
  • @395437265 #6838 10:45 PM, 19 Jun 2024
    another question, im trying to use firstchance exception handling, im executing !epthook <hidden> code {31 c0 f7 f0} <- division by zero. but debugger console stays in infinite loop
  • 20 June 2024 (66 messages)
  • @6190448061 #6839 01:58 AM, 20 Jun 2024
    有没有自己人?😁
  • @chadgpt ↶ Reply to #6839 #6840 02:33 AM, 20 Jun 2024
    没有
  • @instw0 ↶ Reply to #6833 #6841 03:39 AM, 20 Jun 2024
    thank you, did I understand correctly(in general):
    configuring vmxcs to be notified when an event occurs -> processing in vmm?
  • @instw0 ↶ Reply to #6798 #6842 03:41 AM, 20 Jun 2024
    i add a check rflags.tf in !tsc, and:
  • @instw0 #6844 03:53 AM, 20 Jun 2024
    the debugger is frozen...
  • Ah, this one is also mentioned by another person in issues. This one should be updated in the phnt repo that we used it as a submodule. We could also update HyperDbg's fork and comment it. I'll fix it.
  • Not sure what you trying to do? The division by zero error you're trying produce is handled in VMX root-mode because all of the events (except !epthook2, not !epthook) execute assembly in VMX root-mode, so it's not handled by guest (Windows) IDT and it's passed to HyperDbg's HOST IDT exception handler.
  • Yes
  • Just added a check? Any modification to the TF Flag?
  • @instw0 #6849 03:02 PM, 20 Jun 2024
    debugger is frozen
  • @instw0 #6851 03:03 PM, 20 Jun 2024
    EventinjectDebugBreakpoint is tf processing?
  • @6306026391 #6852 03:18 PM, 20 Jun 2024
    I'm trying to do remote debugging with 2 physical machines over COM but the connection never seems to complete, the debugger stays on

    HyperDbg> .debug remote serial 115200 com1
    Waiting for debuggee to connect...

    And the debugee:

    HyperDbg> .debug prepare serial 115200 com3
    current processor vendor is : GenuineIntel
    virtualization technology is vt-x
    vmx operation is supported by your processor

    I've tested the COM connection with PuTTY and all appears to be working fine there, any suggestions on what I can do to debug/fix the issue?
  • @395437265 ↶ Reply to #6846 #6853 03:44 PM, 20 Jun 2024
    im trying to stop app in particular state by modifying code to raise division exception, now app stops with unhandled exception and windows popup appears. i can take dump, state is intact, however, in traces i can see windows exception handler mechanism, so real trace is not accessible. actually i wanted to cause BSOD, but it seems its not so easy for usermode
  • Yes a trap flag generates a #Db.
  • @instw0 ↶ Reply to #6854 #6855 04:13 PM, 20 Jun 2024
    and is it being processed?
  • If I were in your shoes, I tried to make a simple application with your target technique (popfq TF), and I try to trigger the behavior in HyperDbg like showing a message using (LogInfo) without modifying anything. Once I was sure that this technique can be correctly detected (by seeing the message), then I try to modify the guest state. I think this is the best approach to handle this VMProtect technique.
  • @instw0 ↶ Reply to #6856 #6857 04:16 PM, 20 Jun 2024
    I'm trying
  • Yes, but it depends on when CPU gives us this #Db, the reason such a technique exists is because CPUID has precedence over #Db's exception bitmap vm-exit.
  • @instw0 #6860 04:18 PM, 20 Jun 2024
    Are we processing the trap inside now?
  • Ah, unfortunately this feature is not working as expected. We previously had a discussion in this group and conclude that this feature is not working. You need to use a virtual serial device.
  • @instw0 #6862 04:19 PM, 20 Jun 2024
    that is, the exception should be triggered immediately after the cpuid instruction?
  • @instw0 #6863 04:21 PM, 20 Jun 2024
    just processing rflags.tf should take place inside the try catch block, not in the debugger
  • .
  • Larry you can follow this discussion, it's probably the problem with verifying packets.
  • Still don't understand what you're trying to do but if you want to trigger an exception in your target user-mode app, you need to inject an event in HyperDbg by using these functions:

    https://docs.hyperdbg.org/commands/scripting-language/functions/events/event_inject

    And:

    https://docs.hyperdbg.org/commands/scripting-language/functions/events/event_inject_error_code

    These are the functions that deliver exception to the guest debuggee application. The assembly code you used in your event will cause division by zero in HyperDbg's VMM which is simply handled in VMX root-mode and it's ignored by HyperDbg's division by zero exception handler.
    event_inject | HyperDbg Documentation

    Description of the 'event_inject' function in HyperDbg Scripts

  • Depends on how CPU behaves in this case. If it triggers immediately then you need to inject a #DB.
  • User-mode try/catch?
  • @instw0 #6869 04:28 PM, 20 Jun 2024
    kernel
  • Are you analyzing a driver?
  • @instw0 #6871 04:29 PM, 20 Jun 2024
    yes
  • @instw0 #6872 04:29 PM, 20 Jun 2024
    driver obfuckate vmprotect
  • @HughEverett #6873 04:29 PM, 20 Jun 2024
    I think you need to create a user-mode application with the same technique.
  • @HughEverett #6874 04:31 PM, 20 Jun 2024
    It's easier to modify a user-mode application and introspect it's behavior. Try to make a similar check function check in user-mode.
  • @HughEverett #6875 04:31 PM, 20 Jun 2024
    And also post your function here if it's possible. I'm gonna check it too.
  • @instw0 #6876 04:32 PM, 20 Jun 2024
    and trap and breakpoint are not disabled in the hypervisor.... does windows think that the debugger is connected?
  • No, it's the case for HyperDbg. Windows (OS) doesn't have any details about the presence of a top-level (ring -1) debugger.
  • In VMI mode, traps/breakpoints are not intercepted by default.
  • @HughEverett #6879 04:35 PM, 20 Jun 2024
    In the Debugger Mode, traps/bps are intercepted.
  • @395437265 #6880 06:22 PM, 20 Jun 2024
    !monitor w 001995A4 l 4 pid 01cc script {
    if (db(001995A4) == c3){
    pause();
    }
    }

    why this script is slow as hell? it freezes debugee process. if i remove if condition its more less ok
  • Is it (the entire 4kb of the target page) located on a page with high rate of memory access?
  • @395437265 #6882 06:28 PM, 20 Jun 2024
    i think so.. there is buffer prepared for network sending
  • So, that's the reason. HyperDbg puts hook on entire 4 kb granularity of the page boundary. Not just 4 bytes. Because it's how EPT works.
  • @395437265 #6884 06:30 PM, 20 Jun 2024
    mmm
    !monitor w 001995A4 l 4 script {

    printf("BUF ACCESSED BY %s stack:%x\n",$pname,@esp);
    printf("BUF CONTENT \n");
    for (i = 0; i < 10; i++){
    printf("%x ",db(001995A4+i));
    }
    printf("\n");

    }

    this script works perfect
  • So, each access to this 4kb cause a VM-exit, but HyperDbg filters it and only show you the accesses on your target address range.
  • Why? 🤔
  • @395437265 #6887 06:31 PM, 20 Jun 2024
    i also wonder :D
  • Can you check the entire page boundary?
  • @395437265 #6889 06:32 PM, 20 Jun 2024
    all 4kb ?
  • Yes. Get a printf from it
  • And also not sure if you already knew it or not but the $context pseudo-register shows you the address of the memory accessed by the instruction that triggered the hook.

    https://docs.hyperdbg.org/commands/extension-commands/monitor#context
  • @395437265 ↶ Reply to #6890 #6892 06:37 PM, 20 Jun 2024
    what i need to do to achieve it ?
  • @395437265 #6893 06:38 PM, 20 Jun 2024
    i need to montor 001995A4+4kb ?
  • No, the page boundary start from PAGE_ALIGN(001995A4) which means you need sth like:

    00199000 l fff
  • Or from 199000 to 199fff
  • @395437265 #6896 06:42 PM, 20 Jun 2024
    aha...
    !monitor w 199000 l fff pid 1a00 script {
    printf("Buffer accessed\n");
    }
    i get a ton of accesses, but at least it shows something
  • @HughEverett #6897 06:43 PM, 20 Jun 2024
    Ah, so that's the reason
  • @HughEverett #6898 06:43 PM, 20 Jun 2024
    The rate of access is too high
  • @395437265 #6899 06:43 PM, 20 Jun 2024
    will try to add if condition now
  • @395437265 #6900 06:43 PM, 20 Jun 2024
    or will it fail ?
  • It does not make that much difference.
  • @HughEverett #6902 06:45 PM, 20 Jun 2024
    Once you try to hook 001995a4, HyperDbg will automatically hook the entire page boundary (00199000 to 00199fff) for you.
  • @395437265 #6903 06:45 PM, 20 Jun 2024
    i see..
  • It just doesn't show you once it's not within the range but not showing you doesn't mean it didn't happen.
  • @395437265 #6905 06:46 PM, 20 Jun 2024
    yes, understood
  • 21 June 2024 (4 messages)
  • @6190448061 #6906 02:05 AM, 21 Jun 2024
    群里天天都在聊啥
  • @6190448061 #6907 02:05 AM, 21 Jun 2024
    看不懂英语
  • @6190448061 #6908 02:05 AM, 21 Jun 2024
    有没有自己人讲讲😊
  • 祁 同伟
    This is an English-speaking group. Please send your messages in English only. You may use an online translator if needed.
    ___
    这是一个英语群组。请仅以英语发送您的消息。如有需要,您可以使用在线翻译。