Is it possible to replace the Mac login screen?

Deadly 提交于 2019-11-29 02:26:09

The login window application is defined as part of the launchd configuration in /System/Library/LaunchDaemons/com.apple.loginwindow.plist.

In theory you can replace the login window with your own but I don't know what you have to do in the new app - I think the login window does a bit more then authentication and setting up the user session -> amongst others, it looks like its doing some launchd related chores.

I've compiled an application that calls CGSCreateLoginSession and once you run it it transitions to the login window via the rotating cube. I imagine this is why it requires CoreGraphics - it's just a graphics function that calls logout at the end.

You could try an InputManager and see it the login window loads the code -> if it does, you could then alter the loginwindow NIB (LoginWindowUI.nib) and add some buttons to display a new window with the user browser. Once the student chooses a picture of him/herself you could autofill the username and password fields in the loginwindow.

Node this is all theory, and it looks very fragile and unsafe.

Good luck.

Later edit

Please note this is very unsafe so use with care - I did hose my system a couple of times when trying out this stuff

Here's a proof-of-concept implementation that injects code in the loginwindow.

#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <strings.h>
#include <syslog.h>

#import <Cocoa/Cocoa.h>

#include <execinfo.h>

@interface LLApp:NSApplication
@end
@implementation LLApp
- (void)run
{
    syslog(LOG_ERR, "LLApp being run");
    [super run];
}
@end

void my_openlog(const char *ident, int logopt, int facility);

typedef struct interpose_s 
{
        void * new_func;
        void * orig_func;
} interpose_t;

int MyNSApplicationMain(int argc,  const char ** argv);


static const interpose_t interposers[] __attribute__ ((section("__DATA, __interpose")))     = {
{ (void *) my_openlog, (void *) openlog },
};

void my_openlog(const char *ident, int logopt, int facility)
{
        openlog(ident, logopt, facility);

    if(!strcmp(ident, "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow"))
    {

        [LLApp poseAsClass:[NSApplication class]];
    }
    else
    {
        syslog(LOG_ERR, "Ignoring unknown indent: >%s<", ident);
    }
    return;
}

The code compiles with:

gcc -Wall -dynamiclib -undefined dynamic_lookup -o ~/Desktop/libinterposers.dylib testin.m -framework Cocoa

Code loading is based on interposing so the launchd definition of loginwindow has to contain an additional entry (to enable interposing in the dynamic linker), i.e.:

<key>EnvironmentVariables</key>
<dict>    
    <key>DYLD_INSERT_LIBRARIES</key>
    <string>path_to/Desktop/libinterposers.dylib</string>
</dict>

yes, you can use the SFAuthorizationPluginView

here the reference link at ADC

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!