Reveal the lost but saved password.

Discussion in 'MFC' started by shabbir, Feb 11, 2007.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    This article will tell you how you can retrieve the text from any window. I will use the Notepad as the sample but you can even use the password input boxes. This is not about hacking the passwords but is for retrieving you lost but saved password which is not displayed in browser. There is no standard approach for changing or retrieving the text from existing windows.

    How to go about it?



    In windows every window has handle which is assigned when process of window is created. Which is unique across all processes. Window means not only top level windows but also buttons, text boxes and other controls. Handle is required to interact with these windows.

    Finding a window handle



    There are number of ways to find the window handle. For sample application of Notepad an API FindWindow() function is useful. It takes class name and window name as parameters and returns handle to the window. Spy++ (The bundle application with the Visual studio) is a good application to find the class name.

    For Notepad the class name is 'notepad'.
    Code:
    HWND hNotepad = ::FindWindow(_T("notepad"),NULL);
    if(hNotepad == NULL)
    {
        MessageBox(_T("No Notepad present"));
    }
    There are two child windows for main notepad window. When you are using your browser with spy its your choice and discretion as to what is the window and how its rendered with toolbars, status bars and menus but in notepad one is edit box and second one is a status bar. The control ID for the edit box is 0xf and Class Name for the Edit Box is 'edit'.

    Using this control ID, child widow handle can retrieved as follows
    Code:
    HWND hEdit =  ::GetDlgItem(hNotepad,0xf);

    Get the text



    Using windows message WM_SETTEXT and WM_GETTEXT you can get the text of the notepad or set it.
    Code:
    TCHAR txtBuf[256];
    memset(txtBuf,0,sizeof(TCHAR));
    ::SendMessage(hEdit,WM_GETTEXT,(WPARAM)1024,(LPARAM)txtBuf);
    
    This can be used with the passwords fields as well.
     
  2. parvez.yu

    parvez.yu New Member

    Joined:
    Feb 14, 2008
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    thanks i needed to recover my password
     
  3. malleswari

    malleswari New Member

    Joined:
    Mar 6, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    Your information is very helpful. I have tried to retrieve control IDs for password fields in various mails like yahoo mail, gmail etc. through Spy++ tool. But I'm unable to find them. Can we get control IDs for every field through Spy++ or is there any possibility for the people who prepared the site to hide the particular information from Spy++? After a lot of trials I've got control ID for password field of Gtalk login dialog, but got empty string after sending WM_GETTEXT message. What would be the reason for it? I'm able to retrieve information of username field in the same dialog. It would be grateful if you can clarify my doubts.

    Thanks in advance,
    Malleswari.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice