http://www.perlmonks.org?node_id=146619


in reply to Keystoke Logger

Yes, it can be done with VB.. and as far as I know, there's no way to do it that's completely Perl. Here's why..

First, you have to create a "System Wide Hook". This is done by creating a DLL. You can't do that in Perl. A "Hook" is basically a low level operation where you create a callback to an API function. In your case, you'd have to hook the Keyboard API. You can probably use Win32::API to create the app that loads the DLL, but not the DLL itself.

Pick your poision.. VB or C++ for the DLL. There's info on VB here. There's something in C++ here but it involves more than just the keyboard.

I could be wrong, but I'm pretty sure there's no pure Perl way to do it.

If you're interested in some more advanced stuff, there's also Detours Which will inject code into an apps memory space, replacing functions in the app.

Rich

Replies are listed 'Best First'.
Re: Re: Keystoke Logger
by Dog and Pony (Priest) on Feb 21, 2002 at 09:36 UTC
    If you really, really want to give it a try, it just might be possible to port the VB code via the Win32 modules, and with Perl Dev Kit you can build DLL's and other stuff from pure perl. It does cost money, but hey, so does Visual Studio.

    The only reason to go this way, however, would be pure interest, or good old "Because it's there", I think. I am a very strong believer in choosing the tools for the job, not the other way around - so I recommend that you take rchiav's advice and try to build it in some language that does it natively. VB if you have access to Visual Studio, C++ otherwise. Dev-C++, for instance, is a free IDE for C++ that can build stuff for the windows platform. It seems pretty good. UPDATE: of course, http://www.bloodshed.net is down at the moment. Here is the Google cache in the meantime.

    No matter what way you choose, however, you will have to go native on the platforms you choose - of course, you could very well write some wrapper class that uses the correct underlying modules depending on what OS it is running under, and possibly create a transparent cross-platform keylogger. Unless it is for "Because..." reasons, you have to ask yourself if it is worth it. :)


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.