{"id":19369435,"url":"https://github.com/kara-4search/fulldllunhooking_csharp","last_synced_at":"2025-04-23T15:31:35.265Z","repository":{"id":45756239,"uuid":"403322625","full_name":"Kara-4search/FullDLLUnhooking_CSharp","owner":"Kara-4search","description":"Unhook DLL via cleaning the DLL 's .text section","archived":false,"fork":false,"pushed_at":"2021-09-07T09:24:44.000Z","size":42,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T17:01:33.869Z","etag":null,"topics":["apiunhook","bypass","bypass-","bypass-antivirus","bypass-av","bypassedr","charp","csharp","edr","edr-evasion","ntdll","redteam","unhooking"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kara-4search.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-05T13:58:38.000Z","updated_at":"2025-02-19T10:26:11.000Z","dependencies_parsed_at":"2022-08-05T08:00:06.881Z","dependency_job_id":null,"html_url":"https://github.com/Kara-4search/FullDLLUnhooking_CSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kara-4search%2FFullDLLUnhooking_CSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kara-4search%2FFullDLLUnhooking_CSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kara-4search%2FFullDLLUnhooking_CSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kara-4search%2FFullDLLUnhooking_CSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kara-4search","download_url":"https://codeload.github.com/Kara-4search/FullDLLUnhooking_CSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250460414,"owners_count":21434248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apiunhook","bypass","bypass-","bypass-antivirus","bypass-av","bypassedr","charp","csharp","edr","edr-evasion","ntdll","redteam","unhooking"],"created_at":"2024-11-10T08:11:17.740Z","updated_at":"2025-04-23T15:31:34.972Z","avatar_url":"https://github.com/Kara-4search.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FullDLLUnhooking_CSharp\n\nBlog link: Not gonna update \n\n- A project fully unhook a DLL via file mapping to bypass EDR's inline hook.\n- Base on my other projects down below:\n\t1. [MappingInjection](https://github.com/Kara-4search/MappingInjection_CSharp)\n\t2. [HookDetection](https://github.com/Kara-4search/HookDetection_CSharp)\n\t3. [NewNtdllBypassInlineHook](https://github.com/Kara-4search/NewNtdllBypassInlineHook_CSharp)\n\n- Just load a fresh copy of a DLL on disk, and copy the DLL's .text section to unhook.\n- Steps\n\t1. Load a fresh new copy of ntdll.dll via file mapping.\n\t2. Get current process's hooked DLL address. (HookNtdll_address in Program.cs)\n\t3. Load the copy into memory and get a \"BaseAddress\".(FleshNtdll_address in Program.cs)\n\t4. Use the \"BaseAddress\" to find IMAGE_FILE_HEADER's address.\n\t5. Iterate all section via \"IMAGE_FILE_HEADER_instance.NumberOfSections\"\n\t6. **If a section contains \".text\", replace the whole section from the clean copy base on the section's RVA.**\n:) not my pic~\n![avatar](https://raw.githubusercontent.com/Kara-4search/ProjectPics/main/FullDLLUnhooking_unhookpic.png)\n\n- Tested on Win10/x64 works fine, to works on x86 you may need some modification about finding the IMAGE_SECTION_HEADER address.\n- After unhooking you could do other stuff. enjoy~ :)\n\n\t\n## Usage\n1. Just launch through a white-list application\n* I use another project(https://github.com/Kara-4search/HookDetection_CSharp) to test this.\n* Before unhook, detect the hooking status.\n\t![avatar](https://raw.githubusercontent.com/Kara-4search/ProjectPics/main/FullDLLUnhooking_hookdetection.png)\n\n* Unhooking the DLL\n\t![avatar](https://raw.githubusercontent.com/Kara-4search/ProjectPics/main/FullDLLUnhooking_unhooking.png)\n\t\n* Detect again\n\t![avatar](https://raw.githubusercontent.com/Kara-4search/ProjectPics/main/FullDLLUnhooking_unhook%26detection.png)\n\n- You could see the APIs have been unhooked\n- **Although highly effective at detecting functions hooked with inline patching, this method returns a few false positives when enumerating hooked functions inside ntdll.dll, such as:**\n**False Positives**\n```\n\tNtGetTickCount\n\tNtQuerySystemTime\n\tNtdllDefWindowProc_A\n\tNtdllDefWindowProc_W\n\tNtdllDialogWndProc_A\n\tNtdllDialogWndProc_W\n\tZwQuerySystemTime\n```\n**The above functions are not hooked.** \n\n## TO-DO list\n- To works on x86\n- Maybe even unhook other DLL in userland.\n\n## Update history\n- NONE\n\n## Reference link:\n\t1. https://blog.csdn.net/qq_42253797/article/details/105090943\n\t2. https://blog.csdn.net/jiangqin115/article/details/79757041\n\t3. https://blog.csdn.net/huninglei3333/article/details/78725725\n\t4. https://idiotc4t.com/defense-evasion/reload-ntdll-.text-section\n\t5. https://www.ired.team/offensive-security/defense-evasion/how-to-unhook-a-dll-using-c++\n\t6. https://makosecblog.com/malware-dev/dll-unhooking-csharp/\n\t7. http://pinvoke.net/default.aspx/Structures.IMAGE_DOS_HEADER\n\t8. https://github.com/MakoSec\n\t9. https://github.com/TheWover/DInvoke\n\t10. https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getmoduleinformation\n\t11. https://blog.csdn.net/qingzai_/article/details/76919402\n\t12. https://blog.csdn.net/tianxiayijia1998/article/details/50119435\n\t13. https://stackoverflow.com/questions/2658380/how-can-i-copy-unmanaged-data-in-c-sharp-and-how-fast-is-it/43589444\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkara-4search%2Ffulldllunhooking_csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkara-4search%2Ffulldllunhooking_csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkara-4search%2Ffulldllunhooking_csharp/lists"}