<commit_before>/* 	Fixes VMWare Bios UUID and MAC Address to Randomize the VM 

Works only on VMware virtual machines called 'XPSP3_Coupon' and specifically
on its .vmx file
	
	- Generates random bios.uuid and runs it as a system command to fix .vmx file
			uuid.bios = "56 4d 0e 84 f8 f6 7b b3-52 a1 b5 5f 15 83 82 b5"
	- Generates random MAC address by removing the following lines in .vmx file
			ethernet0.generatedAddress
			ethernet0.generatedAddressOffset
			ethernet0.address
			ethernet0.addressType
		and adds the following lines in .vmx file
			ethernet0.address = "00:50:56:[00-3F]:YY:ZZ"
			ethernet0.addressType = "static"
	- Delete the temp files it creates... aaa.txt and bbb.txt


NOTE: "00:50:56:XX:YY:ZZ" where XX is a valid hex number between 00 and 3F 
and YY and ZZ are valid hex numbers between 00 and FF. 
The value for XX must not be greater than 3F to avoid conflict with MAC addresses 
that are generated by VMware Workstation and VMware GSX Server products.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=219

I limited the XX value between 00-99 to avoid MAC address conflicts 
	
TODO - Use other OUI's besides  00:50:56   <-- already programmed
				00:0C:29   <-- not programmed
				00:05:69   <-- not programmed
	 - Automatically recognize .vmx file in current directory
	 - Randomize memory size, maybe between 1.8 gigs to 2.4 gigs
	 
	tcc -o fixuuid.exe UUID_Fix.c
	
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

void rand_hex(char * str, unsigned long len)
{
srand((unsigned int) time(0));	// seed number for rand
   
const char *chars = "01a2b3c4d5e6f789";		//char map for hex digits
unsigned int max = strlen( chars );
unsigned long i = 0L;

for ( ; i < len - 2L; ++i ) {
str[ i ] = chars[ rand() % max ];
}
str[ i++ ] = '\n';
str[ i ] = '\0';  
}

void rand_0123(char * str, unsigned long len)
{
srand((unsigned int) time(0));	// seed number for rand
   
const char *chars = "0123";	 //char map for hex digits
unsigned int max = strlen( chars );
unsigned long i = 0L;

for ( ; i < len - 2L; ++i ) {
str[ i ] = chars[ rand() % max ];
}
str[ i++ ] = '\n';
str[ i ] = '\0';  
}

int main(void)
{
 //	1st, Remove lines with ethernet0.generatedAddress, addressOffset, addressType, and uuid.bios 
  char cmdKillUUID[100];	// create array to store uuid command 
  sprintf(cmdKillUUID, "findstr /v \"uuid.bios\" XPSP3_Coupon.vmx >aaa.txt \n");
  system(cmdKillUUID);		// run the system command stored in the array  
  
  char cmdKillEth[100];	// create array to store generatedAddress and generatedAddressOffset command 
  sprintf(cmdKillEth, "findstr /v \"ethernet0.generatedAddress\" aaa.txt >bbb.txt \n");
  system(cmdKillEth);		// run the system command stored in the array
  
  char cmdKillType[100];	// create array to store address and addressType command 
  sprintf(cmdKillType, "findstr /v \"ethernet0.address\" bbb.txt >XPSP3_Coupon.vmx \n");
  system(cmdKillType);		// run the system command stored in the array 
   
  // 2nd, add created 32-hex digit bios.uuid and 12-hex digit MAC 
  char aHex[34];			// hex digit random array
  char a0123[10];			// random 0123 array. Need only one digit
  rand_hex(aHex, 34);
  rand_0123(a0123, 10);
  printf("uuid.bios = \"%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s-%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s\"\n", 
	aHex, &aHex[2], &aHex[4], &aHex[6], &aHex[8], &aHex[10], &aHex[12], &aHex[14], &aHex[16], &aHex[18], &aHex[20], 
	&aHex[22], &aHex[24], &aHex[26], &aHex[28], &aHex[30]);

  printf("ethernet0.address = \"00:50:56:%.1s%.1s:%.2s:%.2s\"\n", &a0123[4], &aHex[29], &aHex[21], &aHex[5]);
  printf("ethernet0.addressType = \"static\"\n");
  	
  char cmdAddUUID[128];	// create array to store add uuid.bios command 
  sprintf(cmdAddUUID, "echo uuid.bios = \"%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s-%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s\" >>XPSP3_Coupon.vmx \n", 
	aHex, &aHex[2], &aHex[4], &aHex[6], &aHex[8], &aHex[10], &aHex[12], &aHex[14], &aHex[16], &aHex[18], &aHex[20], 
	&aHex[22], &aHex[24], &aHex[26], &aHex[28], &aHex[30]);
  system(cmdAddUUID);	// run the system command stored in the array
  
  char cmdAddEth0[128];	// create array to store add ethernet0.address command 
  sprintf(cmdAddEth0, "echo ethernet0.address = \"00:50:56:%.1s%.1s:%.2s:%.2s\" >>XPSP3_Coupon.vmx \n", &a0123[4], &aHex[29], &aHex[21], &aHex[5]);
  system(cmdAddEth0);	// run the system command stored in the array
  
  char cmdAddStatic[100];	// create array to store add ethernet0.addressType = "static" command 
  sprintf(cmdAddStatic, "echo ethernet0.addressType = \"static\" >>XPSP3_Coupon.vmx \n");
  system(cmdAddStatic);	// run the system command stored in the array
  
  char cmdDelTXT[100];	// create array to store del *.txt command 
  sprintf(cmdDelTXT, "del /q *.txt \n");
  system(cmdDelTXT);	// run the system command stored in the array  
  
  return 0;
}
<commit_msg>Automatic .VMX recognition<commit_after>/* 	Fixes VMWare Bios UUID and MAC Address to Randomize the VM 

Works only on VMware virtual machine .vmx file
	
	- Generates random bios.uuid and runs it as a system command to fix .vmx file
			uuid.bios = "56 4d 0e 84 f8 f6 7b b3-52 a1 b5 5f 15 83 82 b5"
	- Generates random MAC address by removing the following lines in .vmx file
			ethernet0.generatedAddress
			ethernet0.generatedAddressOffset
			ethernet0.address
			ethernet0.addressType
		and adds the following lines in .vmx file
			ethernet0.address = "00:50:56:[00-3F]:YY:ZZ"
			ethernet0.addressType = "static"
	- Delete the temp files it creates... aaa.txt, bbb.txt and fff.txt
        - Automatically recognizes .vmx file in current directory


NOTE: "00:50:56:XX:YY:ZZ" where XX is a valid hex number between 00 and 3F 
and YY and ZZ are valid hex numbers between 00 and FF. 
The value for XX must not be greater than 3F to avoid conflict with MAC addresses 
that are generated by VMware Workstation and VMware GSX Server products.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=219

I limited the XX value between 00-99 to avoid MAC address conflicts 
	
TODO - Use other OUI's besides  00:50:56   <-- already programmed
				00:0C:29   <-- not programmed
				00:05:69   <-- not programmed
	 - Randomize memory size, maybe between 1.8 gigs to 2.4 gigs
	 
	tcc -o fixuuid.exe UUID_Fix.c
	
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

void rand_hex(char * str, unsigned long len)
{
srand((unsigned int) time(0));	// seed number for rand
   
const char *chars = "01a2b3c4d5e6f789";		//char map for hex digits
unsigned int max = strlen( chars );
unsigned long i = 0L;

for ( ; i < len - 2L; ++i ) {
str[ i ] = chars[ rand() % max ];
}
str[ i++ ] = '\n';
str[ i ] = '\0';  
}

void rand_0123(char * str, unsigned long len)
{
srand((unsigned int) time(0));	// seed number for rand
   
const char *chars = "0123";	 //char map for hex digits
unsigned int max = strlen( chars );
unsigned long i = 0L;

for ( ; i < len - 2L; ++i ) {
str[ i ] = chars[ rand() % max ];
}
str[ i++ ] = '\n';
str[ i ] = '\0';  
}

int main(void)
{
 // 1st, let's get the vmx filename into a temp file and then into a variable
  char cmdGetVMX[100];	// create array to store output of dir /b *.vmx command 
  sprintf(cmdGetVMX, "dir /b *.vmx >fff.txt \n");
  system(cmdGetVMX);	// run the system command stored in the array
  
  char cVMX[500];   // read file into char array cVMX 
  FILE *fptr;
  if ((fptr=fopen("fff.txt","r"))==NULL){
      printf("Error opening file! VMX file not found... exiting");
      exit(1);     // Program exits if file pointer returns NULL 
  }
  fscanf(fptr,"%[^\n]",cVMX);
  fclose(fptr);
  printf("VMX file found = %s \n",cVMX);

 // 2nd, Remove lines with ethernet0.generatedAddress, addressOffset, addressType, and uuid.bios 
  char cmdKillUUID[100];	// create array to store uuid command 
  sprintf(cmdKillUUID, "findstr /v \"uuid.bios\" %s >aaa.txt \n",cVMX);
  system(cmdKillUUID);		// run the system command stored in the array  
  
  char cmdKillEth[100];	// create array to store generatedAddress and generatedAddressOffset command 
  sprintf(cmdKillEth, "findstr /v \"ethernet0.generatedAddress\" aaa.txt >bbb.txt \n");
  system(cmdKillEth);		// run the system command stored in the array
  
  char cmdKillType[100];	// create array to store address and addressType command 
  sprintf(cmdKillType, "findstr /v \"ethernet0.address\" bbb.txt >%s \n",cVMX);
  system(cmdKillType);		// run the system command stored in the array 
   
  // 3rd, add created 32-hex digit bios.uuid and 12-hex digit MAC 
  char aHex[34];			// hex digit random array
  char a0123[10];			// random 0123 array. Need only one digit
  rand_hex(aHex, 34);
  rand_0123(a0123, 10);
  printf("uuid.bios = \"%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s-%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s\"\n", 
	aHex, &aHex[2], &aHex[4], &aHex[6], &aHex[8], &aHex[10], &aHex[12], &aHex[14], &aHex[16], &aHex[18], &aHex[20], 
	&aHex[22], &aHex[24], &aHex[26], &aHex[28], &aHex[30]);

  printf("ethernet0.address = \"00:50:56:%.1s%.1s:%.2s:%.2s\"\n", &a0123[4], &aHex[29], &aHex[21], &aHex[5]);
  printf("ethernet0.addressType = \"static\"\n");
  	
  char cmdAddUUID[128];	// create array to store add uuid.bios command 
  sprintf(cmdAddUUID, "echo uuid.bios = \"%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s-%.2s %.2s %.2s %.2s %.2s %.2s %.2s %.2s\" >>%s \n", 
	aHex, &aHex[2], &aHex[4], &aHex[6], &aHex[8], &aHex[10], &aHex[12], &aHex[14], &aHex[16], &aHex[18], &aHex[20], 
	&aHex[22], &aHex[24], &aHex[26], &aHex[28], &aHex[30], cVMX);
  system(cmdAddUUID);	// run the system command stored in the array
  
  char cmdAddEth0[128];	// create array to store add ethernet0.address command 
  sprintf(cmdAddEth0, "echo ethernet0.address = \"00:50:56:%.1s%.1s:%.2s:%.2s\" >>%s \n", &a0123[4], &aHex[29], &aHex[21], &aHex[5], cVMX);
  system(cmdAddEth0);	// run the system command stored in the array
  
  char cmdAddStatic[100];	// create array to store add ethernet0.addressType = "static" command 
  sprintf(cmdAddStatic, "echo ethernet0.addressType = \"static\" >>%s \n",cVMX);
  system(cmdAddStatic);	// run the system command stored in the array
  
  char cmdDelTXT[100];	// create array to store del *.txt command 
  sprintf(cmdDelTXT, "del /q *.txt \n");
  system(cmdDelTXT);	// run the system command stored in the array  
  
  return 0;
}

{'fraction_non_alphanumeric': 0.1520755080419917, 'fraction_numerical': 0.0574015217181932, 'mean_word_length': 3.5049891540130154, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5355828', 'n_tokens_mistral': 4294, 'n_tokens_neox': 3863, 'n_words': 1238}