• 30 July 2023 (396 messages)
  • @prekvapko #3642 12:23 PM, 30 Jul 2023
    i have win11 on debugger
  • @prekvapko #3643 12:23 PM, 30 Jul 2023
    and win10 on debugee?
  • @HughEverett #3644 12:23 PM, 30 Jul 2023
    No, that should not be a problem.
  • this one.
  • @prekvapko #3646 12:24 PM, 30 Jul 2023
    one second.. working from release because i cant build it on laptop, il lsend over debug bins
  • @prekvapko #3647 12:29 PM, 30 Jul 2023
    length received: 0x18
    buffer received seems to be 0x14
  • @prekvapko #3648 12:30 PM, 30 Jul 2023
    first packet was correct?
  • @prekvapko #3649 12:30 PM, 30 Jul 2023
    passed checksum too
  • @prekvapko #3650 12:30 PM, 30 Jul 2023
    next packets incorrect
  • @prekvapko #3651 12:30 PM, 30 Jul 2023
    next packets are the same
  • @prekvapko #3652 12:30 PM, 30 Jul 2023
    as the previous one
  • @prekvapko #3653 12:31 PM, 30 Jul 2023
    nvm
  • @prekvapko #3654 12:31 PM, 30 Jul 2023
    some packets pass through
  • @prekvapko #3655 12:31 PM, 30 Jul 2023
    just fine
  • @prekvapko #3656 12:31 PM, 30 Jul 2023
    but a few will still be invalid
  • @prekvapko #3657 12:31 PM, 30 Jul 2023
    if stepping through following are shown:
  • @prekvapko #3658 12:31 PM, 30 Jul 2023
    err, unknown packet action received from debugger
  • @prekvapko #3659 12:31 PM, 30 Jul 2023
    blank
  • @prekvapko #3660 12:31 PM, 30 Jul 2023
    err, checksum is invalid
  • @prekvapko #3661 12:31 PM, 30 Jul 2023
    err, unknown packet action received
  • @prekvapko #3662 12:31 PM, 30 Jul 2023
    4x
  • @prekvapko #3663 12:32 PM, 30 Jul 2023
    and then it stops and debuggee acts as if it's connected properly
  • @prekvapko #3664 12:32 PM, 30 Jul 2023
    dont mind the spam, it's because of bp
  • 🤨🤨
  • @prekvapko #3666 12:32 PM, 30 Jul 2023
    debuggee becomes a process zombie waiting for object i think in COM comms
  • @prekvapko #3667 12:32 PM, 30 Jul 2023
    (can't kill it or anything, have to restart)
  • It shows that the debuggee is successfully connected.
  • @HughEverett #3669 12:33 PM, 30 Jul 2023
    Now, you can't control it over the debuggger?
  • @prekvapko #3670 12:33 PM, 30 Jul 2023
    nope
  • @prekvapko #3671 12:34 PM, 30 Jul 2023
    i never get popped into the "interactable prompt" again
  • @HughEverett #3672 12:34 PM, 30 Jul 2023
    You mean CTRL+C won't work.
  • @prekvapko #3673 12:34 PM, 30 Jul 2023
    ctrl c won't work on debugee
  • @prekvapko #3674 12:34 PM, 30 Jul 2023
    on debugger it will throw exception
  • @HughEverett #3675 12:34 PM, 30 Jul 2023
    on debugger
  • @HughEverett #3676 12:34 PM, 30 Jul 2023
    not debuggee
  • @HughEverett #3677 12:34 PM, 30 Jul 2023
    Exception?
  • @HughEverett #3678 12:34 PM, 30 Jul 2023
    In visual studio?
  • @prekvapko #3679 12:34 PM, 30 Jul 2023
    yep
  • @prekvapko #3680 12:34 PM, 30 Jul 2023
    but i can continue
  • @prekvapko #3681 12:34 PM, 30 Jul 2023
    but nothing really changes
  • @HughEverett #3682 12:34 PM, 30 Jul 2023
    You have to pass it to the application
  • @HughEverett #3683 12:34 PM, 30 Jul 2023
    Did you pass it to the application?
  • @prekvapko #3684 12:35 PM, 30 Jul 2023
    i think i did
  • @HughEverett #3685 12:35 PM, 30 Jul 2023
    Because visual studio debugger first intercepts CTRL+C events
  • @prekvapko #3686 12:35 PM, 30 Jul 2023
    i told it to ignore
  • @HughEverett #3687 12:35 PM, 30 Jul 2023
    no
  • @HughEverett #3688 12:35 PM, 30 Jul 2023
    🫠
  • @HughEverett #3689 12:35 PM, 30 Jul 2023
    Okay, run the debugger process without visual studio
  • @prekvapko #3690 12:35 PM, 30 Jul 2023
    well here's the thing
  • @prekvapko #3691 12:35 PM, 30 Jul 2023
    if i do that
  • @HughEverett #3692 12:35 PM, 30 Jul 2023
    run it directly by clicking on it
  • @prekvapko #3693 12:36 PM, 30 Jul 2023
    it's gonna go into that loop again :)
  • @prekvapko #3694 12:36 PM, 30 Jul 2023
    this stuff only happens if i step through it
  • @prekvapko #3695 12:36 PM, 30 Jul 2023
    and there's delay between processed packets
  • @prekvapko #3696 12:36 PM, 30 Jul 2023
    which may be a hint as to why it's fucked?
  • @HughEverett #3697 12:36 PM, 30 Jul 2023
    🤔🤔🤔
  • @prekvapko #3698 12:36 PM, 30 Jul 2023
    anyways; i had the debugee show success messages on previous builds too
  • @prekvapko #3699 12:36 PM, 30 Jul 2023
    but i could never interact via the debugger
  • @HughEverett #3700 12:36 PM, 30 Jul 2023
    You mean the delay solved the problem?
  • @prekvapko #3701 12:36 PM, 30 Jul 2023
    I think it let a couple packets get processed correctly
  • @prekvapko #3702 12:37 PM, 30 Jul 2023
    it's weird.. it's as if there's noise happening on the com port when it's running realtime
  • @prekvapko #3703 12:37 PM, 30 Jul 2023
    but most of the packets are right if yo ustep through it
  • @prekvapko #3704 12:37 PM, 30 Jul 2023
    some are still invalid, or invalid actions
  • @prekvapko #3705 12:37 PM, 30 Jul 2023
    this is what i examined before as well
  • @prekvapko #3706 12:37 PM, 30 Jul 2023
    that the debugger was getting weird actions
  • @prekvapko #3707 12:38 PM, 30 Jul 2023
    wait
  • @prekvapko #3708 12:38 PM, 30 Jul 2023
    i think i know what's the problem
  • @prekvapko #3709 12:38 PM, 30 Jul 2023
    i have a feeling the debugger is also reading it's own messages?
  • @prekvapko ↶ Reply to #2805 #3710 12:38 PM, 30 Jul 2023
    .
  • @HughEverett #3711 12:38 PM, 30 Jul 2023
    HyperDbg just checks for the checksum, it won't request the corrupted packet again.
  • What do you mean?
  • @prekvapko #3713 12:38 PM, 30 Jul 2023
    check the message
  • @prekvapko #3714 12:38 PM, 30 Jul 2023
    those packets were received
  • @prekvapko #3715 12:38 PM, 30 Jul 2023
    on the debugger
  • @prekvapko #3716 12:38 PM, 30 Jul 2023
    on previous version
  • @prekvapko #3717 12:39 PM, 30 Jul 2023
    behavior was the same; had a checksum error and spam of invalids, if i stepped through it, i got invalid action
  • @prekvapko #3718 12:39 PM, 30 Jul 2023
    but I never saw those packets being sent from debuggee to debugger
  • @prekvapko #3719 12:39 PM, 30 Jul 2023
    only other way around
  • @prekvapko #3720 12:39 PM, 30 Jul 2023
    "DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER"
  • @prekvapko #3721 12:39 PM, 30 Jul 2023
    this packet was received on debugger
  • @prekvapko #3722 12:40 PM, 30 Jul 2023
    so it looks like the debugger is also reading it's own packets?
  • @HughEverett #3723 12:40 PM, 30 Jul 2023
    You see invalid packet error in debugger?
  • @HughEverett #3724 12:41 PM, 30 Jul 2023
    not debuggee?
  • @prekvapko #3725 12:41 PM, 30 Jul 2023
    correct
  • @prekvapko #3726 12:41 PM, 30 Jul 2023
    i never saw invalid packet errors in the debugee
  • @prekvapko #3727 12:41 PM, 30 Jul 2023
    there were never any printed errors from that side
  • @prekvapko #3728 12:42 PM, 30 Jul 2023
    besides the new listening check
  • @prekvapko #3729 12:42 PM, 30 Jul 2023
    the debugee always displayed the bottom text after some time
  • @HughEverett #3730 12:42 PM, 30 Jul 2023
    so, you mean it's a kinda loopback ?
  • @prekvapko #3731 12:42 PM, 30 Jul 2023
    that was never a problem
  • @prekvapko #3732 12:42 PM, 30 Jul 2023
    yes
  • @prekvapko #3733 12:42 PM, 30 Jul 2023
    debugee always showed that it loaded succesfully
  • @prekvapko #3734 12:42 PM, 30 Jul 2023
    debugger was always stuck
  • @prekvapko #3735 12:43 PM, 30 Jul 2023
    with a hundred err prints from the packet handler
  • @prekvapko #3736 12:43 PM, 30 Jul 2023
    once they stopped, debuggee printed success
  • This is supposed to be received.
  • @prekvapko #3738 12:44 PM, 30 Jul 2023
    DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER
  • @prekvapko #3739 12:44 PM, 30 Jul 2023
    doesn't that mean
  • @prekvapko #3740 12:44 PM, 30 Jul 2023
    nvm
  • @HughEverett #3741 12:44 PM, 30 Jul 2023
    It seems that packets relating to sending the initial symbol messages is corrupted.
  • @prekvapko #3742 12:44 PM, 30 Jul 2023
    yup, but getting rid of those packets doesn't fix it
  • @prekvapko #3743 12:44 PM, 30 Jul 2023
    and same error messages are printed
  • @prekvapko #3744 12:44 PM, 30 Jul 2023
    i tried that already
  • This means that the debuggee sends a message which should be received in debugger.
  • @HughEverett #3746 12:47 PM, 30 Jul 2023
    The thing that I can conclude here is that some packets got corrupted (probably due to the serial's physical issues), and as I HyperDbg won't re-request the corrupted packets (it assumes every packet is received successfully), then this problem happens.
  • @HughEverett #3747 12:47 PM, 30 Jul 2023
    🤔
  • @prekvapko #3748 12:48 PM, 30 Jul 2023
    I wonder if the packets are in correct order
  • @prekvapko #3749 12:48 PM, 30 Jul 2023
    when moved thru the com port
  • @ricnar #3750 12:49 PM, 30 Jul 2023
    Sorry to disturb
  • Windows will send them in order. Why not in order?
  • @ricnar #3752 12:49 PM, 30 Jul 2023
    But did you try use windbg thought the same serial connection?
  • @prekvapko #3753 12:50 PM, 30 Jul 2023
    I did not
  • @prekvapko #3754 12:50 PM, 30 Jul 2023
    Good point
  • @prekvapko #3755 12:50 PM, 30 Jul 2023
    Ill try
  • HyperDbg won't send anything simultaneously.
  • @prekvapko #3757 12:50 PM, 30 Jul 2023
    what about packets over 4096?
  • @prekvapko #3758 12:50 PM, 30 Jul 2023
    they are split, no?
  • I don't think so. Because WinDbg checks for packets to make sure they are not corrupted and if corrupted, will request to re-send the packets.
  • @HughEverett #3760 12:51 PM, 30 Jul 2023
    But, at the same time, might be a good thing to consider
  • @HughEverett #3761 12:52 PM, 30 Jul 2023
    to see whether there is an unrecoverable error in the physical serial or not. 🤔🤔🤔
  • @prekvapko #3762 01:00 PM, 30 Jul 2023
    i think i did it correctly and windbg is not connecting either?
  • @prekvapko #3763 01:01 PM, 30 Jul 2023
    nvm
  • @prekvapko #3764 01:01 PM, 30 Jul 2023
    system just froze and its loading
  • WinDbg has problem?
  • @prekvapko #3766 01:01 PM, 30 Jul 2023
    its just slow
  • @HughEverett #3767 01:01 PM, 30 Jul 2023
    🤔
  • @prekvapko #3768 01:01 PM, 30 Jul 2023
    waiting on executable search path is:
  • @prekvapko #3769 01:01 PM, 30 Jul 2023
    but same when i open dmp file
  • @prekvapko #3770 01:01 PM, 30 Jul 2023
    so i guess its just
  • @prekvapko #3771 01:01 PM, 30 Jul 2023
    Loading still
  • @prekvapko #3772 01:01 PM, 30 Jul 2023
    yep
  • @HughEverett #3773 01:01 PM, 30 Jul 2023
    What's the baudrate?
  • @prekvapko #3774 01:02 PM, 30 Jul 2023
    all good
  • @prekvapko #3775 01:02 PM, 30 Jul 2023
    115200
  • @prekvapko #3776 01:02 PM, 30 Jul 2023
    works fine
  • @prekvapko #3777 01:02 PM, 30 Jul 2023
    with windbg
  • @HughEverett #3778 01:03 PM, 30 Jul 2023
    I think I've got the problem. The problem here is that the COM connection is prone to errors (which is what we didn't considered in HyperDbg).
  • @HughEverett #3779 01:03 PM, 30 Jul 2023
    and it receives some bytes in error, and HyperDbg will lose the control.
  • @HughEverett #3780 01:04 PM, 30 Jul 2023
    Do you think the same about it?
  • @HughEverett #3781 01:04 PM, 30 Jul 2023
    🤔
  • @prekvapko #3782 01:06 PM, 30 Jul 2023
    i assume so, would make sense
  • @prekvapko #3783 01:07 PM, 30 Jul 2023
    first time using COM but we pretty much observed corrupted packet behavior
  • @prekvapko #3784 01:07 PM, 30 Jul 2023
    and we know some packets were correct
  • @prekvapko #3785 01:07 PM, 30 Jul 2023
    therefore there was probably some error in writing or reading
  • @prekvapko #3786 01:07 PM, 30 Jul 2023
    and windbg seems to compensate for that
  • Okay, thanks a lot for debugging it, I'll make changes once I'm done with current tasks and after that I will ask you to re-test it.
  • @prekvapko #3788 01:08 PM, 30 Jul 2023
    if i have some time, i'll write a test kit if i figure out how this com stuff works
  • @prekvapko #3789 01:08 PM, 30 Jul 2023
    just send data continuously, integrity check it
  • @prekvapko #3790 01:08 PM, 30 Jul 2023
    and see if this is the actual issue
  • @ricnar #3791 01:40 PM, 30 Jul 2023
    Maybe add an optional option to recheck packet?
  • I previously made something like this to recheck packets. But, then I realized it makes the connection substantially slower and it's not really needed because the VM connection is guaranteed to send/receive without error. So, it's not needed. But, yeah, kinda agree. We have to implement such an optional mechanism.
  • 31 July 2023 (64 messages)
  • @HughEverett #3793 06:51 AM, 31 Jul 2023
    Here's the preview of a new feature that will be available starting from the next version (v0.5).

    You can specify one of the following calling stages for the event:
    - All
    - Pre
    - Post

    It shows whether HyperDbg should trigger the event before the emulation, or after the emulation or both. By default and if you don't specify anything, HyperDbg will trigger the event in the 'pre' stage.

    How can it be useful? Imagine you want to see the results of a specific event like a CPUID, RDMSR, WRMSR, etc., you can see the result of the emulation based in the post calling stage (and possibly modify it).

    The main usage of it is for the '!monitor' command. For example, you're notified whenever the memory is modified at the target address. Using the 'pre' calling stage you can see the content of memory before 'MOV' instruction, and the 'post' calling stage shows the content of the memory after running 'MOV' or in other words, the modified memory contents.
  • @HughEverett #3795 06:52 AM, 31 Jul 2023
    another example:

    !monitor w $proc $proc+ff stage all script {

    if ($stage == 1) {
    curr_memory = dq($context);
    printf("current memory: %llx\n", curr_memory);
    }
    else {
    prev_memory = dq($context);
    printf("thread id: %x , from (RIP): %llx modified address: %llx, previous memory: %llx ", $tid, @rip, $context, prev_memory);
    }
    }
  • @HughEverett #3796 06:53 AM, 31 Jul 2023
    You can test it on the 'dev' branch right now. Let me know, if you guys have any feedback about these event calling stages.
  • @ricnar #3797 08:37 AM, 31 Jul 2023
    Good morning
  • @ricnar #3798 08:39 AM, 31 Jul 2023
    Can it help with the 32 bit symbols?
  • Which one? Do you mean the new 'calling stage' mechanism?
  • @ricnar #3800 08:56 AM, 31 Jul 2023
    The execution of the program when one want 32 bits symbol information
  • Do you mean the changing context problem?
  • @ricnar #3802 08:57 AM, 31 Jul 2023
    lm pid xxxx
  • @ricnar #3803 08:57 AM, 31 Jul 2023
    And the program starts execution
  • @ricnar #3804 08:58 AM, 31 Jul 2023
    The problem which show you yesterday
  • Do you need it only for the 'lm' and the '.sym reload' command?
  • @ricnar #3806 08:59 AM, 31 Jul 2023
    Yes
  • @ricnar #3807 08:59 AM, 31 Jul 2023
    If this change affect those commands
  • @ricnar #3808 09:00 AM, 31 Jul 2023
    The final concern is
  • @ricnar #3809 09:01 AM, 31 Jul 2023
    When only information about symbols is needed
  • @ricnar #3810 09:01 AM, 31 Jul 2023
    The program starts executing
  • @ricnar #3811 09:01 AM, 31 Jul 2023
    And tricks need to be applied
  • @ricnar #3812 09:01 AM, 31 Jul 2023
    Like infinite loop
  • @ricnar #3813 09:02 AM, 31 Jul 2023
    Or other monitor command
  • It's a little bit complicated. I need some time researching this to see what I can do. Currently, the way that HyperDbg reads the user-mode modules can be easily changed to run without changing the context. But, the problem here is reading the kernel modules. HyperDbg reads it by using user-mode APIs. I'm pretty sure there should be some routines to get the same result in the kernel, but the problem here is that we need to find something HIGH_IRQL compatible. Because, if HyperDbg wants to read this information from an API where it accesses a paged-out page, then as paging (RFLAG's IF bit) is not set, HyperDbg cannot read that information and it will hang the entire computer.
  • @ricnar #3815 09:08 AM, 31 Jul 2023
    But the user modules can have a flag to read only user like windbg
  • @ricnar #3816 09:09 AM, 31 Jul 2023
    Reload /user
  • The same is also applies to this command. In the 'lm' command, we physically read the target file to get the debug information (and send it to the debugger). Of course, reading file (ReadFile, CreateFile) and their equivalent kerenl-mode routines are not HIGH_IRQL compatible. So, it's not possible to read the file without changing context.
  • It's okay for user-mode modules, but where can I find the debug (symbol) information?
  • @HughEverett #3819 09:10 AM, 31 Jul 2023
    Is it also mapped in the target PE in the memory?
  • @HughEverett #3820 09:10 AM, 31 Jul 2023
    We cannot read files in VMX root-mode. We have to find other ways around it.
  • @ricnar #3821 09:11 AM, 31 Jul 2023
    The weekend I will test the new feature
  • But, just asking, why don't you reload the symbols for the target binary module once you opened it? and again next time that you open the same binary file, the symbol information remains the same.
  • Did you test this trick? 🧐
  • @HughEverett #3825 09:15 AM, 31 Jul 2023
    Because, otherwise, I don't know if the debug symbol information is available in the memory or not and if it's available, we cannot guarantee that it's not paged-out. That's why we cannot preserve the state in the '.sym' command.
  • Do you need a command for it? I mean applying this trick?
  • @ricnar #3827 09:15 AM, 31 Jul 2023
    i did that and the program starts executing too
  • @ricnar #3828 09:16 AM, 31 Jul 2023
    i send you the images
  • No, I mean once you do that and then close the program.
  • @HughEverett #3830 09:16 AM, 31 Jul 2023
    After that, run the program again, using the '.start'.
  • @ricnar #3831 09:16 AM, 31 Jul 2023
    i load the program and in the pushad i want to put a breakpiont in a user mode symbol
  • The symbol information remains the same. Am I right?
  • @ricnar #3834 09:17 AM, 31 Jul 2023
    i will try this too the next weekend
  • @ricnar #3835 09:17 AM, 31 Jul 2023
    in the week i have lot of work sorry
  • I used this trick and it probably works.
  • @ricnar #3837 09:17 AM, 31 Jul 2023
    thanks
  • That's okay 🙏
  • Once more, feel free to let me know if there are any other problems or concerns. I'll make every effort to address them all, as long as we're not limited with design constraints and limitations.
  • One important consideration here is the fundamental difference between WinDbg and HyperDbg in context preservation. When HyperDbg claims to guarantee system state preservation (context), it means that no other processes or threads will be allowed to execute. This is in contrast to WinDbg, where executing something like 'Reload /user' in WinDbg, it will continue all the cores and threads while preserving only the context of the current debugging process. This advantage in WinDbg comes from the fact that they have the ability to control the context-switching mechanism as WinDbg is compiled with the Windows Kernel source code, which is not something we can do.

    If we attempt to manipulate thread context switching in Windows to preserve context, it could lead to complications, as Windows might easily modify it, potentially breaking HyperDbg entirely. As a result, we need to find other methods of context preservation, mainly based on Intel VT-x concepts rather than relying on Windows concepts. Although we can force system to block further execution at the current RIP (context), we cannot guarantee that no other threads from different processes will arrive at the same RIP during execution.

    For instance, let's consider a scenario where we want to force the system to preserve context, and the target debuggee is running in the kernel32 function. If we prevent the system from executing any further instructions from that kernel32 function, we might disrupt other system critical processes, as they may arrive at the same location and cause system instabilities.
  • @ricnar #3842 09:45 AM, 31 Jul 2023
    if the actual thread is suspended till the command is applied can work?
  • @ricnar #3843 09:46 AM, 31 Jul 2023
    Maybe the command will not completely be applied
  • @ricnar #3844 09:46 AM, 31 Jul 2023
    With the actual thread suspended and fail
  • @ricnar #3845 09:46 AM, 31 Jul 2023
    I dont know
  • How can we suspend the thread? This is one of my big dilemmas. How to suspend a running thread?
  • @HughEverett #3847 11:25 AM, 31 Jul 2023
    Previously for the uHyperDbg we've allocated a buffer in the target process. A 'nop' loop, we set the thread RIP to that 'nop' loop and once we want to resume it, we adjust the RIP again.
  • @HughEverett #3848 11:25 AM, 31 Jul 2023
    But that's not a good idea, it can be easily detected by anti-debugging methods.
  • @ricnar #3849 02:33 PM, 31 Jul 2023
    The state of the thread is in the thread structure
  • @ricnar #3850 02:33 PM, 31 Jul 2023
    I think can be changed in the kennel structure
  • @ricnar #3851 02:33 PM, 31 Jul 2023
    I didn't try
  • @ricnar #3852 02:33 PM, 31 Jul 2023
    But all the things about thread is there
  • @ricnar #3853 02:34 PM, 31 Jul 2023
    Looking the eprocess structure
  • @ricnar #3854 02:34 PM, 31 Jul 2023
    The thread can be accesed
  • @ricnar #3855 02:34 PM, 31 Jul 2023
    I will try manually in the weekend
  • @ricnar #3856 02:35 PM, 31 Jul 2023
    And I will try if I can suspend the thread changing flags
  • @ricnar #3857 02:35 PM, 31 Jul 2023
    On the structure
  • If it's possible to suspend the thread with one flag, then it's a good way of fixing this problem. Let me know, whatever was the result.
  • @HughEverett #3859 05:28 PM, 31 Jul 2023
    Also, one thing that just came to my mind is setting an invalid RIP for the target thread and intecept and ignore page-faults on the target thread. That might be a good option for solving this issue. I'll test it.