migrate all

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-05 00:00:00 +00:00
parent ecef42be81
commit 0ef494b681
27 changed files with 280 additions and 230 deletions

View File

@@ -0,0 +1,26 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#ctrl-alt-del */
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/reboot.h>
#include <unistd.h>
void signal_handler(int sig) {
write(STDOUT_FILENO, "cad\n", 4);
signal(sig, signal_handler);
}
int main(void) {
int i = 0;
/* Disable the forced reboot, enable sending SIGINT to init. */
reboot(RB_DISABLE_CAD);
signal(SIGINT, signal_handler);
while (1) {
sleep(1);
printf("%d\n", i);
i++;
}
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,9 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#poweroff-out */
#define _XOPEN_SOURCE 700
#include <sys/reboot.h>
#include <unistd.h>
int main(void) {
reboot(RB_POWER_OFF);
}

View File

@@ -0,0 +1,41 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#rand_check-out */
#include <inttypes.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
int bss = 0;
int data = 1;
int main(__attribute__((unused)) int argc, char **argv) {
int i, *ip;
uint64_t uint64;
FILE *fp;
/* Loaded addresses. */
printf("&i = %p\n", (void *)&i);
printf("&argv[0] = %p\n", (void *)&argv[0]);
printf("&main = %p\n", (void *)(intptr_t)main);
printf("&bss = %p\n", (void *)&bss);
printf("&data = %p\n", (void *)&data);
/* Misc syscalls. */
printf("time(NULL) = %ju\n", (uintmax_t)time(NULL));
printf("pid = %ju\n", (uintmax_t)getpid());
/* malloc */
ip = malloc(sizeof(*ip));
printf("&malloc = %p\n", (void *)ip);
free(ip);
/* /dev/urandom */
fp = fopen("/dev/urandom", "rb");
fread(&uint64, sizeof(uint64), 1, fp);
printf("/dev/urandom = %" PRIx64 "\n", uint64);
fclose(fp);
}

View File

@@ -0,0 +1,14 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#time_boot-out */
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <unistd.h>
int main(void) {
FILE *fp;
fp = fopen("/dev/kmsg", "w");
fputs(__FILE__ "\n", fp);
fclose(fp);
while (1)
sleep(0xFFFFFFFF);
}