Advertisement
TCB13

other.c | STKeys, other strange algorithm.

Jul 11th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. /*
  2.     Author: Kevin Devine <wyse101 0x40 gmail.com>
  3.     WWW:    http://weiss.u40.hosting.digiweb.ie/
  4.     Date:   April 2008
  5.  
  6.     example input: CP0615JT109
  7.    
  8.     it wasn't possible to debug the binary and see what input was
  9.     requested, so i can't say what input it requests for certain.
  10.  
  11.  */
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15.  
  16. #ifdef linux
  17.  #include <openssl/sha.h>
  18.  #define SHA1_Final(x,y) SHA1_Final(y,x)
  19. #else
  20.  #include "sha1.h"
  21.  
  22.  #define SHA1_Init SHA1Reset
  23.  #define SHA1_Update SHA1Input
  24.  #define SHA1_Final SHA1Result
  25.  #define SHA_CTX SHA1Context
  26. #endif
  27.  
  28. typedef unsigned int u32;
  29. typedef unsigned char u8;
  30.  
  31. int main(int argc, char **argv)
  32. {
  33.     u8 key[32]={0};
  34.     SHA_CTX sha1_ctx;
  35.     u8 sha1_digest[32];
  36.     u32 i;
  37.  
  38.     if( argc == 2 && strlen(argv[1]) == 11 ) {
  39.  
  40.       SHA1_Init(&sha1_ctx);
  41.  
  42.       /* set the context to zero */
  43.  
  44.       ((u32*)&sha1_ctx)[0] = 0;
  45.       ((u32*)&sha1_ctx)[1] = 0;
  46.       ((u32*)&sha1_ctx)[2] = 0;
  47.       ((u32*)&sha1_ctx)[3] = 0;
  48.       ((u32*)&sha1_ctx)[4] = 0;
  49.  
  50.       SHA1_Update(&sha1_ctx,argv[1],strlen(argv[1]));
  51.       SHA1_Final(&sha1_ctx,sha1_digest);
  52.  
  53.       /* format 26 bytes */
  54.       for(i = 0;i < 13;i++)
  55.         sprintf(&key[i*2],"%.2X",sha1_digest[i]);
  56.  
  57.       fprintf(stdout,"\nKey = %s\n\n",key);
  58.  
  59.    } else fprintf(stdout,"\nUsage:%s <SERIAL NUMBER>\n\n",argv[0]);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement