Skip to content

Instantly share code, notes, and snippets.

@useit015
Created October 10, 2019 01:39
Show Gist options
  • Save useit015/92c4abd582494cf0ad81deeeacc217e9 to your computer and use it in GitHub Desktop.
Save useit015/92c4abd582494cf0ad81deeeacc217e9 to your computer and use it in GitHub Desktop.
#include <dlfcn.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(void)
{
char *name;
void *handle;
char *lib = "/System/Library/PrivateFrameworks/login.framework/Versions/A/login";
char *logout = "SACLOStartLogout";
char *turn = "SACSwitchToLoginWindow";
void (*func)(int, int, int, int);
if (!(name = calloc(1024, sizeof(char *))))
return (-1);
if (gethostname(name, 1024) == -1)
return (-1);
if (!(handle = dlopen(lib, RTLD_LAZY)))
return (-1);
if (!func = dlsym(handle, strstr(name, "1337.ma") ? logout : turn))
return (-1);
func(1, 1, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment