staticvoid print_banner(void)
{ struct utsname utsname; int len;
if (uname(&utsname) < 0)
panic("uname");
len = strlen(" WireGuard Test Suite on ") + strlen(utsname.sysname) + strlen(utsname.release) + strlen(utsname.machine);
printf("\x1b[45m\x1b[33m\x1b[1m%*.s\x1b[0m\n\x1b[45m\x1b[33m\x1b[1m WireGuard Test Suite on %s %s %s \x1b[0m\n\x1b[45m\x1b[33m\x1b[1m%*.s\x1b[0m\n\n", len, "", utsname.sysname, utsname.release, utsname.machine, len, "");
}
staticvoid seed_rng(void)
{ int bits = 256, fd;
if (!getrandom(NULL, 0, GRND_NONBLOCK)) return;
pretty_message("[+] Fake seeding RNG...");
fd = open("/dev/random", O_WRONLY); if (fd < 0)
panic("open(random)"); if (ioctl(fd, RNDADDTOENTCNT, &bits) < 0)
panic("ioctl(RNDADDTOENTCNT)");
close(fd);
}
staticvoid set_time(void)
{ if (time(NULL)) return;
pretty_message("[+] Setting fake time..."); if (stime(&(time_t){1433512680}) < 0)
panic("settimeofday()");
}
staticvoid mount_filesystems(void)
{
pretty_message("[+] Mounting filesystems...");
mkdir("/dev", 0755);
mkdir("/proc", 0755);
mkdir("/sys", 0755);
mkdir("/tmp", 0755);
mkdir("/run", 0755);
mkdir("/var", 0755); if (mount("none", "/dev", "devtmpfs", 0, NULL))
panic("devtmpfs mount"); if (mount("none", "/proc", "proc", 0, NULL))
panic("procfs mount"); if (mount("none", "/sys", "sysfs", 0, NULL))
panic("sysfs mount"); if (mount("none", "/tmp", "tmpfs", 0, NULL))
panic("tmpfs mount"); if (mount("none", "/run", "tmpfs", 0, NULL))
panic("tmpfs mount"); if (mount("none", "/sys/kernel/debug", "debugfs", 0, NULL))
; /* Not a problem if it fails.*/ if (symlink("/run", "/var/run"))
panic("run symlink"); if (symlink("/proc/self/fd", "/dev/fd"))
panic("fd symlink");
}
staticvoid enable_logging(void)
{ int fd;
pretty_message("[+] Enabling logging...");
fd = open("/proc/sys/kernel/printk", O_WRONLY); if (fd >= 0) { if (write(fd, "9\n", 2) != 2)
panic("write(printk)");
close(fd);
}
fd = open("/proc/sys/debug/exception-trace", O_WRONLY); if (fd >= 0) { if (write(fd, "1\n", 2) != 2)
panic("write(exception-trace)");
close(fd);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.