• 01 July 2024 (9 messages)
  • @Satushi_nakamaro #6995 01:57 AM, 01 Jul 2024
    Joined.
  • No. Unfortunately, the stepping mechanism only works in the Debugger Mode (not VMI Mode).
  • Not sure if I understand. Can you elaborate on what to be addressed in ntoskrnl? 🤔
  • @instw0 ↶ Reply to #6997 #6998 04:16 AM, 01 Jul 2024
    is there a kernel base address variable?(example @rax)
  • You can use the 'lm' command to get the base address of different modules.

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

    Description of the 'lm' command in HyperDbg.

  • @RickLeeUS #7000 11:05 AM, 01 Jul 2024
    Joined.
  • @395437265 #7001 09:04 PM, 01 Jul 2024
    @HughEverett
    1: kHyperDbg> !monitor x 017CA56B l 10 script {
    > printf("%s %s DYN CALL TO %x\n",$date, $time, dd(eax+8));
    > }
    err, the page modification is not applied, make sure that you don't put multiple EPT Hooks or Monitors on a single page (c0000026)

    1: kHyperDbg> g
    debuggee is running...
    fffff801`17de1282 0F 01 C1 vmcall

    0: kHyperDbg> events
    no active/disabled events
  • @395437265 #7002 09:05 PM, 01 Jul 2024
    shall i remove monitor different way than event c all ?
  • @395437265 #7003 09:06 PM, 01 Jul 2024
    (i applied different script before on same addr)
  • 02 July 2024 (11 messages)
  • @mriot1real0n3 #7004 09:52 AM, 02 Jul 2024
    Joined.
  • Hi,

    sorry for the late reply

    Actually there is a design issue with HyperDbg that whenever you clear an event, it cannot be removed immediately. Instead HyperDbg first disables the event and when you continue the debuggee (using the 'g' command) it removes it from the EPT page tables. So, you need to continue debuggee before applying next EPT hook. This design issue will be solved in the future but if you cannot continue the debuggee for any reason or you need to apply your new event immediately, then you can simply disable it (event d all) and HyperDbg won't trigger it for you anymore.
  • But if you removed it and you continue debuggee and pause it again, if the error happens again (while the hook is removed) it's potentially a bug that needs to be investigated.
  • @395437265 #7008 05:57 PM, 02 Jul 2024
    yea.. i ran debugger again after clearing
  • So, it still shows this error? 🤨
  • @395437265 #7010 06:00 PM, 02 Jul 2024
    lemme try again
  • @395437265 #7011 06:11 PM, 02 Jul 2024
    yup.. its repeating
    hook 1
    1: kHyperDbg> !monitor x 760858a0 l 4 script {
    > printf("WS2SEND TRIGGERED\n");
    > }

    1: kHyperDbg> g
    debuggee is running...
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    WS2SEND TRIGGERED
    fffff804`33ca1282 0F 01 C1 vmcall

    0: kHyperDbg> event c all

    0: kHyperDbg> g
    debuggee is running...
    fffff804`33ca1282 0F 01 C1 vmcall
    events empty
    1: kHyperDbg> events
    no active/disabled events
    here i forgot to switch process
    1: kHyperDbg> !monitor x 760858a0 l 4 script {
    > printf("WS2SEND TRIGGERED AGAIN\n");
    > }
    err, invalid address (c0000005)
    address may be paged-out or unavailable on the page table due to 'demand paging'
    please refer to https://docs.hyperdbg.org/tips-and-tricks/considerations/accessing-invalid-address for further information

    1: kHyperDbg> process pid 22e0
    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!KiSwapThread+0x81b:
    fffff804`36c4164b 45 33 C0 xor r8d, r8d
    hook2
    0: kHyperDbg> !monitor x 760858a0 l 4 script {
    > printf("WS2SEND TRIGGERED AGAIN\n");
    > }
    err, the page modification is not applied, make sure that you don't put multiple EPT Hooks or Monitors on a single page (c0000026)

    0: kHyperDbg>
    Accessing Invalid Address | HyperDbg Documentation

    Considerations for accessing memory in different modes

  • Ah, got it. Could you create a GitHub issue for this? I'll try to investigate it hopefully tomorrow.
  • @395437265 #7013 06:16 PM, 02 Jul 2024
    Can't set !monitor on same addres, even after event removed. · Issue #409 · HyperDbg/HyperDbg

    hook 1 1: kHyperDbg> !monitor x 760858a0 l 4 script { printf("WS2SEND TRIGGERED\n"); } 1: kHyperDbg> g debuggee is running... WS2SEND TRIGGERED WS2SEND TRIGGERED WS2SEND TRIGGERED W...

  • 👍
  • @395437265 #7015 06:44 PM, 02 Jul 2024
    @HughEverett by the way, is monitor x implemented way different than !epthook ? !etphook is detected by antihack, !monitor is not
  • 03 July 2024 (60 messages)
  • The '!monitor' command just changes the attributes of EPT page tables but the '!epthook' changes both EPT page table attributes and puts 0xcc (int3) breakpoints, but I think your target anti-hack method tries to read/write from the page table and compute the time it takes (probably by using RDTSC/RDTSCP) instructions which is performed normally if you just use '!monitor x' but if you use '!monitor rwx' then probably it detects !monitor too. Please take a look at these documentation explanations:

    Design of !epthook:
    https://docs.hyperdbg.org/design/features/vmm-module/design-of-epthook

    Design of !monitor:
    https://docs.hyperdbg.org/design/features/vmm-module/design-of-monitor
    Design of !epthook | HyperDbg Documentation

    Design of !epthook command

  • @395437265 #7017 07:18 AM, 03 Jul 2024
    I see. Im pretty sure, that antihack finds int3, it even tells you that process was altered, probably some md5 calculations or smth like that.
  • Int3 is hidden, if it's a user-mode process check, it shouldn't notice it 🤨
  • @395437265 #7019 07:32 AM, 03 Jul 2024
    Antihack sits on ring0
  • @395437265 #7020 07:35 AM, 03 Jul 2024
    If I put either BP or !epthook after some time it pops up telling that process or antihack was altered and shuts down everything. The only thing - it's not instant, I can manage to catch some bps/hooks until that thing finds out them.
  • No difference, it shouldn't notice it from the kernel mode too.
  • @HughEverett #7022 07:37 AM, 03 Jul 2024
    It probably checks for the time it takes to respond to a memory read which will reveal that HyperDbg is monitoring that special page.
  • @HughEverett #7023 07:38 AM, 03 Jul 2024
    Otherwise, I can't think of a method to check the memory alteration for !epthook. 🤔
  • @395437265 #7024 07:47 AM, 03 Jul 2024
    Could be... well, anyway I'm fine with monitor, just takes longer time do debug
  • @395437265 #7025 08:07 AM, 03 Jul 2024
    Ah, wanted to ask, is it possible to set monitor from script(i mean its possible with current architecture)? I have dynamic calls, which I can calculate only in runtime.
  • @395437265 #7026 04:20 PM, 03 Jul 2024
    @HughEverett there is no possibility to exit script, right? like return or smth
  • It's actually possible in the VMM module to apply events immediately, but it's not exported to the user this way. Because the script engine IR generator is in the user-mode. If you want to do it, you can directly modify the source code and apply the event using a custom function. But, it's a really cool feature I think. 🤔
    I'll add it to the future to-do list but it probably won't be ready soon since it needs fundamental design changes.

    One way around it is by using:

    event (with a pause() function) + g + new event

    So, once your script is running, it continues the debuggee immediately after applying the first event and when your event executes the pause() function, the debugger is paused and the second event will be created. (If you didn't understand what I mean by this, please let me know, I could elaborate it more).
  • Exit script? What do you mean? Like disabling the event? 🤨
  • There are a couple of functions for disabling/enabling and removing or short-circuiting events here:
    https://docs.hyperdbg.org/commands/scripting-language/functions/events
    events | HyperDbg Documentation

    Functions related to events

  • You can use them along with the $event_id pseudo-register.
  • @395437265 ↶ Reply to #7028 #7031 05:34 PM, 03 Jul 2024
    no.. sample from my script:

    n = check_address(edx+c);
    k = 0;
    if (n == 1){
    printf("%s %s DYN CALL TO %x\n",$date, $time, dd(edx+c));
    k = 1;
    } else {
    printf("%s %s DYN CALL, BUT FAILED TO DECODE %x\n",$date, $time, edx+c);
    return here as memory is invalid, so no longer processing needed
    }
    if (k == 1){....
  • @395437265 #7032 05:35 PM, 03 Jul 2024
    it would improve scripting a lot i think, no additional if branches
  • Like a function return? 🤨
  • @395437265 #7034 05:43 PM, 03 Jul 2024
    yup
  • @395437265 ↶ Reply to #7027 #7035 05:46 PM, 03 Jul 2024
    i understand, but pause will loose context in this case..
  • @xmaple555 implemented the functions logic, you can use it like a function.
  • No, pause will pause the debugger immediately. Context is preserved.
  • @395437265 #7039 05:47 PM, 03 Jul 2024
    hm. in main script it told me there is error when i put return;
  • You need to ask @xmaple555 to fix it, I don't know that much about the script engine parser. 🙂🙃
  • @395437265 ↶ Reply to #7038 #7041 05:49 PM, 03 Jul 2024
    this is good to know.. bad thing those dynamic calls are calculated within one page :(
  • @395437265 ↶ Reply to #7040 #7042 05:50 PM, 03 Jul 2024
    ok, i will create issue
  • What do you mean by dynamic calls calculation? 🤨
  • @395437265 #7044 05:53 PM, 03 Jul 2024
    something like

    main:017C9D0E call dword ptr [edx+0Ch]
    and
    main:017C9BEE call dword ptr [edx+0Ch]

    those are different subs, but stays within one page, so i cant put !monitors on both calls
  • @395437265 #7045 05:53 PM, 03 Jul 2024
    edx will point to different offsets
  • @395437265 #7046 05:54 PM, 03 Jul 2024
    so the chain actually is : call dword ptr [eax+8] -> ( main:017C9D0E call dword ptr [edx+0Ch] OR main:017C9BEE call dword ptr [edx+0Ch])
  • @395437265 #7047 05:55 PM, 03 Jul 2024
    so i need to calculate the target function at the very end of this
  • @395437265 #7048 05:56 PM, 03 Jul 2024
    so far i know call dword ptr [eax+8] location, that is executed always
  • Wait, you cannot put two !monitors in one page?
  • @HughEverett #7050 06:02 PM, 03 Jul 2024
    I thought it's possible. 🤔
  • @395437265 #7051 06:03 PM, 03 Jul 2024
    lemme prepare sample
  • Not sure if I understand what you mean but !monitor receives (to/from) parameters from the script expressions:

    https://github.com/HyperDbg/HyperDbg/blob/a691c1df3be48660907fcf93840302a8c4650ff4/hyperdbg/libhyperdbg/code/debugger/commands/extension-commands/monitor.cpp#L204
    HyperDbg/hyperdbg/libhyperdbg/code/debugger/commands/extension-commands/monitor.cpp at a691c1df3be48660907fcf93840302a8c4650ff4 · HyperDbg/HyperDbg

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

  • @395437265 #7053 06:05 PM, 03 Jul 2024
    if i put monitor on whole page, it will flood with calls...
  • Which means you can calculate your addresses in global variables and use them as parameters to the !monitor.
  • @395437265 #7055 06:06 PM, 03 Jul 2024
    ok, let me explain a bit
  • E.g., !monitor .FromGlobalVar .FromGlobalVar+0x85 script { ... }
  • Wait couldn't you put multiple !monitor hooks in one page? As long as I remember it was possible. 🤔🤔🤔

    Not a big deal BTW, you can handle it through the script.

    E.g., check for your ranges within if conditions. $context pseudo-register contains the address of accessed memory address. However, I'm pretty sure we support multiple !monitor(s) on same page at some point. 🤔
  • @395437265 #7058 06:12 PM, 03 Jul 2024
    first i put monitor here main:017CA56B call dword ptr [eax+8] ; then inside script i want to do something like put monitor x eax+8 l 4 so it will follow function call, for example main:017C9D00, i know offest where dword ptr [edx+0Ch] will be called, let say 017C9D00+58, so i will put new monitor again on 017C9D00+58 and then, when im in desired function - print disasembly
  • @395437265 #7059 06:14 PM, 03 Jul 2024
    0: kHyperDbg> !monitor x 760658a0 l 4 script {
    >
    > printf("monitor");
    > }

    0: kHyperDbg> !monitor x 760658f0 l 4 script {
    >
    > printf("monitor");
    > }
    err, the page modification is not applied, make sure that you don't put multiple EPT Hooks or Monitors on a single page (c0000026)

    0: kHyperDbg>
  • @395437265 #7060 06:15 PM, 03 Jul 2024
    i will try to play with from/to params, but im afraid it will spam me with events though :(
  • Why don't you check ranges within if conditions?
  • @395437265 #7062 06:16 PM, 03 Jul 2024
    yea, going to do that
  • Like put a !monitor on an entire page, and check for the $context.
  • @395437265 #7064 06:16 PM, 03 Jul 2024
    yup, thats my idea for now :)
  • @395437265 #7065 06:16 PM, 03 Jul 2024
    thanks for advice
  • This one again could be handled from the by the method I told you earlier (pause())
  • @395437265 #7067 06:17 PM, 03 Jul 2024
    i want to do it automatically (e.g. all possible "end" calls)
  • You can use global variables to check your $context with dynamic ranges.
  • @395437265 #7069 06:18 PM, 03 Jul 2024
    there are bunch of them, like 30
  • @395437265 #7070 06:18 PM, 03 Jul 2024
    yes, will see how it helps
  • Maybe a combination of loops could help.
  • @395437265 #7072 06:20 PM, 03 Jul 2024
    if i was allowed to use monitors on same page, it would help a lot :)
  • @395437265 #7073 06:20 PM, 03 Jul 2024
    and a bit more below
  • @395437265 #7074 06:21 PM, 03 Jul 2024
    as you see those subs are pretty close to each other, so probably global variables might do the trick
  • @395437265 #7075 08:06 PM, 03 Jul 2024
    @HughEverett one more bug about monitors - when i remove monitors and .debug close, vm restarts, i think its related to that bug where cant set monitor on same adderss
  • 04 July 2024 (7 messages)
  • @instw0 #7076 05:48 AM, 04 Jul 2024
    each kernel driver has its own stack and heap or is shared with the kernel?
  • It's just the matter of handling complex logic of hooks in different pages. I'm so lazy to think about it since the algorithm of handling multiple hooks and events could become complex. 😅
  • @HughEverett #7078 04:04 PM, 04 Jul 2024
    But sure, I'll add it to the future todo list.
  • Thanks for reporting it, I'll check it.
  • I think it's shared between all drivers. I see caaes where it's not shared but if I remember it correctly, it's generally shared between different processes (but not sure). 🤔
  • @395437265 ↶ Reply to #7077 #7081 05:05 PM, 04 Jul 2024
    ok, no worries, but pls try to solve that monitor mystery :) actually after putting one monitor i shall restart vm (it restarts itself) and then put another one
  • Sure
  • 05 July 2024 (24 messages)
  • I was able to reproduce this error.

    https://github.com/HyperDbg/HyperDbg/issues/409
  • @HughEverett #7084 05:51 AM, 05 Jul 2024
    It seems that it's because HyperDbg doesn't remove the !monitor hooks correctly when the address is not available in HyperDbg's address space. 🤔
  • @HughEverett #7085 05:52 AM, 05 Jul 2024
    Since this address is only valid in the target process memory, not HyperDbg's view of memory (cr3).
  • @HughEverett #7086 08:31 AM, 05 Jul 2024
    Eduard Please switch to this branch and test it again:
    https://github.com/HyperDbg/HyperDbg/tree/fix-monitor-remove
    GitHub - HyperDbg/HyperDbg at fix-monitor-remove

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

  • Test this one and ...
  • this one.
  • @HughEverett #7089 08:32 AM, 05 Jul 2024
    Both of them should be fixed.
  • @HughEverett #7090 08:33 AM, 05 Jul 2024
    I changed the logic of clearing !monitor events.
  • @HughEverett #7091 08:34 AM, 05 Jul 2024
    Also please try to test it with different conditions and different ways if you can. At the moment it passed all of my tests but since the logic of clearing these kinds of events is changed, I might break it in some other ways, so performing a complete test would help a lot.
  • @HughEverett #7092 08:35 AM, 05 Jul 2024
    Once you've done testing it, please let me know so I'll merge it to the 'dev' branch.
  • @395437265 #7093 09:27 AM, 05 Jul 2024
    Ok, will test today
  • @395437265 #7094 11:48 AM, 05 Jul 2024
    good! i can set monitor on same address again :)
  • @395437265 #7095 11:50 AM, 05 Jul 2024
    VM also does not restart on .debug close when monitor removed
  • That's great. I merged it to the 'dev' branch now.
  • @395437265 #7097 12:54 PM, 05 Jul 2024
    thanks
  • @395437265 #7098 06:00 PM, 05 Jul 2024
    one thing, i have to run process for some while to get monitor completely removed, i cant remove and set new within one break
  • Yep, this is what I told here:
  • .
  • @395437265 #7101 06:22 PM, 05 Jul 2024
    ah.. i see, but its minor thing anyway :)
  • But generally you have tons of options, you could disable/enable events instead of clearing them. Or use a nop+jmp infinite loop at the @RIP register.
  • This one is really hard to solve. 😅

    In HyperDbg we use NMIs for halting cores. This mechanism should be changed to IPIs instead of NMIs.
    The reason why it doesn't support immediately clearing of events is because we might halt the core in the middle of handling an event and conclude to remove them. In that case, the event will trigger BSOD since its structures are freed. But, using IPIs will make sure that handling one event will be finished, and then another VM-exit happens which will halt the core.
  • Using IPIs by itself is okay but since HyperDbg is highly dependent on NMIs, changing it to IPIs will probably break lots of its functionalities. That's why I didn't dare to change it to IPIs yet. 😅
  • @395437265 #7105 06:32 PM, 05 Jul 2024
    ah.. i know only in general what are those interrupts :D not details, so i have to believe You :D
  • @395437265 #7106 07:43 PM, 05 Jul 2024
    one more issue in github :)
  • 06 July 2024 (8 messages)
  • @Reverser69 #7107 02:56 PM, 06 Jul 2024
    Anyone tried hyperdbg gui?
  • It's not ready yet. These days I'm working on it together with another team member. I'll let you guys know once it's finished.
  • @395437265 #7109 07:29 PM, 06 Jul 2024
    @HughEverett
    0: kHyperDbg> !monitor x 8ef7b0 l 1 script {
    > printf("trigger\n");
    > }
    err, invalid address (c0000005)
    address may be paged-out or unavailable on the page table due to 'demand paging'
    please refer to https://docs.hyperdbg.org/tips-and-tricks/considerations/accessing-invalid-address for further information

    0: kHyperDbg>

    0: kHyperDbg> u2 8ef7b0
    00000000`008ef7b0 83 EC 18 sub esp, 0x18
    00000000`008ef7b3 8B 44 24 1C mov eax, dword ptr ss:[esp+0x1C]
    00000000`008ef7b7 53 push ebx
    00000000`008ef7b8 55 push ebp
    00000000`008ef7b9 56 push esi
    00000000`008ef7ba 8B 30 mov esi, dword ptr ds:[eax]
    ...

    0: kHyperDbg> bp 8ef7b0
    what im doing wrong ?
    Accessing Invalid Address | HyperDbg Documentation

    Considerations for accessing memory in different modes

  • @395437265 #7110 07:30 PM, 06 Jul 2024
    (switched to process before)
  • @395437265 #7111 07:32 PM, 06 Jul 2024
    ok.. looks like its working with l 4
  • @395437265 #7112 07:36 PM, 06 Jul 2024
    ah... so:
    if i put monitor on !monitor x 017CA56B l 3 script {....
    and then run for some while and put monitor
    !monitor x 8ef7b0 l 1 script {
    results to:

    trigger
    (22:36:23.619 - core : 0 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:182) | Page-fault received, CR2: 8ef7b0
    (22:36:23.619 - core : 0 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:182) | Page-fault received, CR2: 8ef7b0
    (22:36:23.619 - core : 0 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:182) | Page-fault received, CR2: 8ef7b0
    (22:36:23.619 - core : 0 - vmx-root? yes) [+] Information (IdtEmulationhandleHostInterrupt:182) | Page-fault rece

    loop.

    any ideas ?
  • @395437265 #7113 07:37 PM, 06 Jul 2024
    !monitor x 017CA56B l 3 script { is just reading some registers
  • @395437265 #7114 07:38 PM, 06 Jul 2024
    so i need to remove 017CA56B monitor first. i definetly know that 017CA56B is calling 8ef7b0
  • 07 July 2024 (19 messages)
  • Didn't get it 🤔
    It doesn't work with 1 in the '!monitor'?
  • Could you please make a GitHub issue with the sequence of commands I could reproduce the error?
    If there are multiple ways of reproducing error (e.g., it crashes with both 1 and 3 length) make sure to include all sequences separately so all of them will be fixed.
  • @Some00ne #7117 06:21 AM, 07 Jul 2024
    Hello guys, I need some help here

    I'm trying to install EfiGaurd to disable PatchGaurd in my local machine,
    But I cannot find the option to add a boot option, or enter the boot setup.

    I disabled the secure boot and make it legacy, but the problem still the same.
  • @Some00ne #7118 06:22 AM, 07 Jul 2024
    My laptop is Lenovo IdeaPad
  • @Mattiwatti The original author is in the group but not sure if he still checks his Telegram since he rarely uses this app.
  • @Some00ne #7120 06:35 AM, 07 Jul 2024
    Yeah, the last seen is long time ago
  • @Some00ne #7121 06:36 AM, 07 Jul 2024
    Is there's any other option to disable the PatchGaurd in my local machine
  • As long as I remember, you could boot EfiGuard from a USB.
  • BTW, why do you need to disable PatchGuard? The only command that is not PatchGuard compatible in HyperDbg is the '!syscall'. Are you going to intercepts system-calls?
  • @HughEverett #7124 08:34 AM, 07 Jul 2024
    Other commands are perfectly fine with PatchGuard.
  • @Some00ne #7125 08:36 AM, 07 Jul 2024
    No actually I'm going to use the !epthook command, but I faced a problem that the command cannot identify the system call function that I passed to it, so I thought it's a problem related to PatchGaurd
  • @Some00ne #7126 08:36 AM, 07 Jul 2024
    I'm using it in the VMI, with script of course
  • Not sure if I understand it correctly. Are you going to hook system-call handler using the '!epthook' command? 🤨
  • @Some00ne ↶ Reply to #6989 #7128 08:53 AM, 07 Jul 2024
    Oh, I feel very stupid right now 😶.

    It's just I was going to apply your example that you did in this video about the epthook (that I'm mentioning) but in VMI mode. I thought that it would be ok 😶.
  • @Some00ne #7129 08:57 AM, 07 Jul 2024
    As I understand, the epthook will remove the execute permission on that page that holds the code for hooked API, so whenever the caller calls it, it will cause a vm-exit, then the Hypervisor will take control then execute my script then cause vm-continue and continue the execution normally to the guest. I don't know if I understand it right 😶.
  • This example doesn't need patchguard to be disabled. It's works even if PatchGuard is running in both the 'Debugger Mode' and the 'VMI Mode'.
  • No, actually this behavior is not for the '!epthook'. The one you mentioned is the scenario where you use the '!monitor x' command. For the '!epthook', the execution bit is in effect while the 'read/write' bits are cleared. There is a hidden breakpoint there (int3 or 0xCC) which will be triggered and handled in the hypervisor whenever the target function is executed. Please take a look at these document pages for more information:

    - https://docs.hyperdbg.org/design/features/vmm-module/design-of-epthook
    - https://docs.hyperdbg.org/design/features/vmm-module/design-of-monitor
    Design of !epthook | HyperDbg Documentation

    Design of !epthook command

  • @395437265 #7132 10:50 AM, 07 Jul 2024
    @HughEverett https://github.com/HyperDbg/HyperDbg/issues/415 i cant clearly reproduce length issue, but reproducing subsequent call monitor is easy
    Can't set monitors on subsequent calls. · Issue #415 · HyperDbg/HyperDbg

    0: kHyperDbg> x ws2_32!send 00000000`75c658a0 ws2_32!send 0: kHyperDbg> bp 75c658a0 0: kHyperDbg> g debuggee is running... breakpoint 0x1 hit ws2_32!send: 00000000`75c658a0 8B FF mov edi, ...

  • Thanks, I'll fix it.
  • 08 July 2024 (13 messages)
  • @HughEverett #7134 03:54 AM, 08 Jul 2024
    HyperDbg (@HyperDbg) on X

    🔥 Summer's heating up, and so is the learning! VMware Workstation is now free, making it the perfect time to dive into hypervisor-based reverse engineering. Check out the free HyperDbg tutorial at @OpenSecTraining: https://t.co/I1n3ggYlU9 (preferred) https://t.co/119iZNhSsA

  • None
  • I was not able to reproduce the error using your scripts in the GitHub, but it was reproduced once using this script:

    .sym reload pid 3024
    .process pid 3024
    g
    .process
    !monitor x ws2_32!send l 3 script {
    printf("pre triggered\n");
    }
    --------------------------------------
    g
    event c all
    g
    .process pid 3024
    g
    .process
    --------------------------------------
    bp ws2_32!send
    !monitor x ws2_32!send l 3 script {
    printf("pre triggered\n");
    }
    .process
  • @fuckingIdiottt #7137 06:27 AM, 08 Jul 2024
    Joined.
  • But, only one time! Couldn't reproduce it again. It seems to be race condition but in order to investigate it, it needs to be deterministically reproduced.
  • I'll keep testing the same scripts to find a way for reproducing it, meanwhile if you find a reproduceable sequence of command, pls send it here.
  • Okay, I found a sequence that reproduces the error:
    .sym reload pid 3024
    .process pid 3024
    g
    .process
    !monitor x ws2_32!send l 3 script {
    printf("pre triggered\n");
    }
    !monitor x 00354b67 l 3 script {
    printf("pre triggered\n");
    }
  • @395437265 #7141 07:04 AM, 08 Jul 2024
    Maybe setting vm to use one core might help..
  • Fixed. Check the latest 'dev' branch.
  • @395437265 #7143 08:56 AM, 08 Jul 2024
    Will check later today
  • @6579281239 #7144 09:05 AM, 08 Jul 2024
    Joined.
  • @395437265 #7145 05:09 PM, 08 Jul 2024
    all good
  • @1005535509 #7146 07:08 PM, 08 Jul 2024
    Joined.
  • 10 July 2024 (5 messages)
  • @HughEverett #7147 07:09 AM, 10 Jul 2024
    Eduard I fixed this issue, but I'm not sure if I correctly fixed it and it didn't break anything. Once you have free time, please update your 'dev' branch and make a comprehensive test on both the step-over 'p' and the step-in 't', and let me know if you find any problems.

    https://github.com/HyperDbg/HyperDbg/issues/406
    Step over hangs, if process terminates/excepts within call instruction. · Issue #406 · HyperDbg/HyperDbg

    StepOverTst.zip Steps to reproduce: .start path C:\dbg\StepOverTst.exe 2: kHyperDbg> bp 00007ff7`54c3156c 2: kHyperDbg> g debuggee is running... breakpoint 0x3 hit 00007ff7`54c3156c E8 37 03 ...

  • @6190448061 ↶ Reply to #7147 #7148 11:25 AM, 10 Jul 2024
    You did a great job.
  • @395437265 #7149 06:58 PM, 10 Jul 2024
    @HughEverett no good :( it solved the issue i mentioned, i can quit waiting with ctrl+c, but introduced another - if i put bp on call instruction and when bp is trapped, when i press p it just continues execution
  • @395437265 #7150 06:58 PM, 10 Jul 2024
    will prepare another test
  • @395437265 #7151 07:49 PM, 10 Jul 2024
    sorry.. cant reproduce stable, but i hope in real debug i will understand something
  • 11 July 2024 (11 messages)
  • @tianwang99 #7152 04:51 AM, 11 Jul 2024
    Joined.
  • @tianwang99 #7153 04:52 AM, 11 Jul 2024
    这个调试器怎么用
  • @tianwang99 #7154 04:52 AM, 11 Jul 2024
    有没有使用教程
  • @DK_ZAG #7155 06:26 AM, 11 Jul 2024
    没有
  • @tianwang99 #7156 01:00 PM, 11 Jul 2024
    视频了
  • You mean the patch (last commit) should be reverted? 🤨
  • Or it just sometimes cause errors?
  • @395437265 ↶ Reply to #7157 #7160 03:30 PM, 11 Jul 2024
    maybe put it to another branch for a while... something has changed, but i dont know exactly what
  • @395437265 #7161 03:32 PM, 11 Jul 2024
    try, for example, put bp on any call, and when its trapped, execute p
  • @395437265 #7162 03:33 PM, 11 Jul 2024
    its like sometimes it steps overs, sometimes it waits for a long time for no reason
  • 12 July 2024 (9 messages)
  • @7251314798 #7163 04:07 AM, 12 Jul 2024
    Joined.
  • It's on the 'dev' branch now. Sure we won't release (merge it to the master) if the problem is not yet fixed.
  • I'll create a GitHub issue to further investigate it. Meanwhile, if you find a deterministic way of reproducing it, pls let me know.
  • @395437265 #7166 02:34 PM, 12 Jul 2024
    sure, no prob
  • @xmaple555 #7167 09:08 PM, 12 Jul 2024
    hi guys, I'm trying to use visual studio kernel debug. But there is no current line shown (yellow arrow) in source code when hitting breakpoint
  • @xmaple555 #7168 09:09 PM, 12 Jul 2024
    only show yellow arrow to the current line in asm
  • @xmaple555 #7169 09:10 PM, 12 Jul 2024
    any solution ? 😢
  • @grootdxb #7170 11:07 PM, 12 Jul 2024
    Literally... if RSP is valid, (Assuming its some local var), then...the line you listed is simply moving 0 (zero) into the local var, and not invalid. If RSP (the stack) is jacked up, then you've got some problem elsewhere.
  • @grootdxb #7171 11:07 PM, 12 Jul 2024
    As far as "no line showing" —- likely due to optimizations..add #pragma optimize("", off) to the top of the C/CPP and compile/run again
  • 13 July 2024 (6 messages)
  • @xmaple555 #7172 04:57 AM, 13 Jul 2024
    I use Debug mode to compile . I guess the optimization is off
  • @xmaple555 ↶ Reply to #7170 #7173 04:59 AM, 13 Jul 2024
    the rsp pointing to mov dword ptr [rsp +40h],0 (UINT Index = 0)
  • @grootdxb #7174 12:35 PM, 13 Jul 2024
    Thats "mov >Q<word" — anyway, assuming RSP is not broken (corrupted or otherwise),
    thats no different than. uint64_t foo; foo=0; or uint64_t foo, uint64_t * bar=&foo; *bar=0
  • @395437265 #7175 08:24 PM, 13 Jul 2024
    @HughEverett sorry, i have no time currently, i think i can implement some deterministic test in asm, but it need me to remember asm :) i studied it almost 15 yrs ago, lot of thing have changed, chatgpt also not helping much, but i got some ideas already
  • @395437265 #7176 08:25 PM, 13 Jul 2024
    in general, it seems, that p bug is related to threading
  • @395437265 #7177 08:28 PM, 13 Jul 2024
    e.g. if new thread is spawn within call, then p cant detect ret properly, maybe some cpu optimizations, so thread is started and control flow now belongs to thread, so it wont return until thread is complete (if ever), but thats just assumptions
  • 14 July 2024 (4 messages)
  • Ok, got it. I'll check it with these new details. Thanks 👍
  • @395437265 #7179 09:43 PM, 14 Jul 2024
    @HughEverett im back to debugging and need some advice:
    main:00D6A4BD push [ebp+arg_4]
    main:00D6A4C0 push [ebp+arg_0]
    main:00D6A4C3 mov eax, [ebp+var_8]
    main:00D6A4C6 movzx eax, word ptr [eax]
    main:00D6A4C9 push eax
    main:00D6A4CA mov eax, [ebp+var_8]
    main:00D6A4CD inc eax
    main:00D6A4CE inc eax
    main:00D6A4CF push eax
    main:00D6A4D0 mov ecx, [ebp+var_8]
    main:00D6A4D0
    main:00D6A4D3 call sub_D6A5E0 ; add c3
    main:00D6A4D8 mov esp, ebp
    main:00D6A4DA pop ebp
    main:00D6A4DB retn 8
    main:00D6A4DE

    i want to main:00D6A4D3 call sub_D6A5E0 ; add c3 call 5 times instead of one with some interval, now i have:

    !monitor x 0D6A4D0 l 2 core 0 stage post script {
    if ($context == 0D6A4D0){
    for (i = 0; i < 5; i++){
    @eip = 00D6A4D3;
    }
    printf("NOW WILL CALL %x\n",eip);
    }
    }

    but it fails even on first time, when parameters are adequate (instant crash)

    i tried to use code {....} but it fails with page fault, any ideas how to do this?
  • This doesn't work as expected. You're trying to change @eip 5 times in one single execution. Doesn't make sense. 🤔

    So, it probably needs to be changed to:

    !monitor x 0D6A4D0 l 2 core 0 stage post script {
    if ($context == 0D6A4D0){
    @eip = 00D6A4D3;
    printf("NOW WILL CALL %x\n",eip);
    }
    }
  • But, that's definitely not a reason for the crash. Is it a crash of HyperDbg (BSOD)? or the target program crashes through SEH?
  • 15 July 2024 (34 messages)
  • @grootdxb #7182 12:20 AM, 15 Jul 2024
    Why the hell is it "EIP" — 32 bit!? PLLLEASE STOP with 32-bit for the love of all thats Holy and precious.
  • @395437265 ↶ Reply to #7181 #7183 04:44 AM, 15 Jul 2024
    App crash, hyberdbg is just fine. Yea, just got it that changing eip within one execution is pointless. Is there another way to call some code from script? Like xdbg script .asm sections?
  • @395437265 ↶ Reply to #7182 #7184 04:45 AM, 15 Jul 2024
    It's 32 bit app I'm trying to reverse )
  • @HughEverett #7185 05:32 AM, 15 Jul 2024
    Starting from v0.10 (the next version), HyperDbg uses @keystone_engine as its assembler. ❤️

    Thanks to our new team member @Reverser69 for adding it.

    The following commands are added to assemble virtual and physical memory:

    - https://docs.hyperdbg.org/commands/debugging-commands/a

    - https://docs.hyperdbg.org/commands/extension-commands/a
    a (assemble virtual address) | HyperDbg Documentation

    Description of the 'a' command in HyperDbg.

  • None
  • No, actually if you wanna call something within an event, it'll be called from VMX root-mode. Though, not sure if it's because you're using it in the post stage or not.

    Can you put the '!monitor' check into the next address (the address after the current @eip) and use it in the regular 'pre' stage?
  • @395437265 #7188 06:57 AM, 15 Jul 2024
    I actually want to call next instruction after monitored address.. I used stage post, because on monitored instruction parameter for call was set, so it will be set up properly..
  • I was thinking about it. The thing is, after executing a call (pre stage), an MTF is set to bring the results back (post stage).
  • This MTF will be executed exactly after one instruction. It doesn't work like a step-over, it's like a step-in.
  • @HughEverett #7191 05:29 PM, 15 Jul 2024
    So, I don't have any idea what's going on inside HyperDbg with a post stage !monitor to a CALL instruction. 🤔
  • @HughEverett #7192 05:31 PM, 15 Jul 2024
    The thing that you wanna do, seems more reasonable to be done by using an !epthook. But as probably you're dealing with an executable with lots of anti debugging methods, maybe modifying the stack and putting the return address of a CALL gadget works for this case?
  • @395437265 #7193 05:43 PM, 15 Jul 2024
    yes, thinking about playing with stack, its a pity, that code {} execution is in vmx-root...
  • @395437265 #7194 05:45 PM, 15 Jul 2024
    epthooks are always detected.. not instantly, but after some time
  • FYI, @Reverser69 is now working on bringing the support for assembly codes (keystone) within code {} statements, along with its classic hex format.
  • @395437265 #7196 05:47 PM, 15 Jul 2024
    thats good, but seems wont fix my situation :)
  • @395437265 #7197 05:48 PM, 15 Jul 2024
    i will give a try to call eb within script, maybe antidebug wont detect it instantly, so i will manage o put code back :) but there are aligment problems for sure
  • @395437265 #7198 05:57 PM, 15 Jul 2024
    @HughEverett i also wanted to ask - is it possible to implement sleep(x) in script, so it pauses execution for x miliseconds?
  • @395437265 #7199 05:58 PM, 15 Jul 2024
    like pause() wait some time and resume
  • Don't have any idea how it's implemented in the OS-level functions or how we can implement it in VMX root-mode. 🤔
    Does it need a timer configuration? 🤨
  • @395437265 #7201 06:02 PM, 15 Jul 2024
    ah... but i need it only for one process, so it wont stop execution of whole vm
  • @395437265 #7202 06:03 PM, 15 Jul 2024
    about timer - kernel32!GetTickCount might help
  • @395437265 #7203 06:03 PM, 15 Jul 2024
    (i dont know 64bit windows call)
  • @395437265 #7204 06:04 PM, 15 Jul 2024
    in assembly its quite simple to do :D
  • @395437265 #7205 06:05 PM, 15 Jul 2024
    call kernel32!SleepEx(time,0). it will break current process for time milis
  • HyperDbg is in VMX root-mode, not user-mode 😕
  • @395437265 #7207 06:08 PM, 15 Jul 2024
    i mean use sleep implementation as reference
  • There are tons of way to do this. Let me find an example from OST2 videos
  • @395437265 #7209 06:09 PM, 15 Jul 2024
    yes, maybe i missed something when watched
  • @HughEverett #7210 06:10 PM, 15 Jul 2024
    Dbg3301: HyperDbg 10 08 Ignoring Events

    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.

  • This one. You can use the short-circuiting mechanisom along with the !monitor's X attribute to pause the target process.
  • @395437265 #7212 06:12 PM, 15 Jul 2024
    i just thought about sc :)
  • Another option is using the newly added !mode command+event_sc:

    https://docs.hyperdbg.org/commands/extension-commands/mode
  • @395437265 ↶ Reply to #7208 #7215 06:16 PM, 15 Jul 2024
    ah.. i thought its related to timer somehow, of course i used monitors for pid with sc :)
  • @395437265 #7216 07:54 PM, 15 Jul 2024
    @HughEverett looks like i found solution about timer - can you pls add $timeD that returns time as milis, but not string, then by using global vars i can manage timing easily
  • 16 July 2024 (8 messages)
  • Only time in milis doesn't make sense since it will change each time you try to get it and it takes a long time to be ready (like some functions needed to be called) which makes it not a suitable case.
  • @HughEverett #7218 01:57 PM, 16 Jul 2024
    What about a function for RDTSC/P? 🤨
  • @395437265 ↶ Reply to #7217 #7219 03:52 PM, 16 Jul 2024
    i understand, my solutions would be something like:

    if ($time - .oldTime > 200){
    .oldTime = $time;
    } else {eventsc(1))
  • @395437265 #7220 03:52 PM, 16 Jul 2024
    i dont need high precision in my case
  • @395437265 ↶ Reply to #7218 #7221 03:53 PM, 16 Jul 2024
    looks interesting, i can execute it from code{} part, right ?
  • @395437265 #7222 07:02 PM, 16 Jul 2024
    @HughEverett for now, my goal is achieved :) thanks once again for this great tool. i will continue to explore this app so i can find even more exploits
  • @395437265 #7223 07:05 PM, 16 Jul 2024
    ? .count = 0;
    ? ._ecx = 0;
    ? ._eax = 0;
    ? ._ebp = 0;
    ? ._esp = 0;
    ? .run = 0;
    !monitor x D6A5E0 00D6A7AD script {


    if ($context == D6A5E0){
    ptr = dd(esp+4);
    v0 = db(ptr);
    v2 = db(ptr+2);
    if ((v0 == c1) && (v2 == b7)) {
    printf("process pid %x ctx %x \n",$pid,$context );
    ._esp = esp;
    ._ecx = ecx;
    if (.count < 5){
    printf("count less than 5, duplicating \n");
    .run = 1;
    } else {
    printf("count is 5, stop duplicating \n");
    .run = 0;
    .count = 0;
    }
    }
    }

    if ($context == 00D6A7AD && .run == 1){
    printf("process pid %x %x TURBO\n",$pid, .count);
    //eax = ._eax;
    ecx = ._ecx;
    //ebp = ._ebp;
    //esp = ._esp;
    eip = D6A5E0;
    .count = .count + 1;
    event_sc(1);
    }
    }
  • @395437265 #7224 07:05 PM, 16 Jul 2024
    it recursively calls same sub 00D6A7AD in this case 5 times, and then exits
  • 17 July 2024 (7 messages)
  • No, I mean a function in the script engine.
  • Oh, the problem is solved now?
  • @395437265 #7227 04:56 PM, 17 Jul 2024
    Timer problem not, but recursive call is
  • No problem, I could implement that, but just to confirm it with you, do you expect to sleep() and halt the entire core for a couple of seconds or do you want to make sleep() only the target thread?
  • @395437265 ↶ Reply to #7228 #7229 06:10 PM, 17 Jul 2024
    mm depends whats simplier :)
  • @395437265 #7230 06:10 PM, 17 Jul 2024
    im fine with both variants
  • @395437265 #7231 06:11 PM, 17 Jul 2024
    maybe for single thread will be more useful
  • 18 July 2024 (41 messages)
  • @7370627757 #7232 03:03 AM, 18 Jul 2024
    Joined.
  • I think for the thread variant it's better to patch the execution flow (e.g. some assembly codes at @rip or somewhere else), but for the VMX-root variant, I'll try to see what's the best method of adding such a function.
  • @HughEverett #7234 11:13 AM, 18 Jul 2024
    ? {
    void Sleep(int milliseconds) {
    .count = 0;
    .delay = milliseconds * 1000; // Convert milliseconds to microseconds

    while (.delay != 0) {
    .delay--;
    .count = 1000; // This constant can be adjusted based on the clock speed
    while (.count != 0) {
    .count--;
    // Do nothing, just busy-wait
    }
    }
    }

    Sleep(10);
    }
  • Eduard What about this one? I test it an it works perfectly. You can adjust waiting time too.
  • @395437265 #7236 11:44 AM, 18 Jul 2024
    Wow..looks interesting, already in git?
  • @395437265 #7237 11:45 AM, 18 Jul 2024
    Ah. It's script
  • @395437265 #7238 11:46 AM, 18 Jul 2024
    Will test later today
  • @395437265 #7239 01:26 PM, 18 Jul 2024
    ? .count = 0;
    ? ._ecx = 0;
    ? ._eax = 0;
    ? ._ebp = 0;
    ? ._esp = 0;
    ? .run = 0;
    !monitor x D6A5E0 00D6A7AD script {
    void Sleep(int milliseconds) {
    .count = 0;
    .delay = milliseconds * 1000; // Convert milliseconds to microseconds

    while (.delay != 0) {
    .delay--;
    .count = 1000; // This constant can be adjusted based on the clock speed
    while (.count != 0) {
    .count--;
    // Do nothing, just busy-wait
    }
    }
    }

    if ($context == D6A5E0){
    ptr = dd(esp+4);
    v0 = db(ptr);
    v2 = db(ptr+2);
    if ((v0 == c1) && (v2 == b7)) {
    printf("process pid %x ctx %x \n",$pid,$context );
    ._esp = esp;
    ._ecx = ecx;
    if (.count < 10){
    //printf("count less than 16, duplicating \n");
    .run = 1;
    } else {
    printf("count is 16, stop duplicating \n");
    .run = 0;
    .count = 0;
    }
    }
    }

    if ($context == 00D6A7AD && .run == 1){
    //printf("process pid %x %x TURBO\n",$pid, .count);
    //eax = ._eax;
    ecx = ._ecx;
    //ebp = ._ebp;
    //esp = ._esp;
    Sleep(150);
    printf("%s",$time);
    eip = D6A5E0;
    .count = .count + 1;
    event_sc(1);
    }
    }

    freezes vm :(
  • @xmaple555 #7240 03:36 PM, 18 Jul 2024
    well, I guess the problem is from the stack buffer in vmx-root
  • @xmaple555 #7241 03:37 PM, 18 Jul 2024
    @HughEverett is there one more core that run script in vmx-root ?
  • @xmaple555 #7242 03:39 PM, 18 Jul 2024
    each core should have its own stack buffer to run script
  • @xmaple555 #7243 03:41 PM, 18 Jul 2024
    so I guess that one core's stack buffer is accessed or modified by other cores at the same time
  • Each core can run its script independently. Each core has its own stack and could run script simultaneously.
  • He uses global variables. Variables start with a '.' means global variables.
  • If you don't use '.' before name of each variable, it's considered as a local variable (local to each core).
  • So, I agree with @xmaple555, if your code is supposed to run simultaneously on multiple cores, you need to use local variables instead.
  • @xmaple555 #7248 03:49 PM, 18 Jul 2024
    @sina well, I mean, this script works for one single core
    ? {
    int my_func(int var1) {
    if (var1 == 0) {
    return 0;
    }
    if (var1 == 1) {
    return 1;
    }
    return my_func(var1 - 1) + my_func(var1 - 2);
    }

    var = my_func(9);
    printf("%d\n", var);
    }

    but , there is problem for multi-core

    !epthook ntopenprocess script {
    int my_func(int var1) {
    if (var1 == 0) {
    return 0;
    }
    if (var1 == 1) {
    return 1;
    }
    return my_func(var1 - 1) + my_func(var1 - 2);
    }

    var = my_func(9);
    printf("%d, %s, %d\n", var, $pname, $core);
    }
  • @xmaple555 #7249 03:52 PM, 18 Jul 2024
    is the page faulted caused by accessing invalid memory ?
  • It should work on multi-core unless there is a error.
  • It needs to be investigated, if you have Windbg attached, you could comment this line:
  • @xmaple555 #7253 03:55 PM, 18 Jul 2024
    can we use windbg to debug hypervisor now ?
  • Once you comment #pf line, all page-faults in the VMX root-mode will be passed to the Windows handler (which is WinDbg) and you could see the exact location of the crash.
  • Yes, the main debugger we used to debug HyperDbg is windbg+serial handler of HyperDbg itself. It works on all cases.
  • Just make sure to comment this line and !analyze -v in windbg will tell you where page-fault happens.
  • @xmaple555 #7257 04:03 PM, 18 Jul 2024
    @HughEverett nice, it helps a lot for developing the hypervisor
  • @xmaple555 ↶ Reply to #7257 #7258 04:36 PM, 18 Jul 2024
    well, it seems like not able to use t or p to debug each code line
  • @xmaple555 #7259 04:36 PM, 18 Jul 2024
    but now I did it for dump crash analysis
  • Yes, it's not that straightforward. You can do single stepping but it takes a lot of time to get the execution cobtext again and sometimes it doesn't work (like after 4 or 5 single steppings).
  • I usually use our magical 'LogInfo' function which immediately sends the results over serial and it effectively works as the main printf-debugging function of the VMX root-mode.
  • @HughEverett #7262 04:43 PM, 18 Jul 2024
    'LogInfo' is guaranteed to send the results immediately without buffering them in the Debugger Mode. But, in the VMI Mode, it first buffers the logs and then sends them to the user-mode whenever it's possible.
  • @xmaple555 #7263 04:44 PM, 18 Jul 2024
    @HughEverett well, is there any tip to debug something that executes in multi-core? for now, the script engine function can work in one single core, but not really sure what happen in multi-core
  • You could run scripts within an event with a high rate of execution.

    E.g.:

    !epthook nt!ExAllocatePoolWithTag script { blah blah }

    All cores definitely run your scripts simultaneously in this special case.
  • @HughEverett #7265 04:48 PM, 18 Jul 2024
    Because the execution rate of 'nt!ExAllocatePoolWithTag' is high enough to make them run simultaneously.
  • @395437265 ↶ Reply to #7247 #7266 08:01 PM, 18 Jul 2024
    its not, process is single threaded, but i'll give a try in hour or so
  • @395437265 #7267 08:56 PM, 18 Jul 2024
    nop...

    ? .count = 0;
    ? ._ecx = 0;
    ? ._eax = 0;
    ? ._ebp = 0;
    ? ._esp = 0;
    ? .run = 0;
    !monitor x D6A5E0 00D6A7AD script {
    void Sleep(int milliseconds) {
    cntr = 0;
    int delay = milliseconds * 1000; // Convert milliseconds to microseconds

    while (delay != 0) {
    delay--;
    cntr = 1000; // This constant can be adjusted based on the clock speed
    while (cntr != 0) {
    cntr--;
    // Do nothing, just busy-wait
    }
    }
    }
    if ($context == D6A5E0){
    ptr = dd(esp+4);
    v0 = db(ptr);
    v2 = db(ptr+2);
    if ((v0 == c1) && (v2 == b7)) {
    printf("process pid %x ctx %x \n",$pid,$context );
    ._esp = esp;
    ._ecx = ecx;
    if (.count < 10){
    //printf("count less than 16, duplicating \n");
    .run = 1;
    } else {
    printf("count is 16, stop duplicating \n");
    .run = 0;
    .count = 0;
    }
    }
    }

    if ($context == 00D6A7AD && .run == 1){
    //printf("process pid %x %x TURBO\n",$pid, .count);
    //eax = ._eax;
    ecx = ._ecx;
    //ebp = ._ebp;
    //esp = ._esp;
    printf("%s",$time);
    Sleep(150);
    eip = D6A5E0;
    .count = .count + 1;
    event_sc(1);
    }
    }

    this also fails
  • @395437265 #7268 08:56 PM, 18 Jul 2024
    vm freeze
  • @395437265 #7269 08:57 PM, 18 Jul 2024
    output:
    process pid 1fa0 ctx d6a5e0
    23:54:48.793

    freeze
  • @395437265 #7270 09:05 PM, 18 Jul 2024
    ok... looks like counter and delay shall be adjusted, with original provided values it froze, when i put int delay = milliseconds * 10; it more less ok
  • @395437265 #7271 09:11 PM, 18 Jul 2024
    so, on my pc its not stable:
    ? {
    void Sleep(int milliseconds) {
    .count = 0;
    .delay = milliseconds; // Convert milliseconds to microseconds
    printf("before\n");
    while (.delay != 0) {
    .delay--;
    .count = 10; // This constant can be adjusted based on the clock speed
    while (.count != 0) {
    .count--;
    // Do nothing, just busy-wait
    }
    }
    printf("after\n");
    }

    Sleep(1);
    }

    sometimes it runs instantly, sometimes not
  • @395437265 #7272 09:12 PM, 18 Jul 2024
    i think its related to cpu clock speed - as i have dynamic frequency
  • 19 July 2024 (17 messages)
  • Yes, the CPU clock speed is an important factor in this case.
  • Is the problem solved? Or it still freezes the debuggee? 🤨
  • @xmaple555 #7275 06:00 PM, 19 Jul 2024
    I'm rewriting the parser and code execution. I think the problem will be fixed soon
  • Are you working on rewriting the parser of the script engine? Or the main parser of commands?
  • @HughEverett #7277 06:27 PM, 19 Jul 2024
    @Reverser69 finished rewriting the parser of commands yesterday.
  • Yes
  • @HughEverett #7281 06:32 PM, 19 Jul 2024
    But it's for command (libhyperdbg.dll), not the script engine.
  • @xmaple555 #7282 06:32 PM, 19 Jul 2024
    I'm current rewrite the code generation of lr parser
  • Oh, okay, you're working on parser of script engine
  • @xmaple555 #7284 06:33 PM, 19 Jul 2024
    and code execution (ScriptEngineExecute)
  • @xmaple555 #7285 06:33 PM, 19 Jul 2024
    yes
  • @HughEverett #7286 06:33 PM, 19 Jul 2024
    It's okay, he was working on something else.
  • @HughEverett #7287 06:33 PM, 19 Jul 2024
    No collision
  • @HughEverett #7288 06:33 PM, 19 Jul 2024
    👍
  • @395437265 ↶ Reply to #7274 #7289 09:10 PM, 19 Jul 2024
    its not freezing, but works unstable, even with same values, interval is different
  • 20 July 2024 (10 messages)
  • So I assume that, this is not a problem with HyperDbg?
  • @HughEverett #7291 09:11 AM, 20 Jul 2024
    Since the interval depends on CPU clock speed
  • @HughEverett #7292 09:13 AM, 20 Jul 2024
    Also, we need to have a discussion about this one.
  • @HughEverett #7293 09:14 AM, 20 Jul 2024
    It's a new change proposed by @xmaple555.

    I'm not sure if it's a good idea of having a limitation for the number of IRs that could be executed.
  • @HughEverett #7294 09:14 AM, 20 Jul 2024
    What do you guys think ? Does anybody have any idea regarding this one?
  • @HughEverett #7296 09:14 AM, 20 Jul 2024
    🤔
  • @395437265 ↶ Reply to #7290 #7297 09:27 AM, 20 Jul 2024
    Mm I would say it is.. as sometimes with minimal interval it returns instantly, sometimes waits up to 10 seconds, in the sample you provided, it never waited for 10 milliseconds, but much longer
  • @395437265 #7298 09:29 AM, 20 Jul 2024
    Maybe not with hyperdbg but scripting engine
  • @395437265 #7299 09:54 AM, 20 Jul 2024
    i will try to apply interlocked exchange later, and see if it helps
  • @395437265 #7300 09:55 AM, 20 Jul 2024
    but as i said, i just ran example, and wait time is different :(
  • 21 July 2024 (26 messages)
  • I've looked into the sleep implementation in the OS, and it seems quite complex because it uses an external device timer. ☹️
  • @395437265 ↶ Reply to #7301 #7302 07:46 AM, 21 Jul 2024
    That's no good... maybe some vmware stuff(like drivers) can help?
  • @395437265 #7303 11:56 AM, 21 Jul 2024
    KeDelayExecutionThread function (wdm.h) - Windows drivers

    The KeDelayExecutionThread routine puts the current thread into an alertable or nonalertable wait state for a specified interval.

  • @xmaple555 #7304 12:08 PM, 21 Jul 2024
    it requires IRQL level
  • @395437265 #7305 12:35 PM, 21 Jul 2024
    https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-kequerysystemtime-r1 this? If we have system time, implementation of sleep shall not be complex
    KeQuerySystemTime function (wdm.h) - Windows drivers

    The KeQuerySystemTime routine obtains the current system time.

  • VMware? 🤨
  • Exactly. In the VMX root-mode, interrupts are masked (RFLAG.IF is cleared).
  • This is exactly same as the function we used for the $time pseudo-register.
  • @395437265 ↶ Reply to #7308 #7309 04:48 PM, 21 Jul 2024
    ok.. but I asked for $time register to return time as milis :) then by using global vars i can implement smth looking as sleep
  • @395437265 ↶ Reply to #7306 #7310 04:49 PM, 21 Jul 2024
    i thought maybe there is some vmware API, didnt studied that question deep
  • I think you can use this $time for this purpose too. By default, it returns a pointer to a string.
  • @HughEverett #7312 05:15 PM, 21 Jul 2024
    Also, dslang supports dereferencing (memory access) through & operator.
  • @395437265 #7313 05:21 PM, 21 Jul 2024
    i also thought about another idea:

    is it possible to write some value inside memory and then read it from script, lets say:

    !monitor .... code {

    push rdx;
    push rax;
    rdtsc;
    mov [vmx_root_offset_any], rax ;lo bits
    mov [vmx_root_offset_any+8], rdx ;hi bits
    ret
    }
    script {
    n = dq(vmx_root_offset_any);
    k = dq(vmx_root_offset_any+8);
    rsp = rsp + 16; //move esp back
    // do something


    }
  • @xmaple555 #7314 05:22 PM, 21 Jul 2024
    I think I can include the inline asm to script-engine
  • @395437265 #7315 05:23 PM, 21 Jul 2024
    it would be perfect actually :)
  • @395437265 ↶ Reply to #7312 #7316 05:24 PM, 21 Jul 2024
    but $time returns pointer to string.. of course i can modify hyperdbg source code as well
  • @395437265 ↶ Reply to #7314 #7317 05:26 PM, 21 Jul 2024
    just thinking how to deal with this situation

    !monitor .... code {
    this i executed in vm root, with kernel addressspace
    push rdx;
    push rax;
    rdtsc;
    mov [vmx_root_offset_any], rax ;lo bits
    mov [vmx_root_offset_any+8], rdx ;hi bits
    ret
    }
    script {
    this executed in process address space
    n = dq(vmx_root_offset_any);
    k = dq(vmx_root_offset_any+8);
    rsp = rsp + 16; //move esp back
    // do something


    }

    correct me if im using bad terminology :)
  • It would be great if we can have such a feature. You can use the Keystone disassembler that is recently added to the project.
  • You can add (+x) number to the time and read it using db, or dd. Like db($time+123)
  • @xmaple555 #7320 05:55 PM, 21 Jul 2024
    not a problem. BTW I plan the next update will be variable type, array, pointer, deference, and followed by struct
  • @supermanfranky #7321 05:59 PM, 21 Jul 2024
    Joined.
  • @supermanfranky #7322 06:04 PM, 21 Jul 2024
    Hey! Junior Vulnerability Researcher and Reverse Engineer here who's been really liking HyperDbg! Any way I could help contribute!
  • Hi and welcome to the group. 🤗
    Tomorrow, we'll release HyperDbg v0.10.
    Along with that, I'll create a list of potential tasks that you (and anyone else) could add to the HyperDbg. I'll notify you when the list is ready (hopefully tomorrow).
  • @HughEverett #7324 06:23 PM, 21 Jul 2024
    Eduard please don't forget to check this as well.

    https://github.com/HyperDbg/HyperDbg/issues/417

    If it's solved, please close this issue.
    Script with functions going crazy · Issue #417 · HyperDbg/HyperDbg

    !monitor x 00D6A712 l 2 script { void printMemDD(int addr){ dlen = 20; for (i = 0; i < dlen; i = i + 4){ printf("%x ", dd(addr + i)); } printf("\n"); return; } void printMemB...

  • @supermanfranky #7325 06:24 PM, 21 Jul 2024
    Thanks! Good timing on my part lol!
  • @395437265 ↶ Reply to #7324 #7326 06:57 PM, 21 Jul 2024
    sure
  • 22 July 2024 (24 messages)
  • @HughEverett #7327 04:47 AM, 22 Jul 2024
    Happy to announce @HyperDbg v0.10! 🎉🎊✨

    This version comes with numerous bug fixes and stability improvements, plus new features like running assembly code directly in the events (VMX root-mode) and two new commands.

    Check out the latest version: https://github.com/HyperDbg/HyperDbg/releases

    For more information,

    Assembly codes in conditions:
    - https://docs.hyperdbg.org/using-hyperdbg/prerequisites/how-to-create-a-condition

    Assembly codes in code sections:
    - https://docs.hyperdbg.org/using-hyperdbg/prerequisites/how-to-create-an-action

    Assemble virtual address:
    - https://docs.hyperdbg.org/commands/debugging-commands/a

    Assemble physical address:
    - https://docs.hyperdbg.org/commands/extension-commands/a
    Releases · HyperDbg/HyperDbg

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

  • @HughEverett #7329 04:48 AM, 22 Jul 2024
    # Changelog

    ## Added
    - Support using assembly conditions and codes in all events
    - Added the assembler command 'a' for virtual memory
    - Added the assembler command '!a' for physical memory
    - Providing a unified SDK API for reading memory in the VMI Mode and the Debugger Mode
    - Export SDK APIs for reading/writing into registers in the Debugger Mode
    - Export SDK API for writing memory in the VMI Mode and the Debugger Mode
    - Export SDK API for getting kernel base address
    - Export SDK API for connecting to the debugger and from debuggee in the Debugger Mode
    - Export SDK API for starting a new process
    - Add and export SDK API for unsetting message callback
    - Event commands are coming with more examples regarding scripts and assembly codes
    - Add message callback using shared memory
    - Add maximum execution limitation to the script IRs (#435)

    ## Changed
    - Fix clearing '!monitor' hooks on a different process or if the process is closed (#409)
    - Fix triggering multiple '!monitor' hooks with different contexts (#415)
    - Fix the problem of repeating commands once kHyperDbg is disconnected
    - Fix step-over hangs if the process terminates/excepts within call instruction (#406)
    - Fix crash on editing invalid physical addresses (#424)
    - Fix exporting VMM module load and install it in the SDK
    - Fix function interpretation issues and update the parser and the code execution (#435)
  • Thanks to @xmaple555 and @Reverser69 for their great contributions in this release. ❤️
  • @Reverser69 ↶ Reply to #7330 #7331 04:50 AM, 22 Jul 2024
    Right on
  • None
  • @HughEverett #7333 07:40 AM, 22 Jul 2024
    Here is an updated list of tasks that needs contributions from the community members:

    https://github.com/HyperDbg/HyperDbg/blob/dev/CONTRIBUTING.md
    HyperDbg/CONTRIBUTING.md at dev · HyperDbg/HyperDbg

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

  • cc @supermanfranky
  • @supermanfranky #7335 01:08 PM, 22 Jul 2024
    Thanks!
  • @supermanfranky #7336 01:12 PM, 22 Jul 2024
    Congrats on the release!
  • @frendguo #7337 03:07 PM, 22 Jul 2024
    Joined.
  • @S4l3H ↶ Reply to #7320 #7339 05:53 PM, 22 Jul 2024
    I just wonder whether there is any plan for adding something like import or #include to the dslang scripts?
  • This one is really something if it could be added! @xmaple555 🤔
  • @HughEverett #7341 05:55 PM, 22 Jul 2024
    My first idea is passing a pointer to a buffer where links for the buffers of scripts are stored.
  • @HughEverett #7342 05:56 PM, 22 Jul 2024
    This way, we could even pre-load a bunch of standard scripts.
  • @xmaple555 #7343 05:56 PM, 22 Jul 2024
    if you mean include the C file to the script-engine, that must be really difficult to do it
  • No, I think he means include of .ds files.
  • @HughEverett #7345 05:57 PM, 22 Jul 2024
    C files needs compiler which is really hard to do.
  • @HughEverett #7346 05:58 PM, 22 Jul 2024
    But, .ds files might be good if we could implement functions in it and import it to other .ds files.
  • @HughEverett #7347 05:58 PM, 22 Jul 2024
    Not sure if it's possible 🤔
  • @HughEverett #7348 05:59 PM, 22 Jul 2024
    We could start implementing standard script functions.
  • @xmaple555 #7349 05:59 PM, 22 Jul 2024
    😅, the current grammar of the script-engine is free ambiguous, so it is not difficult like C to implement it
  • @HughEverett #7350 06:03 PM, 22 Jul 2024
    I think some functionalities like Windows-specific routines (and in the future other functions) that needs interaction with symbols (structure offsets and function addresses) are better to be implemented in the script-engine.
  • @HughEverett #7351 06:04 PM, 22 Jul 2024
    This way, we could add lots of cool functions for modifying Windows as a standard library (say Windows.ds), and then import it and use it in the scripts.
  • This would be super cool! 👌🤔
  • 23 July 2024 (6 messages)
  • @Rootasuser #7353 08:18 AM, 23 Jul 2024
    Joined.
  • @b00tkitism #7354 08:20 AM, 23 Jul 2024
    Joined.
  • @badberake #7355 08:20 AM, 23 Jul 2024
    Joined.
  • @6388720268 #7356 08:31 AM, 23 Jul 2024
    Joined.
  • @piranidev #7357 09:03 AM, 23 Jul 2024
    Joined.
  • @HughEverett #7359 11:13 AM, 23 Jul 2024
    Joined.
  • 24 July 2024 (8 messages)
  • @ChellamRamesh #7374 12:55 AM, 24 Jul 2024
    Joined.
  • @Yosefso #7375 07:15 AM, 24 Jul 2024
    Joined.
  • @Chesssecond #7376 12:31 PM, 24 Jul 2024
    Joined.
  • @HAMISHEGI #7377 02:00 PM, 24 Jul 2024
    Joined.
  • @6169881296 #7378 05:13 PM, 24 Jul 2024
    Joined.
  • @Devansh_Mittai #7379 05:37 PM, 24 Jul 2024
    Joined.
  • @SavithaBalaj #7380 06:14 PM, 24 Jul 2024
    Joined.
  • @Karen_Webe #7381 06:30 PM, 24 Jul 2024
    Joined.
  • 25 July 2024 (2 messages)
  • @HanFei1777 #7382 10:53 AM, 25 Jul 2024
    Joined.
  • @5920057923 #7383 11:38 AM, 25 Jul 2024
    Joined.
  • 26 July 2024 (17 messages)
  • @instw0 #7384 04:59 AM, 26 Jul 2024
    hyperdbg v 1.0 support trapflag in cpuid?
  • If you mean v0.10, then unfortunately no! ☹️
  • @HughEverett #7386 07:50 AM, 26 Jul 2024
    I spent time on finding the issue but it seems that it needs more investigation, I added it to the contributing list (to-do) list.
  • @instw0 #7387 07:57 AM, 26 Jul 2024
    there was a flag-cpuid branch, can it be returned somehow?
  • Is it deleted? 🤨
  • Forgot to say that #HyperDbg v0.10 also supports event forwarding to external binary (DLLs) modules.

    - If you want to use HyperDbg events in your function, check out the guide:
    https://docs.hyperdbg.org/tips-and-tricks/misc/event-forwarding

    - Rust/C++ implementations are available here:
    https://github.com/HyperDbg/event-forwarding-examples
    Event forwarding | HyperDbg Documentation

    Brief explanation about Event Forwarding Mechanism

  • @instw0 #7391 08:10 AM, 26 Jul 2024
    there seemed to be a cpuid-trapflag project...
  • @243494329 #7392 11:36 AM, 26 Jul 2024
    Joined.
  • @instw0 #7393 01:16 PM, 26 Jul 2024
    is there a way to return the cpuid with trap.flag?
  • Ah, it seems to be deleted. 😔
  • What do you mean by return trap flag from cpuid? 🤨
  • @7058036947 #7396 05:57 PM, 26 Jul 2024
    Joined.
  • @instw0 ↶ Reply to #7395 #7397 05:59 PM, 26 Jul 2024
    emote project
  • @instw0 #7398 05:59 PM, 26 Jul 2024
    Can it be returned?
  • In the Debugger Mode, if the debugee is paused, you could view/modify the trap flag using the 'r' command.
  • @HughEverett #7400 06:17 PM, 26 Jul 2024
    It's also accessible through the script engine using @rflag register.
  • 27 July 2024 (2 messages)
  • @nitcat #7401 02:29 AM, 27 Jul 2024
    Joined.
  • @invlpg #7405 05:49 PM, 27 Jul 2024
    @HughEverett ^^
  • 28 July 2024 (4 messages)
  • @nitcat #7406 12:04 AM, 28 Jul 2024
    Why are you everywhere @invlpg
  • @instw0 ↶ Reply to #7399 #7407 04:25 AM, 28 Jul 2024
    there was a solution to this problem in the cpuid_flags_tf branch https://howtohypervise .blogspot.com/2019/01/a-common-missight-in-most-hypervisors.html . Is it possible to return this branch?
  • It seems that it's deleted.

    https://stackoverflow.com/questions/2613903/does-deleting-a-branch-in-git-remove-it-from-the-history
    Does deleting a branch in git remove it from the history?

    Coming from svn, just starting to become familiar with git. When a branch is deleted in git, is it removed from the history? In svn, you can easily recover a branch by reverting the delete opera...

  • I don't remember what I did on that branch, did you clone it somewhere in your computer?
  • 29 July 2024 (10 messages)
  • @HughEverett #7411 04:34 AM, 29 Jul 2024
    Hi everyone!

    We've updated the list of things for which we need contributions from the community in HyperDbg!

    If you have some free time, you're more than welcome to join and contribute to the HyperDbg debugger. 😊✨

    Check it out:

    https://github.com/HyperDbg/HyperDbg/blob/dev/CONTRIBUTING.md
  • None
  • @instw0 ↶ Reply to #7410 #7413 04:59 AM, 29 Jul 2024
    there is no copy of the source code left(((
  • @supermanfranky #7414 05:26 AM, 29 Jul 2024
    Is there any desire to detect and inspect undocumented windows kerbel structures.

    Such as these: https://www.vergiliusproject.com/kernels/x64
    Vergilius Project

    Take a look into the depths of Windows kernels and reveal more than 60000 undocumented structures.

  • @supermanfranky #7415 05:28 AM, 29 Jul 2024
    Also, is there desire to be able to print the dump the page table for a process?
  • @HyperDbgBot #7416 b o t 05:29 AM, 29 Jul 2024
    [discord] <oi_its_me> Test
  • What do you mean by inspecting kernel structures?

    Is it anything other than the 'struct' command?

    https://docs.hyperdbg.org/commands/debugging-commands/struct
  • Dump of all page tables?

    HyperDbg already shows the page table entries, but won't dump them. You could use a combination of the '!pte' command + the '.dump' command to perform that.

    https://docs.hyperdbg.org/commands/extension-commands/pte

    https://docs.hyperdbg.org/commands/meta-commands/.dump
    !pte (display page-level address and entries) | HyperDbg Documentation

    Description of the '!pte' command in HyperDbg.

  • @7125764635 #7419 08:52 PM, 29 Jul 2024
    Joined.
  • @darw1n #7420 10:25 PM, 29 Jul 2024
    Joined.
  • 30 July 2024 (1 messages)
  • @nsky99 #7421 05:33 PM, 30 Jul 2024
    Joined.