flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
Mat-Quasar 31 Mar 2025, 16:07
macomics wrote:
Thanks, but question follows.... How do I change the protection of memory region of another process? Code: ;BOOL VirtualProtect( ; [in] LPVOID lpAddress, ; [in] SIZE_T dwSize, ; [in] DWORD flNewProtect, ; [out] PDWORD lpflOldProtect The above will not work, because it changes its own data section, not the destination. Perhaps I do not understand about how memory works in portable executable. Please enlighten. |
|||
![]() |
|
Furs 31 Mar 2025, 18:02
Mat-Quasar wrote: Thanks, but question follows.... How do I change the protection of memory region of another process? |
|||
![]() |
|
Mat-Quasar 01 Apr 2025, 01:14
Furs wrote:
Thanks, it works. My code is working even on read-only data section of another process: Code: push [_id] push -1 push PROCESS_ALL_ACCESS call [OpenProcess] or eax, eax jz .error_3 mov dword [_hProcess], eax ; BOOL VirtualProtectEx( ; [in] HANDLE hProcess, ; [in] LPVOID lpAddress, ; [in] SIZE_T dwSize, ; [in] DWORD flNewProtect, ; [out] PDWORD lpflOldProtect ; ); invoke VirtualProtectEx, [_hProcess], 0x401000, 0x1000, PAGE_READWRITE, _OldProtect push 0 push _len push _message push 0x401000 push dword [_hProcess] call [WriteProcessMemory] |
|||
![]() |
|
Mat-Quasar 01 Apr 2025, 01:15
macomics wrote: 1) Suspend target process (all threads) This is a bit complicated for me, as I am not familiar how and why the need to suspend and resume process. Maybe later. |
|||
![]() |
|
macomics 01 Apr 2025, 07:11
In your simple crackme, the message processing loop in the MessageBox function is used to suspend the main thread. While messages are being processed in this loop, the program will not execute the code in the program code section and it can be modified. The data section will also not be accessed for data access.
To exclude partial access to data and code, you need to suspend the process (stop all his threads). Then you need to make sure that the main thread has stopped outside the modifiable range for the code (injection start address <= RIP <= injection end address). You can do without this check if you allocate a new block of memory and embed the code in it (as in my example). After that, in my example, I simply switch to my code block from anywhere in the code. I omitted in the sequence of actions the need to save registers to the state before switching. But I hope it's already obvious. Further, the embedded procedure can already work within the implementation process space. I also omitted the need to search and link code with functions in a new space. After performing all the actions, the code simply returns to the place where the old code was interrupted. Of course, it is necessary to restore the values of all registers to the state before running your procedure. |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.