Re: myAutoLogon

From: Tim Jowers (timjowers_at_yahoo.com)
Date: 02/19/04


Date: 19 Feb 2004 14:02:18 -0800


"Kirk Ferdmann" <kirk_ferdmann@nospam.hotmail.com> wrote in message news:<ydKdnbQaW72pWrTd4p2dnA@comcast.com>...
> "Tim Jowers" <timjowers@yahoo.com> wrote in message
> news:b1b4167f.0402100706.53bc0699@posting.google.com...
> > Has anyone seen or made an autologon program for Windows that can be
> > run from the scheduler or another program?
> >
> > I've three several approaches and wonder if anyone can assert or deny
> > any. I am running these from a Service.
> >
> > 1. Send the username and password to the "SAS Window" - the name of
> > the logon window from EnumWindows. Sending ctrl-alt-del to get the
> > window works and sending to the one to lock the workstation work fine
> > but trying keybd_event, SendInput, and PostMessage do nothing with SAS
> > Window AFAICT. This seems to be the approach used by VNC so I wonder
> > what I am missing.
>
> The key point: messages are local to a desktop. You can't send a message to
> a window on a different desktop. You probably can attach (see
> SetThreadDesktop) to the winlogon desktop from the service that runs under
> local system account (I never tried to so). You need to so before you send
> the message. This looks like a hack to me though. I'd say there is no
> guarantee that it will work in the future.
>
> > 2. Tried used LogonUser, OpenWindowStation, SetProcessWindowStation,
> > etc. and CreateProcessAsUser on explorer.exe but this does not log the
> > user in. Works fine if a user is alreadylogged in though.
>
> It does log the user on, but winlogon/GINA do more then just that: they
> modify the default desktop DACL, start userinit, switch to the default
> desktop, etc.
>
> > 3. Read up on Gina DLL and downloaded an OS one from xpasystems but
> > did not see that their Geni replacement DLL would provide what I
> > needed. Do I really have to redo the Windows security to get this to
> > work? Do I need to make a stub or do I have to make a complete Gina
> > DLL?
>
> GINA would be a recommended way to extend the existing security
> infrastructure. I guess you can get away with GINA stub in this case:
> 1. cache the WLX table
> 2. communicate from your service to the DLL using some IPC (DCOM, RPC, MMF,
> etc.)
> 3. issue your own type of SAS from the stub
> 4. handle your own SAS without forwarding it to the original GINA
> 5. for all other calls just forward the call to the original GINA
>
> -Kirk

Thanks Kirk,

  I was able to post the characters. I'll look into Gina.dll if things
develop but for now wanted to steer from something that could
potentially lock up the whole system. (Due to buggy code 8-]

        HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());

        // Switch into the Winlogon desktop
        if (!SelectDesktop("Winlogon"))
        {
                return FALSE;
        }

        // Winlogon uses hotkeys to trap Ctrl-Alt-Del...
        // HWND w=FindWindow("SAS window class","SAS window");
        SendMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT |
MOD_CONTROL, VK_DELETE));
        HWND w=NULL;
        // evil forever loop follows?
       while( NULL != (w=FindWindow(NULL,"Welcome to Windows")) )
                SendMessage(w, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL,
VK_DELETE));

        // Alt-P for password edit
        keybd_event( VK_MENU, 0, 0, NULL );
        keybd_event( VkKeyScan('p'), 1, 0, NULL );
        keybd_event( VkKeyScan('p'), 1, KEYEVENTF_KEYUP, NULL );
        keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, NULL );
        Sleep( 50 ); // maybe not needed
        
        // Enter the password
        char password[] = "not4u2no";
        for( int c=0; c<strlen(password); c++ )
        {
                keybd_event( VkKeyScan(password[c]), 1, 0, NULL );
                keybd_event( VkKeyScan(password[c]), 1, KEYEVENTF_KEYUP, NULL );
        }

        // Send the enter key and do the default (logon)
        keybd_event( VK_RETURN, 0, 0, NULL );
        keybd_event( VK_RETURN, KEYEVENTF_KEYUP, 0, NULL );

        // Switch back to our original desktop
        if (old_desktop != NULL)
                SelectHDESK(old_desktop);
Yeeha! Even works with lockut to unlock. My impression is Windows just
does the right thing... if I'm allowed to run interactively then I can
post.
Cheers,
TimJowers



Relevant Pages

  • Re: Smart card logon & remote desktop
    ... universal adoption of Windows Vista and Windows ... I am with Slav in suggesting that writing your own GINA is ... I can successfully login using my smart card, ... station does not become locked whatever the state of the "smart card ...
    (microsoft.public.security)
  • Re: myAutoLogon
    ... >> Has anyone seen or made an autologon program for Windows that can be ... Do I really have to redo the Windows security to get this to ... Do I need to make a stub or do I have to make a complete Gina ...
    (microsoft.public.win32.programmer.kernel)
  • Re: myAutoLogon
    ... >> Has anyone seen or made an autologon program for Windows that can be ... Do I really have to redo the Windows security to get this to ... Do I need to make a stub or do I have to make a complete Gina ...
    (microsoft.public.platformsdk.security)
  • Re: Hide Username when pc awakes
    ... system will begin to boot Windows XP Pro. ... There's an important element of security ... User IDs are never designed to be secret, ... Platform Software Development Kit that has GINA samples in it. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: GINA logon w/ Logon Message Error
    ... I can do a search for any GINA ... nass Wrote: ... I have two windows that pop up.... ... DLL file and its not mentioning GINA now. ...
    (microsoft.public.windowsxp.help_and_support)