Advertisement
Guest User

Wii U ticket maker

a guest
Feb 22nd, 2017
757
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.09 KB | None | 0 0
  1. /* public domain */
  2. /* V2 Builds on Clang & GCC (linux) and TCC (windows) */
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <stdio.h>
  7.  
  8. #define data_size 848U
  9. #define key_loc 0x1BF
  10. #define id_loc  0x1DC
  11. uint8_t rawData[848] = {
  12.   0,  1,  0,  4,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  13.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  14.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  15.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  16.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  17.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  18.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  19.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  20.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  21.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  22.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  23.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  24.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  25.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  26.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  27.  21,171,225, 26,209, 94,165,237, 21,171,225, 26,209, 94,165,237,
  28.  21,171,225, 26,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  29.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  30.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  31.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  32.  82,111,111,116, 45, 67, 65, 48, 48, 48, 48, 48, 48, 48, 51, 45,
  33.  88, 83, 48, 48, 48, 48, 48, 48, 48, 99,  0,  0,  0,  0,  0,  0,
  34.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  35.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  36. 254,237,250,206,254,237,250,206,254,237,250,206,254,237,250,206,
  37. 254,237,250,206,254,237,250,206,254,237,250,206,254,237,250,206,
  38. 254,237,250,206,254,237,250,206,254,237,250,206,254,237,250,206,
  39. 254,237,250,206,254,237,250,206,254,237,250,206,  1,  0,  0,255,
  40. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,
  41.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,255,255,255,
  42. 255,255,255,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  43.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  44.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  45.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  46.   0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  47.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  48.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  49.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  50.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  51.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  52.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  53.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  54.   0,  0,  0,  0,  0,  1,  0, 20,  0,  0,  0,172,  0,  0,  0, 20,
  55.   0,  1,  0, 20,  0,  0,  0,  0,  0,  0,  0, 40,  0,  0,  0,  1,
  56.   0,  0,  0,132,  0,  0,  0,132,  0,  3,  0,  0,  0,  0,  0,  0,
  57. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  58. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  59.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  60.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  61.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  62.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  63.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  64.   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
  65. };
  66.  
  67. void read_key_string(uint8_t* key_out, char* key_str) {
  68.     if(key_out != NULL && key_str != NULL) {
  69.         uint32_t i;
  70.         for(i=0; i<16; ++i) {
  71.             uint32_t o;
  72.             char str_fix[9];
  73.             memset(str_fix, 0, 9);
  74.             memcpy(str_fix, &key_str[i*2], 2);
  75.             sscanf(str_fix, "%02x", &o);
  76.             key_out[i] = (uint8_t)(o & 0xFF);
  77.         }
  78.     }
  79. }
  80.  
  81. void read_gid_string(uint8_t* gid_out, char* gid_str) {
  82.     if(gid_out != NULL && gid_str != NULL) {
  83.        
  84.         uint32_t i;
  85.         for(i=0; i<4; ++i) {
  86.             char empty[4];
  87.             memset(empty, 0, 4);
  88.             memcpy(empty, &gid_str[i*2], 2);
  89.             gid_out[i] = (uint8_t)strtoul(empty, NULL, 16);
  90.         }
  91.        
  92.         for(i=0; i<4; ++i) {
  93.             char empty[4];
  94.             memset(empty, 0, 4);
  95.             memcpy(empty, &gid_str[(i*2)+9], 2);
  96.             gid_out[i+4] = (uint8_t)strtoul(empty, NULL, 16);
  97.         }
  98.        
  99.     }
  100. }
  101.  
  102. int main(int argc, char** argv) {
  103.     if(argc != 3) {
  104.         printf("Title.tik generator\nOutputs Title.tik with specified data\nUsage: tikmaker.exe XXXXGAME-IDXXXXXX key\n");
  105.     } else {
  106.         FILE* tik;
  107.         uint8_t* gid;
  108.         uint8_t* key;
  109.         key = &rawData[key_loc];
  110.         gid = &rawData[id_loc];
  111.        
  112.         read_key_string(key, argv[2]);
  113.         read_gid_string(gid, argv[1]);
  114.        
  115.         tik = fopen("Title.tik", "wb");
  116.         if(tik != NULL) {
  117.             fwrite(rawData, sizeof(char), data_size, tik);
  118.             fclose(tik);
  119.             printf("successfully written Title.tik!\nGame ID: %s\nKey: %s\n", argv[1], argv[2]);
  120.         } else {
  121.             printf("Could not create Title.tik!\n");
  122.         }  
  123.     }
  124.     return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement