Open source Windows 7 product key checker

Discussion in 'MDL Projects and Applications' started by Daz, Oct 15, 2009.

  1. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,253
    300
    #41 Daz, Oct 15, 2009
    Last edited: Oct 15, 2009
    (OP)
    Added crypto ID & licence channel info, also added copy & paste to the input field.

    @ hvgvirry
    That's due to the pkeyconfig.xrm-ms file, I have it use your current system's rather than supplying different ones. This is what allows it to work on Vista too without me having to supply extra files.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. hvgvirry

    hvgvirry MDL Novice

    Aug 16, 2009
    21
    0
    0

    Ok ! :):):):)
     
  3. thecoder

    thecoder MDL Novice

    Oct 17, 2009
    2
    0
    0
    #43 thecoder, Oct 17, 2009
    Last edited by a moderator: Feb 27, 2013
    Daz it would be REALLY great if you would make working cr4ck for newest RealBasic version (2009 release 4) because version 2007 is old and buggy. And as always - good job and thanks for sharing source of this program!
     
  4. Sabresite

    Sabresite MDL Member

    Nov 7, 2007
    210
    49
    10
    I was looking for the patch.. and everytime I did I got a virus that spreads through programs coded in basic :\

    Then again I went through great lengths to get RB 2007 R5 - Cause you said to use that one :eek:
     
  5. _Spee_

    _Spee_ MDL Novice

    Jul 17, 2009
    19
    0
    0
    #45 _Spee_, Oct 18, 2009
    Last edited: Oct 18, 2009
    Hello.
    I have tried it with RemoveWAT program, and it says: Error: Invalid serial.
    I think that is right.
    Cheers. ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,253
    300
    @ Sabresite
    The best one to compile with, I personally code it in 2009 and then compile in 2007.

    @ elffin
    I think 2008R5 had a keygen, but this is for the 2009 editions (2009R4) which as far as I know nobody else has got activated yet ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. thecoder

    thecoder MDL Novice

    Oct 17, 2009
    2
    0
    0
    Thanks for the patch Daz! ;) You are great! :D
     
  8. elffin

    elffin MDL Novice

    Sep 12, 2009
    3
    0
    0
    Daz:
    Still want to know something about the principle of PID Checker (more than these codes) . Are there any such resources or URL?

    How could you make this program (barely by investigating the internal of DLL file)?

    Could you give me some guidances or hints for this ?

    Thanks! :)
     
  9. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,253
    300
    I looked at the MS PIDX checker, seen what DLL's it was loading and just looked around for function names. Obviously once I was getting data back and it wasn't giving me any error (return 0 being its fine) then I started adding debug lines to the memoryblocks and I could clearly see the data, all I had to do then was output it :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,253
    300
    Heres the Perl version of the code I just got done with :) It's messy, but it works.

    Code:
    use Win32::API;
    use Unicode::String;
    use English;
    use strict;
    
    $OUTPUT_AUTOFLUSH = 1;
    $Win32::API::DEBUG = 0;
    binmode(STDOUT, ":utf8");
    
    system("cls");
    print "Please enter a serial: ";
    my $Key = <STDIN>;
    chomp($Key);
    system("cls");
    print "Please wait...";
    my $Path = "C:\\Windows\\System32\\spp\\tokens\\pkeyconfig\\pkeyconfig.xrm-ms";
    
    my $GenPID = chr(50);
    my $OldPID = chr(164);
    my $CoreData = chr(248).chr(4);
    
    $GenPID .= chr(0) x 99;
    $OldPID .= chr(0) x 163;
    $CoreData .= chr(0) x 1270;
    
    my $ukey = Unicode::String-> new;
    $ukey-> utf8($Key);
    my $upath = Unicode::String-> new;
    $upath-> utf8($Path);
    my $ublock = Unicode::String-> new;
    $ublock-> utf8("XXXXX");
    
    my $PidGenX = new Win32::API('pidgenx', 'PidGenX', ['P','P','P','N','P','P','P'], 'N');
    my $RetID = $PidGenX->Call($ukey->utf16le, $upath->utf16le, $ublock->utf16le, 0, $GenPID, $OldPID, $CoreData);
    if ($RetID == 0){
        $GenPID =~ s/\x00//g;
        my $PID = substr($GenPID, 0);
        my @mydata = split("\x00\x00", $CoreData);
    
        my $EPID = $mydata[2];
        $EPID =~ s/\x00//g;
        my $AID = $mydata[18];
        $AID =~ s/\x00//g;
        my $WEDID = $mydata[54];
        $WEDID =~ s/\x00//g;
        my $SUB = $mydata[311];
        $SUB =~ s/\x00//g;
        my $LTYPE = $mydata[366];
        $LTYPE =~ s/\x00//g;
        my $CID = $mydata[423];
        $CID =~ s/\x00//g;
    
        system("cls");
        print "Key status: Valid (".$Key.")\n";
        if ($PID gt ""){print "PID: ".$PID."\n";}
        if ($EPID gt ""){print "Extended PID: ".$EPID."\n";}
        if ($AID gt ""){print "Activation ID: ".$AID."\n";}
        if ($WEDID gt ""){print "Edition: ".$WEDID."\n";}
        if ($SUB gt ""){print "Subtype: ".substr($SUB,length($SUB)-9)."\n";}
        if ($LTYPE gt ""){print "License type: ".$LTYPE."\n";}
        if ($CID gt ""){print "License channel: ".$CID."\n";}
        if ($EPID gt ""){print "Crypto ID: ".substr($EPID,8,3)."\n";}
      }else{
        system("cls");
        print "Key status: Invalid (".$RetID.")\n";
    }
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. woebetide

    woebetide MDL Member

    May 28, 2007
    240
    78
    10
    #51 woebetide, Oct 27, 2009
    Last edited: Oct 27, 2009
    There is a keygen and if you follow certain instructions it works with 2009R4!
    Out of curiosity i tried it and it's really working
     
  12. libertard

    libertard MDL Junior Member

    Jul 30, 2009
    81
    1
    0
    Like it

    thanks for shaing :D;):cool:
     
  13. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    #53 HotCarl, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    Open source product key checker code for VB.NET :)

    Like I promised, here is an open source product key checker sub procedure for VB.NET 2008...just put it into your VB.NET project and call the sub the same way you would call any sub: Check_Product_Key(productKeyStringHere)

    Code:
        Declare Auto Function PidGenX Lib "pidgenx.dll" (ByVal one As String, ByVal two As String, ByVal three As String, ByVal four As Integer, ByVal five As IntPtr, ByVal six As IntPtr, ByVal seven As IntPtr) As Integer
    
        Private Sub Check_Product_Key(ByVal serial As String)
    
            'This Function will accept a product key and check it to ensure validity...
    
            'Set the Windows cursor (for this program) to a wait cursor so the user cannot close the form by clicking the [X]...
            Me.Cursor = Cursors.WaitCursor
    
            'Basic error checking to ensure 'serial' is not an empty value.
            'More error checking should be done prior to passing the 'serial' string to the this function...
            If serial = Nothing Then Exit Sub
    
            'Create memory spaces to pass to, and accept data from pidgenx.dll
            Dim genPID As IntPtr = Marshal.AllocHGlobal(100)
            Marshal.WriteByte(genPID, 0, &H32)
            Dim clearGenPID As Integer = 0
            For clearGenPID = 1 To 99 'Clear out memory space...
                Marshal.WriteByte(genPID, clearGenPID, &H0)
            Next clearGenPID
    
            Dim oldPID As IntPtr = Marshal.AllocHGlobal(164)
            Marshal.WriteByte(oldPID, 0, &HA4)
            Dim clearOldPID As Integer = 0
            For clearOldPID = 1 To 163 'Clear out memory space...
                Marshal.WriteByte(oldPID, clearOldPID, &H0)
            Next clearOldPID
    
            Dim DPID4 As IntPtr = Marshal.AllocHGlobal(1272)
            Marshal.WriteByte(DPID4, 0, &HF8)
            Marshal.WriteByte(DPID4, 1, &H4)
            Dim clearDPID4 As Integer = 0
            For clearDPID4 = 2 To 1271 'Clear out memory space...
                Marshal.WriteByte(DPID4, clearDPID4, &H0)
            Next clearDPID4
    
            'Set location of pkeyconfig.xrm-ms (needed by pidgenx.dll to verify key)...
            Dim pkeyconfig As String = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms"
            'Call PidGenX() to determine if key is valid...
            Dim RetID As Integer = PidGenX(serial, pkeyconfig, "XXXXX", 0, genPID, oldPID, DPID4)
    
            'Check returned value 'RetID' for valid key...
            If RetID = 0 Then
                outputTextBox.AppendText("Key Status:      Valid" & vbNewLine)
            ElseIf RetID = -2147024893 Then
                outputTextBox.AppendText("Error: invalid function call")
                outputTextBox.AppendText("Must call 'PidGenX'")
            ElseIf RetID = -2147024894 Then
                outputTextBox.AppendText("Error: pkeyconfig.xrm-ms is missing")
            ElseIf RetID = -2147024809 Then
                outputTextBox.AppendText("Error: Invalid arguments")
            ElseIf RetID = -1979645695 Then
                outputTextBox.AppendText("Error: Invalid key")
            Else
                outputTextBox.AppendText("Error: Invalid key")
            End If
    
            'Parse out pertinent information...
            If RetID = 0 Then
                Dim pidb As Byte() = New Byte(99) {}
                For i As Integer = 0 To pidb.Length - 1
                    pidb(i) = Marshal.ReadByte(genPID, i)
                Next
                Dim core As Byte() = New Byte(1271) {}
                For i As Integer = 0 To core.Length - 1
                    core(i) = Marshal.ReadByte(DPID4, i)
                Next
    
                'Display the parsed information...
                Dim enc As System.Text.Encoding = System.Text.Encoding.ASCII
    
                Dim pid As String = enc.GetString(pidb).Replace(vbNullChar, "") 'PID
                outputTextBox.AppendText("Product ID:      " & pid & vbNewLine)
    
                Dim epid As String = enc.GetString(core, 8, 96).Replace(vbNullChar, "") 'Extendend PID 
                outputTextBox.AppendText("Extended PID:    " & epid & vbNewLine)
    
                Dim aid As String = enc.GetString(core, 136, 72).Replace(vbNullChar, "") 'Activation ID 
                outputTextBox.AppendText("Activation ID:   " & aid & vbNewLine)
    
                Dim edi As String = enc.GetString(core, 280, 40).Replace(vbNullChar, "") 'Edition
                outputTextBox.AppendText("Edition:         " & edi & vbNewLine)
    
                Dim  As String = enc.GetString(core, 888, 20).Replace(vbNullChar, "") 'SubType
                outputTextBox.AppendText("Sub Type:        " &  & vbNewLine)
    
                Dim lit As String = enc.GetString(core, 1016, 25).Replace(vbNullChar, "") 'License Type
                outputTextBox.AppendText("License Type:    " & lit & vbNewLine)
    
                Dim lic As String = enc.GetString(core, 1144, 20).Replace(vbNullChar, "") 'License Channel
                outputTextBox.AppendText("License Channel: " & lic & vbNewLine)
    
                Dim cid As String = epid.Substring(8, 3) 'Crypto ID
                outputTextBox.AppendText("Crypto ID:       " & cid)
            End If
    
            miscOptionsOutputLabel.Text = "Product Key Verification Complete."
            Me.Cursor = Cursors.Default
    
            'Clean up memory used and return it to Windows...
            Marshal.FreeHGlobal(genPID)
            Marshal.FreeHGlobal(oldPID)
            Marshal.FreeHGlobal(DPID4)
    
        End Sub
    
     
  14. oneextraid

    oneextraid MDL Member

    Jul 29, 2009
    181
    19
    10
    Daz,

    Could this program also validate Office 2007 keys?
     
  15. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    #55 MasterDisaster, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. redalerthan

    redalerthan MDL Novice

    Aug 7, 2009
    20
    13
    0
    It 's a good idea to sharing such a solution, while I do think that the online checker is more convenient.
     
  17. ComputerDownloads

    ComputerDownloads MDL Novice

    Oct 31, 2009
    24
    0
    0
    #59 ComputerDownloads, Nov 9, 2009
    Last edited by a moderator: Apr 20, 2017
    Here's a more friendly code for VB.NET, Originally by HotCarl, Edited By ComputerDownloads.
    Simply Put a Button, Textbox, Another Textbox(Multiline), And a Label.
    Simply Double Click the Button and insert this Code
    Code:
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Declare Auto Function PidGenX Lib "pidgenx.dll" (ByVal one As String, ByVal two As String, ByVal three As String, ByVal four As Integer, ByVal five As IntPtr, ByVal six As IntPtr, ByVal seven As IntPtr) As Integer
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            'Basic error checking to ensure 'serial' is not an empty value.
            'More error checking should be done prior to passing the 'serial' string to the this function...
            If TextBox1.Text = "" Then
                MessageBox.Show("No Product Key Was Entered", "Product Key Checker", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Exit Sub
            End If
    
            'This Function will accept a product key and check it to ensure validity...
    
            'Set the Windows cursor (for this program) to a wait cursor so the user cannot close the form by clicking the [X]...
            Me.Cursor = Cursors.WaitCursor
    
            'Create memory spaces to pass to, and accept data from pidgenx.dll
            Dim genPID As IntPtr = Marshal.AllocHGlobal(100)
            Marshal.WriteByte(genPID, 0, &H32)
            Dim clearGenPID As Integer = 0
            For clearGenPID = 1 To 99 'Clear out memory space...
                Marshal.WriteByte(genPID, clearGenPID, &H0)
            Next clearGenPID
    
            Dim oldPID As IntPtr = Marshal.AllocHGlobal(164)
            Marshal.WriteByte(oldPID, 0, &HA4)
            Dim clearOldPID As Integer = 0
            For clearOldPID = 1 To 163 'Clear out memory space...
                Marshal.WriteByte(oldPID, clearOldPID, &H0)
            Next clearOldPID
    
            Dim DPID4 As IntPtr = Marshal.AllocHGlobal(1272)
            Marshal.WriteByte(DPID4, 0, &HF8)
            Marshal.WriteByte(DPID4, 1, &H4)
            Dim clearDPID4 As Integer = 0
            For clearDPID4 = 2 To 1271 'Clear out memory space...
                Marshal.WriteByte(DPID4, clearDPID4, &H0)
            Next clearDPID4
    
            'Set location of pkeyconfig.xrm-ms (needed by pidgenx.dll to verify key)...
            Dim pkeyconfig As String = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms"
            'Call PidGenX() to determine if key is valid...
            Dim RetID As Integer = PidGenX(TextBox1.Text, pkeyconfig, "XXXXX", 0, genPID, oldPID, DPID4)
    
            'Check returned value 'RetID' for valid key...
            If RetID = 0 Then
                TextBox2.AppendText("Key Status:      Valid" & vbNewLine)
            ElseIf RetID = -2147024893 Then
                TextBox2.AppendText("Error: invalid function call")
                TextBox2.AppendText("Must call 'PidGenX'")
            ElseIf RetID = -2147024894 Then
                TextBox2.AppendText("Error: pkeyconfig.xrm-ms is missing")
            ElseIf RetID = -2147024809 Then
                TextBox2.AppendText("Error: Invalid arguments")
            ElseIf RetID = -1979645695 Then
                TextBox2.AppendText("Error: Invalid key")
            Else
                TextBox2.AppendText("Error: Invalid key")
            End If
    
            'Parse out pertinent information...
            If RetID = 0 Then
                Dim pidb As Byte() = New Byte(99) {}
                For i As Integer = 0 To pidb.Length - 1
                    pidb(i) = Marshal.ReadByte(genPID, i)
                Next
                Dim core As Byte() = New Byte(1271) {}
                For i As Integer = 0 To core.Length - 1
                    core(i) = Marshal.ReadByte(DPID4, i)
                Next
    
                'Display the parsed information...
                Dim enc As System.Text.Encoding = System.Text.Encoding.ASCII
    
                Dim pid As String = enc.GetString(pidb).Replace(vbNullChar, "") 'PID
                TextBox2.AppendText("Product ID:      " & pid & vbNewLine)
    
                Dim epid As String = enc.GetString(core, 8, 96).Replace(vbNullChar, "") 'Extendend PID 
                TextBox2.AppendText("Extended PID:    " & epid & vbNewLine)
    
                Dim aid As String = enc.GetString(core, 136, 72).Replace(vbNullChar, "") 'Activation ID 
                TextBox2.AppendText("Activation ID:   " & aid & vbNewLine)
    
                Dim edi As String = enc.GetString(core, 280, 40).Replace(vbNullChar, "") 'Edition
                TextBox2.AppendText("Edition:         " & edi & vbNewLine)
    
                Dim  As String = enc.GetString(core, 888, 20).Replace(vbNullChar, "") 'SubType
                TextBox2.AppendText("Sub Type:        " &  & vbNewLine)
    
                Dim lit As String = enc.GetString(core, 1016, 25).Replace(vbNullChar, "") 'License Type
                TextBox2.AppendText("License Type:    " & lit & vbNewLine)
    
                Dim lic As String = enc.GetString(core, 1144, 20).Replace(vbNullChar, "") 'License Channel
                TextBox2.AppendText("License Channel: " & lic & vbNewLine)
    
                Dim cid As String = epid.Substring(8, 3) 'Crypto ID
                TextBox2.AppendText("Crypto ID:       " & cid)
            End If
    
            Label1.Text = "Product Key Verification Complete."
            Me.Cursor = Cursors.Default
    
            'Clean up memory used and return it to Windows...
            Marshal.FreeHGlobal(genPID)
            Marshal.FreeHGlobal(oldPID)
            Marshal.FreeHGlobal(DPID4)
    
        End Sub
    End Class
    
     
  18. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    #60 PAYMYRENT, Nov 9, 2009
    Last edited: Nov 9, 2009