Example #1
0
 public void unInstallKeyboardHookFromCurrentThread()
 {
     if ((this.lwhKeyboardHook != null) && (this.lwhKeyboardHook.IsInstalled))
     {
         this.lwhKeyboardHook.Uninstall();
         this.lwhKeyboardHook = null;
     }
 }
Example #2
0
        public void installKeyboardHookInCurrentThread()
        {
            if (this.lwhKeyboardHook != null)
            {
                this.unInstallKeyboardHookFromCurrentThread();
            }

            this.lwhKeyboardHook = new LocalWindowsHook(utils.LocalWindowsHook.HookType.WH_KEYBOARD);
            this.lwhKeyboardHook.Install();
            this.lwhKeyboardHook.HookInvoked += new Owasp.VulnReport.utils.LocalWindowsHook.HookEventHandler(lwKeyboardHook_HookInvoked);
        }
Example #3
0
 public void unInstallKeyboardHookFromCurrentThread()
 {
     if ((this.lwhKeyboardHook != null) && (this.lwhKeyboardHook.IsInstalled))
     {
         this.lwhKeyboardHook.Uninstall();
         this.lwhKeyboardHook = null;
     }
 }
Example #4
0
        private void lwKeyboardHook_HookInvoked(object sender, LocalWindowsHook.HookEventArgs e)
        {
            if (ccCurrentAscxControl != null && ccCurrentAscxControl.ActiveControl != null)
                if ((int)LocalWindowsHook.HookCode.HC_ACTION == (int)e.HookCode)
                {
                    long iKeyPressedValue = e.lParam.ToInt32() & ~0x7fffffff;	// I use the last bit (31) to mean KeyPressed (note that if the key is pressed continuiously, then we will have multiple events) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/keyboardproc.asp
                    switch (e.lParam.ToInt32())
                    {
                        case 2752513:
                            bLeftShiftDown = true;// Console.WriteLine("bshift down");
                            break;
                        case -1070989311:
                            bLeftShiftDown = false;// Console.WriteLine("bshift up");
                            break;
                        case 1900545:
                            bLeftCtrlDown = true;// Console.WriteLine("bCtrl down");
                            break;
                        case -1071841279:
                            bLeftCtrlDown = false;// Console.WriteLine("bCtrl up");
                            break;
                    }

                    if (iKeyPressedValue == 0)
                    {
                      //  Console.WriteLine(axCurrentAuthenticObject.Focused.ToString() + " " + axCurrentAuthenticObject.Focus());
                        char cKeyPressed = System.Convert.ToChar(e.wParam.ToInt32());

                        Control ctrControlWithFocus = getControlWithFocus(ccCurrentAscxControl.ActiveControl);
                        if (null != ctrControlWithFocus)
                        {
                            if (ctrControlWithFocus.GetType() == axCurrentAuthenticObject.GetType())
                                processAuthenticKeyboardEvent((AxXMLSPYPLUGINLib.AxAuthentic)ctrControlWithFocus, cKeyPressed, (utils.LocalWindowsHook)sender);
                        }
                        /*
                        object objToProcess = ccCurrentAscxControl.ActiveControl;
                        if ("System.Windows.Forms.SplitContainer" == objToProcess.GetType().ToString())
                        {
                            SplitContainer scSplitContainer = (SplitContainer)ccCurrentAscxControl.ActiveControl;
                            foreach (object objControlInPanel in scSplitContainer.Panel2.Controls)
                            {
                                if ("System.Windows.Forms.SplitContainer" == objControlInPanel.GetType().ToString())
                                {
                                    SplitContainer scSplitContainer_Inside = (SplitContainer)objControlInPanel;
                                    foreach (Control ctrControlInPanel2 in scSplitContainer_Inside.Panel2.Controls)
                                    {
                                        if (true == ctrControlInPanel2.ContainsFocus)
                                            Console.WriteLine(string.Format("Contains Focus: Control in {0} : {1} :{2} : {3}", scSplitContainer.Name, scSplitContainer_Inside.Name, ctrControlInPanel2.Name, ctrControlInPanel2.Focused));
                                        if (true == ctrControlInPanel2.Focused)
                                            Console.WriteLine(string.Format("Focused : Control in {0} : {1} :{2} : {3}", scSplitContainer.Name, scSplitContainer_Inside.Name, ctrControlInPanel2.Name, ctrControlInPanel2.Focused));

                                    }
                                }

                            }
                        }
                         * */
                        //Console.WriteLine(ccCurrentAscxControl.ActiveControl.GetType());
                    }
                }
        }
Example #5
0
        public void installKeyboardHookInCurrentThread()
        {
            if (this.lwhKeyboardHook != null)
                this.unInstallKeyboardHookFromCurrentThread();

            this.lwhKeyboardHook = new LocalWindowsHook(utils.LocalWindowsHook.HookType.WH_KEYBOARD);
            this.lwhKeyboardHook.Install();
            this.lwhKeyboardHook.HookInvoked += new Owasp.VulnReport.utils.LocalWindowsHook.HookEventHandler(lwKeyboardHook_HookInvoked);
        }