Hi so I am pretty decent at coding in c++, but I never did any hooking. So I just wanted to ask if anyone could recommend some good articles. 🤝
|
C
Hooking winapi + hooking in general |
(Jul 11, 2019 01:58 PM)Sai Hung Wrote: You better good with Libminhook , i have used it once (libminhook.x86.lib) good library to hook 32 bit process, cannot say for x64 So I never reverse engineered anything really... Btw I would like to learn to code the whole thing myself so pref. no libraries besides default ones
Jul 12, 2019 04:17 AM
(This post was last modified: Jul 12, 2019 04:18 AM by YouthInAsia.)
A hook is easy you don't need an engine
patch the first five+ bytes with a jmp + offset to an address it's common sense (Jul 12, 2019 04:17 AM)YouthInAsia Wrote: A hook is easy you don't need an engine Initially i never knew that, i have to be very honest. hence i started using Detour libraries. even until now, i dont have a good tutor whos gonna show me things in RE. I learnt everything on here , i even misfire most times. If i knew how to count byte instructions manually without the use of detour libs , i think i am fine. Can I pm you for that? (Jul 12, 2019 03:00 PM)Sai Hung Wrote: Initially i never knew that, i have to be very honest. hence i started using Detour libraries. even until now, i dont have a good tutor whos gonna show me things in RE. I learnt everything on here , i even misfire most times. Yup if you just screen shot the instruction you want to hook I can tell you how many bytes to patch but but any disassembler will show you by screen shot I mean screenshot the disassembly of the instruction
Ok so I am currently trying to Hook NtQuerySystemInformation. I managed to write a function that should be able to replace it, and a dll injector that can inject 64bit and 32bit dlls with no issue or crash. My main issue right now is: How do I replace the real NtQuerySysteminformation function with mine? I looked at a lot of github code (tried most) and I never am able to properly hook anything with it (taskmanager just crashes).
(Jul 13, 2019 07:03 AM)lo0sr Wrote: Ok so I am currently trying to Hook NtQuerySystemInformation. I managed to write a function that should be able to replace it, and a dll injector that can inject 64bit and 32bit dlls with no issue or crash. My main issue right now is: How do I replace the real NtQuerySysteminformation function with mine? I looked at a lot of github code (tried most) and I never am able to properly hook anything with it (taskmanager just crashes). you don't make a hook to replace an entire function... especially not ntquerysysteminformation.
Jul 13, 2019 07:24 AM
(This post was last modified: Jul 13, 2019 07:37 AM by lo0sr.)
(Jul 13, 2019 07:11 AM)int main() Wrote: you don't make a hook to replace an entire function... especially not ntquerysysteminformation. Code #define _CRT_SECURE_NO_WARNINGSThis is the function that I wrote
Jul 13, 2019 12:01 PM
(This post was last modified: Jul 13, 2019 01:58 PM by Sai Hung.)
You did not show us your hook function .
Hooking is not just as you think it is. after replacing the jmp bytes of instruction, you would still need a function to be redirected to your own function after which, it goes back to the original function. Have a good look at this Code int WINAPI DetourMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)This is a hook (Detoured Function) which should be called after you have replaced the 5 byte jmp instruction now when you want to call it You do something like this Code MH_CreateHookApiEx(L"user32", "MessageBoxW", &DetourMessageBoxW, &fpMessageBoxW) != MH_OK)I am using Libminhook here You can read more here MinHook - The Minimalistic x86/x64 API Hooking Library - CodeProject (Jul 13, 2019 08:11 PM)doxerhacker Wrote: Why do people use libraries for trivial inline hooks? It baffles my mind. Do you guys not understand assembly? Not every one does sir. Rather than make fun of people, start a thread to show how to do RE and calculate bytes . More popularity and respect awaits you, than asking this question you just asked. Its a forum, You too can contribute :D
Jul 14, 2019 01:23 PM
(This post was last modified: Jul 14, 2019 01:24 PM by doxerhacker.)
(Jul 14, 2019 04:50 AM)Sai Hung Wrote: Not every one does sir. Rather than make fun of people, start a thread to show how to do RE and calculate bytes . Calculating instruction lengths can be done in three ways: - Using a length disassembler engine - Writing your own length disassembler engine - Hardcode function prologues (or any segment of the procedure for that matter) (assuming they are the same across different library versions) The former is trivial but could be used as a signature based scan for AV solutions.
Jul 14, 2019 03:23 PM
(This post was last modified: Jul 14, 2019 03:24 PM by Sai Hung.)
(Jul 14, 2019 01:23 PM)doxerhacker Wrote: Calculating instruction lengths can be done in three ways: No time to code my own LDE at this Moment , i wish i had someone who can give a guide on that. i dont know anything about Intel XED, sorry. like i said, most things i know on here i had to read alone :D I used HDE (Hacker Disassembly Engine) as my own LDE sometime when i tried to make an x86 Detour Engine so i could try Heavens gate much later on. gave me some issues and hence i practically resolved to using the Disassemblers like IDA and the likes to calculate and then hard code the byte of instruction .... One problem... I dont have a guide to school me thru RE fully. |
|
|

