DF-2403 / smcleak.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/sysctl.h> int main(void) { char out[256]; size_t len = sizeof(out) - 1; int i, j; memset(out, 0, sizeof(out)); /* 1: kstack canary spray in this thread (rig sysctl) */ if (sysctlbyname("dev.dfsm.0.spray", NULL, NULL, NULL, 0) < 0) perror("spray"); /* 2: PRODUCTION fanid handler in the same thread */ if (sysctlbyname("dev.dfsm.0.fanid", out, &len, NULL, 0) < 0) { perror("fanid"); return 1; } printf("fanid returned %zu bytes:\n", len); printf("hex: "); for (i = 0; i < (int)len && i < 128; i++) printf("%02x", (unsigned char)out[i]); printf("\nascii: '"); for (j = 0; j < (int)len && j < 128; j++) putchar(out[j] >= 32 && out[j] < 127 ? out[j] : '.'); printf("'\n"); return 0; } |