Added platform_check for keygen

This commit is contained in:
Giulio 2020-09-20 14:42:10 +02:00
parent af63b37aa2
commit ee77cf25db

View File

@ -4,8 +4,9 @@
#include <string.h>
#include <math.h>
#include <stdint.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/utsname.h>
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();