Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help finding hook dll

Help finding hook dll

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomperformancehelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michaelnoam
    wrote on last edited by
    #1

    I've written a program that detects the presence of a keylogger on a process ... If I detect one - I wish to scan the process and find the location of the dll who's being using as a logger .. So far I've detected a logger - and have the list of dll's which are loaded in the process memory .. but how can I know which one is the hook dll ?? I haven't got a clue so far and whereever I look I find myself emtyhanded - can any1 please help me ?? michaelnoam@hotmail.com Michael Noam

    M 1 Reply Last reply
    0
    • M michaelnoam

      I've written a program that detects the presence of a keylogger on a process ... If I detect one - I wish to scan the process and find the location of the dll who's being using as a logger .. So far I've detected a logger - and have the list of dll's which are loaded in the process memory .. but how can I know which one is the hook dll ?? I haven't got a clue so far and whereever I look I find myself emtyhanded - can any1 please help me ?? michaelnoam@hotmail.com Michael Noam

      M Offline
      M Offline
      munawar1968
      wrote on last edited by
      #2

      Check for the following string in each of the dll's : "SetWindowsHook" You can open the dll's in notepad.exe .. most of the compiled code will be garbled .. however imported function names are always in text form.

      M 1 Reply Last reply
      0
      • M munawar1968

        Check for the following string in each of the dll's : "SetWindowsHook" You can open the dll's in notepad.exe .. most of the compiled code will be garbled .. however imported function names are always in text form.

        M Offline
        M Offline
        michaelnoam
        wrote on last edited by
        #3

        thank you for your quick answer -- however .... The string "setwindowshook"/"setwindowshookex" isn't nessecarely in the dll !! the function might have been called from an exe file (for a global hook!) and the only function in the dll is the callback function !! But thank you nevertheless .. I'll try thinking of a function which has to be in the dll ... (b.t.w. the callback function name is up to the programmer - therefor it's of no help!)

        M 1 Reply Last reply
        0
        • M michaelnoam

          thank you for your quick answer -- however .... The string "setwindowshook"/"setwindowshookex" isn't nessecarely in the dll !! the function might have been called from an exe file (for a global hook!) and the only function in the dll is the callback function !! But thank you nevertheless .. I'll try thinking of a function which has to be in the dll ... (b.t.w. the callback function name is up to the programmer - therefor it's of no help!)

          M Offline
          M Offline
          munawar1968
          wrote on last edited by
          #4

          Correct... my mistake. But the dll must call "CallNextHookEx" ..inside the callback function( whatever the programmer decides to name it). So you can search for this string instead.

          C 1 Reply Last reply
          0
          • M munawar1968

            Correct... my mistake. But the dll must call "CallNextHookEx" ..inside the callback function( whatever the programmer decides to name it). So you can search for this string instead.

            C Offline
            C Offline
            CorvetteZ0606
            wrote on last edited by
            #5

            What if they use a WndProc that doesn't directly call "CallNextHookEx"? They could pass the arguments back to the EXE file and call it from there. Also, a hook does not even need the DLL file to hook the keyboard. I've writen a hook that is completely contained in an EXE. The way it's done is to use WriteProcessMemory() to copy the WndProc function as well as a control function into the target process. (SAS Window class in my case) Then call CreateRemoteThread() to the control thread to start the hook. The control thread then hooks the keyboard through the WndProc() function. Completely contained in an EXE.

            M 1 Reply Last reply
            0
            • C CorvetteZ0606

              What if they use a WndProc that doesn't directly call "CallNextHookEx"? They could pass the arguments back to the EXE file and call it from there. Also, a hook does not even need the DLL file to hook the keyboard. I've writen a hook that is completely contained in an EXE. The way it's done is to use WriteProcessMemory() to copy the WndProc function as well as a control function into the target process. (SAS Window class in my case) Then call CreateRemoteThread() to the control thread to start the hook. The control thread then hooks the keyboard through the WndProc() function. Completely contained in an EXE.

              M Offline
              M Offline
              munawar1968
              wrote on last edited by
              #6

              Your original poser was about about locating the correct hooking DLL. I assume you inject SAS to hide taskmanager/ capture change passwords sequence/ capture ALT-CTRL-DEL. If so, then the method you use (quite tricky to code correctly) seems ok. To capture system-wide keybd input for all threads/windows(except SAS input) one can also do without DLLs in far simpler fashion.. check this http://neworder.box.sk/newsread.php?newsid=10952

              C 1 Reply Last reply
              0
              • M munawar1968

                Your original poser was about about locating the correct hooking DLL. I assume you inject SAS to hide taskmanager/ capture change passwords sequence/ capture ALT-CTRL-DEL. If so, then the method you use (quite tricky to code correctly) seems ok. To capture system-wide keybd input for all threads/windows(except SAS input) one can also do without DLLs in far simpler fashion.. check this http://neworder.box.sk/newsread.php?newsid=10952

                C Offline
                C Offline
                CorvetteZ0606
                wrote on last edited by
                #7

                munawar1968 wrote: _Your original poser was about about locating the correct hooking DLL. I assume you inject SAS to hide taskmanager/ capture change passwords sequence/ capture ALT-CTRL-DEL. If so, then the method you use (quite tricky to code correctly) seems ok. To capture system-wide keybd input for all threads/windows(except SAS input) one can also do without DLLs in far simpler fashion.. check this http://neworder.box.sk/newsread.php?newsid=10952_ I use it to capture CTRL+ALT+DEL. It works well. I've also done basically the same thing as you linked to. I use that to create hotkeys on my keyboard and mouse. It works really well. As for the OP, I don't know if there's a way to catch a keylogger since it's possible to completely contain it in an exe file. One thing you could try is to append a hook function on the end of the callback chain. In it you could peek at the stack and see if there are any hooks that aren't normally there in a clean windows installation. If you find one, you might be able to use the address on the stack to find out the thread that hooked the keyboard. note: the preceeding may or may not actually be possible to do. I haven't tried it and I'm no expert on hooks. :-)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups