• Welcome to Valhalla Legends Archive.
 

Key Validator

Started by BlazingKnight, October 09, 2003, 12:21 PM

Previous topic - Next topic

iago

#15
Note this line:
QuoteIt should be something similar to this:


I haven't done any visual basic in a long, long time.. I was close :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


CupHead

Got bored, wrote this inefficient thing to generate all "valid" keys.


#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>

#define DWORD unsigned long

__inline bool Checksum(char * Key);

int main()
{
   char Key[14];
   char TempBuf[6]; char TempBuf2[5]; char TempBuf3[6]; char TempBuf4[5];
   int TempInt;
   ofstream OutFile;
   OutFile.open("keys.txt");

   long i; long j; long k;
   for ( i = 0; i < 5000; i++ )
   {
      for ( j = 0; j < 100000; j++ )
      {
         for ( k = 0; k < 10000; k++ )
         {
            strcpy(TempBuf4, "0000");
            strcpy(TempBuf3, "00000");

            _ltoa(k, TempBuf2, 10);
            TempInt = strlen(TempBuf2);
            strcpy(&TempBuf4[4 - TempInt], TempBuf2);
            strcpy(&Key[9], TempBuf4);

            strcpy(TempBuf4, "0000");

            _ltoa(i, TempBuf2, 10);
            TempInt = strlen(TempBuf2);
            strcpy(&TempBuf4[4 - TempInt], TempBuf2);
            strcpy(&Key[0], TempBuf4);

            _ltoa(j, TempBuf, 10);
            TempInt = strlen(TempBuf);
            strcpy(&TempBuf3[5 - TempInt], TempBuf);
            strcpy(&Key[4], TempBuf3);

            if ( Checksum( Key ) )
               OutFile << Key << endl;
         }
      }
   }

   OutFile.close();
   return 0;
}

__inline bool Checksum(char * Key)
{
   DWORD dChecksum = 3;
   for(int i = 0; i < 12; i++){
      dChecksum += (Key[i] - 0x30) ^ (dChecksum * 2);
   }

   dChecksum %= 10;

   if(Key[12] != dChecksum + 0x30){
      return false;
   }
   return true;
}

BlazingKnight

Yes. It was another one of vL's pointless test's to see if the reader was versatile enough in programming to understand it. Could you please put that validator in VB please.

Hitmen

You might notice most of them don't particularly like VB, so most code you will get will be in C++ unless anyone feels like "translating" it.

Adron

Weeding out the morons is a good thing.

CupHead

There, fully and correctly functioning VB validation code.


Public Function Checksum(ByVal CDKey As String) As Boolean
 Dim TheChecksum As Long, i As Byte
 TheChecksum = 3

 For i = 1 To 12
   TheChecksum = TheChecksum + ((Asc(Mid(CDKey, i, 1)) - &H30) Xor (TheChecksum * 2))
 Next i

 TheChecksum = TheChecksum Mod 10

 If Asc(Mid(CDKey, 13, 1)) <> (TheChecksum + &H30) Then
   Checksum = False
   Exit Function
 End If

 Checksum = True
End Function

BlazingKnight

Thanks CupHead. I owe ya :)

Grok

Quote from: BlazingKnight on October 12, 2003, 03:45 PM
Thanks CupHead. I owe ya :)

The question becomes ... will you ever pay him?

BlazingKnight

Aim: MrTunaBreeze
Talk to me about payment.

iago

If Asc(Mid(CDKey, 13, 1)) <> (TheChecksum + &H30) Then
-- compared to --
if(CDKey[12] - 0x30 == TheChecksum)

Who says VB is nicer? :-P

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*