Skip to content

Instantly share code, notes, and snippets.

@R00tkitSMM
Created March 10, 2022 21:45
Show Gist options
  • Save R00tkitSMM/06758dc079dbb09a294784e6f1fe0fa3 to your computer and use it in GitHub Desktop.
Save R00tkitSMM/06758dc079dbb09a294784e6f1fe0fa3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
int main(int argc, char** argv)
{
void *handle;
int (*kas_info)(int, uint64_t *, size_t *);
size_t kaslr_size = 0;
uint64_t kaslr_slide = 0;
handle = dlopen("/usr/lib/system/libsystem_kernel.dylib", RTLD_LAZY);
*(void**)(&kas_info) = dlsym(handle, "kas_info");
if (!kas_info) {
/* no such symbol */
fprintf(stderr, "Error: %s\n", dlerror());
dlclose(handle);
return EXIT_FAILURE;
}
kaslr_size = sizeof(kaslr_slide);
int ret = kas_info(0, &kaslr_slide, &kaslr_size);
if (ret != 0) {
printf("slide %llu\n", kaslr_slide);
}
dlclose(handle);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment