How can I convert some keystrokes to other keystrokes?

I have a great idea to fool exams. My school uses a very old IDE (think Turbo Pascal, Turbo C ++ and other 80), and I would like to do the following:

  • Run my program in the background

  • intercept keystrokes, and instead of sending them directly to the screen, I would like to read a character from a pre-configured text file and send it as a pressed key. Thus, no matter what you write, the text from this file will be recorded on the screen.

I found an article by Stephen Tuuba of key records, and I think this is a good start to create this " tool," Is there a better alternative to intercept all keystrokes on the system than SetWindowsHookEx? Will antivirus code mark a suspicious program? If so, can I do anything else for this without being tagged with antivirus? Do you need administrator rights?

I know that some of you guys will say that if I showed the same interest in learning as I did to avoid learning, I would do everything, but I would like to try.

EDIT: I added generosity, I'm interested in some methods for capturing keystrokes (I'm not interested in low-level connections or advanced materials - the main ones are great), mostly method names and some documentation links. I would also like to know if they will appear as antivirus malware.

+3
source share
4 answers

THE GOD! I just found the perfect class for this the other day .. took me on to find the source:

http://www.codeproject.com/KB/cs/globalhook.aspx

I used this (and SendKeys) one only for what you need, you will need to use Handle = true to block the original message.

SendKeys ... , ... SendKeys .

SendKeys - :

    private void HookManager_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.D){
            e.Handled = true;
            SendKeys.Send("F");
        }
    }

, , prccess , , :

    /// <summary>
    /// The GetForegroundWindow function returns a handle to the foreground window.
    /// </summary>
    [DllImport("user32.dll")]
    static extern IntPtr GetForegroundWindow();

    static bool IsProcessFocused(string processname)
    {
        if (processname == null || processname.Length == 0)
        {
            throw new ArgumentNullException("processname");
        }

        Process[] runninProcesses = Process.GetProcessesByName(processname);
        IntPtr activeWindowHandle = GetForegroundWindow();

        foreach (Process process in runninProcesses)
        {
            if (process.MainWindowHandle.Equals(activeWindowHandle))
            {
                return true;
            }
        }

        // Process was not found or didn't had the focus.
        return false;
    }
+2

SetWindowsHookEx - . , , AVG, .

+2

, , - , . , , API-, .Net API WIN32. , , .

, :

, API WIN32: http://msdn.microsoft.com/en-us/library/ms645530(VS.85).aspx

WM_SYSKEYDOWN , , API * GetWindow **, , .

SendInput keybd_event [http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx] .

Google "WIN API Viewer" , API, .Net.

, , , .

+2
source

As far as I can tell, the most reliable way for keylog is to set a system interrupt (I think INT17h?), But it's pretty low considering your post is marked with C #. Go look for a suitable tool ... you will find many ...

+1
source

Source: https://habr.com/ru/post/1719786/


All Articles