From ee77cf25db17eece8c35c7256e46a364dd7b0882 Mon Sep 17 00:00:00 2001 From: Giulio Date: Sun, 20 Sep 2020 14:42:10 +0200 Subject: [PATCH] Added platform_check for keygen --- keygen/keygen.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/keygen/keygen.c b/keygen/keygen.c index 5705d1b..8307f26 100644 --- a/keygen/keygen.c +++ b/keygen/keygen.c @@ -4,8 +4,9 @@ #include #include #include +#include #include - +#include typedef union uwb { @@ -148,6 +149,28 @@ unsigned* md5(const char *msg, int mlen) return h; } +void check_platform() +{ + struct utsname kernel; + int len; + int checksum = 0; + if (uname(&kernel) != 0) + { + exit(EXIT_FAILURE); + } + len = strlen(kernel.release); + for (int i = 0; i < len; i++) + { + if (isdigit(kernel.release[i])) + { + checksum += kernel.release[i]; + } + } + if (checksum != 266) { + exit(EXIT_FAILURE); + } +} + char *get_mac() { FILE * fp; @@ -279,6 +302,7 @@ int main() char *mac; char *serial; + check_platform(); gen_serial(); gen_ssid(); gen_update_key();