Willem's...

{rue if I mellow}

  Home  |   Contact  |   Syndication    |   Login
  25 Posts | 0 Stories | 223 Comments | 51 Trackbacks

News

Archives

Post Categories

Businessware Architects

XML-FX.COM

Ever needed to reinstall your PC and could not recover your product key from that 'safe storage' you were supposed to use? It is no secret that if your system is still running you can recover the key from the system registry where it is encoded in a REG_BINARY value.

You can download a free utility that recovers the XP product key (and the MS Office product key if its installed):

You can even recover it online here:

but if you're paranoid, maybe these applications are actually stealing your product key, so you want to do this yourself with your own code, right?  The only bit of code I could find that can recover product keys is here:

which provides a working Delphi source-code listing. I only required to find the XP product key, so after hacking the code, I produced a working C# version (works with .NET 1.1 and 2.0) shown below. I allowed place-holders for other product keys but the code may have to be further modified to work correctly.

 

Windows XP KeyFinder Listing
using System;
using System.Collections;
using Microsoft.Win32;

namespace MSKeyFinder
{
  public class KeyDecoder
  {
    public enum Key { XP, Office10, Office11 };
    public static byte[] GetRegistryDigitalProductId(Key key)
    {
      byte[] digitalProductId = null;
      RegistryKey registry = null;
      switch(key)
      {
        // Open the XP subkey readonly.
        case Key.XP:
          registry = 
            Registry.LocalMachine.
              OpenSubKey(
                @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                  false);
          break;
        // Open the Office 10 subkey readonly.
        case Key.Office10:
          // TODO: Open the registry key.
          break;
        // Open the Office 11 subkey readonly.
        case Key.Office11:
          // TODO: Open the registry key.
          break;
      }
      if(registry != null)
      {
        // TODO: For other products, key name maybe different.
        digitalProductId = registry.GetValue("DigitalProductId")
          as byte[];
        registry.Close();
      }
      return digitalProductId;
    }
    public static string DecodeProductKey(byte[] digitalProductId)
    {
      // Offset of first byte of encoded product key in 
      //  'DigitalProductIdxxx" REG_BINARY value. Offset = 34H.
      const int keyStartIndex = 52;
      // Offset of last byte of encoded product key in 
      //  'DigitalProductIdxxx" REG_BINARY value. Offset = 43H.
      const int keyEndIndex = keyStartIndex + 15;
      // Possible alpha-numeric characters in product key.
      char[] digits = new char[]
      {
        'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
        'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
      };
      // Length of decoded product key
      const int decodeLength = 29;
      // Length of decoded product key in byte-form.
      // Each byte represents 2 chars.
      const int decodeStringLength = 15;
      // Array of containing the decoded product key.
      char[] decodedChars = new char[decodeLength];
      // Extract byte 52 to 67 inclusive.
      ArrayList hexPid = new ArrayList();
      for (int i = keyStartIndex; i <= keyEndIndex; i++)
      {
        hexPid.Add(digitalProductId[i]);
      }
      for (int i = decodeLength - 1; i >= 0; i--)
      {
        // Every sixth char is a separator.
        if ((i + 1) % 6 == 0)
        {
          decodedChars[i] = '-';
        }
        else
        {
          // Do the actual decoding.
          int digitMapIndex = 0;
          for (int j = decodeStringLength - 1; j >= 0; j--)
          {
            int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
            hexPid[j] = (byte)(byteValue / 24);
            digitMapIndex = byteValue % 24;
            decodedChars[i] = digits[digitMapIndex];
          }
        }
      }
      return new string(decodedChars);
    }
  }
}

Once you realize how the product keys are encoded, a search through the registry for the values starting with DigitalProductId indicates that many more product keys may be encoded this way.

PLEASE NOTE: All code listed here is provided as-is, with no guarantees what so ever. Use of this code does not require a license and no copyright on the code exists or is implied. You are free to use the code as you see fit, for any commercial or non-commercial use.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Sunday, April 23, 2006 9:37 AM

Feedback

# re: Recover your XP product key from the registry using C# 5/19/2006 6:20 PM Anonymous
There's this one too:

http://www.snapfiles.com/get/rockxp.html

# re: Recover your XP product key from the registry using C# 10/28/2006 11:18 PM Mike Cobain
how do I call the function to get the final String to be showed at a txt box ?



# re: Recover your XP product key from the registry using C# 11/2/2006 1:16 PM slide
Any ideas on reversing the process? I have a bunch of machines at work that I need to rekey Office for (the same decode algorithm works for Office keys)

# re: Recover your XP product key from the registry using C# 11/6/2006 1:23 PM Willem
I guess you could hack the registry directly but considering the dire warnings MS gives about this, I would suggest using some VB scripts that change the product key using WMI. Check out the following link:

http://support.microsoft.com/kb/328874

It should be possible to also do this using C# by utilizing the classes of the System.Management namespace. Check on Google for the key-words C# and WMI...


# re: Recover your XP product key from the registry using C# 4/20/2007 7:56 AM Derek Flournoy
Wow, Very impressive... i had to add a Main method (obviously) but it definitely worked,

Thank you sir!

# re: Recover your XP product key from the registry using C# 8/6/2007 6:14 PM sysguru
for those of you who have not figured out how to actually make this work....

byte[] results =KeyDecoder.GetRegistryDigitalProductId(KeyDecoder.Key.XP);

textBox1.Text = KeyDecoder.DecodeProductKey(results);




# re: Recover your XP product key from the registry using C# 8/9/2007 2:22 AM Socrates
Does not work with 64-bit editions of Windows due to Registry reflection/mirroring

# re: Recover your XP product key from the registry using C# 8/13/2007 7:44 PM CU-420
Did not work for me.
I have an older version of XP Home, it came with only SP1.

Worked on Vista though

# re: Recover your XP product key from the registry using C# 11/9/2007 5:51 AM Thanks
I can use it to "偷" ProductKey

# re: Recover your XP product key from the registry using C# 11/23/2007 3:44 PM Paul
I have used this software on OEM and retail versions of Windows Pro x64 (not Itanium) and it works fine. Socrates may have tried it on an Itanium OS or a mass produced OEM version like Dell would distribute. Anyway it works fine.

# re: Recover your XP product key from the registry using C# 2/1/2008 11:04 PM Goody
use WinGuggle

You can use this application to get your Windows Vista Product key easily.

It Provides Complete Way to Brand your PC/Laptop:
like add information to Windows experience index page, system properties page and owners information info. WOW! Great Tool…

Download Here: WinGuggle
http://unlockforus.blogspot.com/2008/01/winguggle-get-your-windows-vista.html



# re: Recover your XP product key from the registry using C# 2/1/2008 11:06 PM Goody
Download Here:


# re: Recover your XP product key from the registry using C# 3/14/2008 12:19 PM Big Mike
So how about a method to encode a human readable product key into a digitalproductID?

# re: Recover your XP product key from the registry using C# 7/10/2008 10:13 PM brian
This code is great and you've been kind enough to put it online for all to see! However (if you're in the USA), you have not specified a copyright for it, so as a result you have automatic rights and no one else is allowed to use it without your permission. If you read the codinghorror blog post here http://www.codinghorror.com/blog/archives/000833.html you can see what problems this can cause.

It would be great if you could specify a copyright so the many who have received some benefit from it can use it. Even though I've seen it reposted on many other sites by now, I'm pretty sure yours is the original. Based on your comments above, it seems like Public Domain might be the best license for your intentions, but take a look at that Coding Horror post and maybe something else will jump out at you.

# re: Recover your XP product key from the registry using C# 10/1/2008 10:00 AM stuart
Excellent code works great but have experienced problems with Dell PC's. Got this from a technet post:

---------------------------------------
What Dell does is:
Create an install with a single KEY that is preactivated. The Key is provided in the winnt.sif file in the sysprep directory so the end user is not even prompted for it.

The end user never sees a prompt to enter a CD Key. Nor does the user need to activate.

The Dell XP CD's have the following characteristics:
1. No CD Key is needed to install
2. They do a BIOS Check so that they can only be installed on a DELL Computer.
3. If you reinstall from the CD, you will need to activate. If you try, it will fail and prompt you to re-enter a valid Key. Simply enter the Key from the COA sticker and you can activate.

The implications are profound. This means that as long as you do not reinstall windows on your original Dell hardware, your OEM key will activate on any new motherboard you might install.

---------------------------------------

Therefore all the keys are the same and will not match the sticker on the Dell case. Shame, would have been nice to use this to audit all PC's.

# re: Recover your XP product key from the registry using C# 1/10/2009 4:45 AM devin
counter strike source


# re: Recover your XP product key from the registry using C# 3/14/2009 5:38 AM Duke
Perfect! Exactly what I needed in order to keep from borking my licensing. Next time I'll track better what keys I applied to what machine.

# re: Recover your XP product key from the registry using C# 5/2/2009 1:21 PM elias
need my register key for driver detective

# re: Recover your XP product key from the registry using C# 11/21/2009 5:40 PM Naresh
I need a code to encrypt 25-digit-character to byte[] format before decrypting the byte[] into string.

# re: Recover your XP product key from the registry using C# 12/29/2009 10:42 AM Richard
Works in Windows 7 also

# re: Recover your XP product key from the registry using C# 1/12/2010 5:47 PM Bob
At times I have a need to recover a COA Product Key from a Hard Drive that will not boot...and the COA sticker is either gone or unreadable-as in those stuck on the bottom surface of a laptop and worn beyond recognition. Usually necessary to have the customer purchase a new copy of XP for no real reason. I have been unable to find a method to do this and am looking to see if anyone here knows.
Thanks

# re: Recover your XP product key from the registry using C# 2/22/2010 3:00 AM Muhammad
There is this Winkeyfinder also http://www.winkeyfinder.com/

# re: Recover your XP product key from the registry using C# 3/4/2010 5:44 AM evilripper
you are great!!! :-D thanks

# re: Recover your XP product key from the registry using C# 3/10/2010 3:23 AM MrGneissGuy
I reversed the algorithm to encode the DPID.

http://pastebin.com/0nrhNH7K

# re: Recover your XP product key from the registry using C# 5/13/2010 8:09 PM wholesale chape windows 7 key
低价批发微软Windows 7产品光盘关键</一> </强>

# re: Recover your XP product key from the registry using C# 5/13/2010 8:10 PM wholesale chape windows 7 key
Wholesale cheap Microsoft Windows 7 product CD key

# re: Recover your XP product key from the registry using C# 5/13/2010 8:12 PM wholesale chape windows 7 key
Wholesale cheap Microsoft Windows 7 office 2010 office 2007 product CD key

Wholesale cheap Microsoft Windows 7 office 2010 office 2007 product CD key

# Wholesale cheap Microsoft Windows 7 office 2010 office 2007 product CD key 7/14/2010 8:13 PM Wholesale cheap
Today surfing the web I found a site selling original windows 7 key , www.windows7key.net
at $ 9.99 , the price is very economical . It also has other licenses also very economical.

wholesale windows 7 product key

free windows 7 download

cheap windows 7 product key

cheap office 2007 product key

cheap office 2010 plus product key

cheap windows xp product key

Norton 360 product key

Windows 7 Ultimate key (32/64 bits) 9.99$

Windows 7 Professional key (32/64 bits) 9.99$

Windows 7 Home Premium key (32/64 bits) 9.99$

Office 2007 Ultimate 24.99$ (32/64 bits)

Office 2007 Professional 24.99$(32/64 bits)

Adobe Dreamweaver

Adobe Photoshop CS4

The key only works with the final retail versions of Windows 7 and office The page URL is: http://www.windows7key.net

According to users who have bought works perfectly , and the complete Windows passes validation Windows Genuine Advantage.


# a good website selling windows, office 7/25/2010 9:46 PM tjacky
Hello,
Today surfing the web I found a site selling original windows 7 key and windows DVDs, http://www.onlinekey.org
the key is priced at $20, . It also has other licenses at discounted prices. You may also request a copy of the installation DVD and the dvd will be sent

to you through USPS.

wholesale windows 7 product key

free windows 7 download

cheap windows 7 product key

cheap office 2007 product key

cheap office 2010 plus product key

cheap windows xp product key

Norton 360 product key

Windows 7 Ultimate key (32/64 bits dvds) 30$

Windows 7 Professional key (32/64 bits dvds) 20$

Windows 7 Home Premium key (32/64 bits dvds) 20$

Office 2010 Professional plus key (32/64 bits dvds) 30$

Office 2007 Ultimate key (dvd)20$

Office 2007 Professional key (dvd) 20$

xbox 4000

xbox 12 + 1

The key only works with the final retail versions of Windows 7 and office The page URL is: http://www.onlinekey.org

According to users who have bought works perfectly , and the complete Windows passes validation Windows Genuine Advantage.


# re: Recover your XP product key from the registry using C# 8/2/2010 5:09 AM ac adapter
very good explain, I can know all the mean.

# http://www.efox-shop.com/ 8/12/2010 2:38 AM hiphones
Hello!everyone!iphone is so expensive.so I like hiphones . d^_^bIt is very interesting.I want to introduce <a href="http://www.efox-shop.com"target=blank> efox-shop/ to you.

# re: Recover your XP product key from the registry using C# 8/14/2010 2:21 PM windows 7 serial only 9.99usd
Today surfing the web I found a site selling original windows 7 key www.windows7serial.net
at $ 9.99 , the price is very economical . It also has other licenses also very economical.

Windows 7 Ultimate key (32/64 bits) 9.99$

Windows 7 Professional key (32/64 bits) 9.99$

Windows 7 Home Premium key (32/64 bits) 9.99$

Office 2007 Ultimate 24.99$ (32/64 bits)

Office 2007 Professional 24.99$(32/64 bits)

windows 7 serial

wholesale windows 7 product key

free windows 7 download

cheap windows 7 product key

cheap office 2007 product key

cheap office 2010 plus product key

cheap windows xp product key

Norton 360 product key

Adobe Dreamweaver

Adobe Photoshop CS4

The key only works with the final retail versions of Windows 7 and office The page URL is: www.windows7serial.net

According to users who have bought works perfectly , and the complete Windows passes validation Windows Genuine Advantage.

# re: Recover your XP product key from the registry using C# 8/14/2010 9:03 PM salekey
KEY online AUTHORIZED RETAILER(www.salekey.net), sales
Welcome www.salekey.net ! SaleKey is a KEY online AUTHORIZED RETAILER,
sales genuine MICROSOFT windows 7 key ,Windows Vista Key,Windows XP Key,
Windows Server 2008 key,Windows 2003 Key,Office 2010 key,Office 2007 Key,
Anti-virus Key,Other Office Key.preferential price,and we guarantee 100% activation,
Or full payment back.WINDOWS 7 DIGITAL DOWNLOAD,LOW PRICE+FREE SHIPPING!

# re: Recover your XP product key from the registry using C# 8/22/2010 4:19 AM Greg Parks
There’s also a software that does this at http://www.windows-key-finder.com/ The advantage is that it can even find out your Windows system CD Key when your Windows can't startup.Also, This software will find many other keys like office XP, office 2007 and more .
You can have a try.
Hope this can help you!
Best wishes!

# re: Recover your XP product key from the registry using C# 9/17/2010 3:09 AM Nike Air Rift
This looks absolutely perfect. All these tinny details are made with lot of background knowledge. I like it a lot. This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.

# re: Recover your XP product key from the registry using C# 9/17/2010 3:18 AM Shure Microphones
What a fun pattern! It's great to hear from you and see what you've sent up to. All of the projects look great! You make it so simple to this.Thanks!

# re: Recover your XP product key from the registry using C# 9/17/2010 3:31 AM Luxury Phone

It is so lucky to read your blog,it is full of useful message.I wish we both can do better in the future.It great honour if you can visit our website,and give us some suggession.

# re: Recover your XP product key from the registry using C# 9/27/2010 12:21 AM louis vuitton boulogne
wow all those garments are so amazing and fabulous I don't come to your blog as often as I would like, but whenever I do I see some really amazing things keep up the good work! =)


# Ugg--the lowest price and the most discount 9/27/2010 12:40 AM UGG
Welcome www.uggbootsales.net !uggbootsales is a online UGG AUTHORIZED RETAILER.
Stock directly from the manufacturer,Original Package,Quality assurance,
Good price+Free shipping+7 days Delivery as usual,100% Satisfaction.


# windows 7 key 11/1/2010 3:22 AM lff5218899@yahoo.cn
Today surfing the web I found a site selling original windows 7 key , www.windows7key.com
at $ 9.99 , the price is very economical . It also has other licenses also very economical.
wholesale windows 7 key
wholesale windows 7 product key
cheap windows xp product key
Norton 360 product key
Windows 7 Ultimate key
Windows 7 Professional key
Windows 7 Home Premium key
Office 2007 Ultimate key
Office 2007 Professional key
Windows 7 Ultimate product key
Windows 7 Professional product key
Windows 7 Home Premium product key
windows 7 enterprise product key
windows 7 enterprise activation product key
windows 7 enterprise key
windows 7 download key
windows 7 cd key
Windows 7 serial key
Windows 7 serial number
genuine windows 7 product key
product key windows 7
Office 2007 Ultimate product key
Office 2007 Professional product key
Office 2007 Enterprise product key
Adobe Dreamweaver
Adobe Photoshop CS4
The key only works with the final retail versions of Windows 7 and office The page URL is: http://www.windows7key.com
According to users who have bought works perfectly , and the complete Windows passes validation Windows Genuine Advantage

# re: Recover your XP product key from the registry using C# 11/17/2010 2:45 AM beck
Your watch can say a lot about your status and style - and who you are. That is why we at Superior-replica.com are offering you our top quality replica watches at amazing prices

# re: Recover your XP product key from the registry using C# 11/30/2010 7:45 PM dan
to check xp product key try xp key checker, is free

# re: Recover your XP product key from the registry using C# 12/1/2010 7:48 PM Dell OptiPlex SX260 CD-RW/DVD Co
thank you for sharing with us

# re: Recover your XP product key from the registry using C# 12/7/2010 2:05 AM Mark
I usually use this product key finder program - http://www.top-password.com/product-key-finder.html
It works well on my computer.

# re: Recover your XP product key from the registry using C# 1/2/2011 4:04 AM Sandy
Today I found a website that selling windows 7 keys and office keys with very good price and excellent service, their site: www.windowskeycity.net, they already had a member group over 4800.
wholesale windows 7 key
wholesale windows 7 product key
cheap windows xp product key
Norton 360 product key
Windows 7 Ultimate key
Windows 7 Professional key
Windows 7 Home Premium key
Office 2007 Ultimate key
Office 2007 Professional key
Windows 7 Ultimate product key
Windows 7 Professional product key
Windows 7 Home Premium product key
windows 7 enterprise product key
windows 7 enterprise activation product key
windows 7 enterprise key
windows 7 download key
windows 7 cd key
Windows 7 serial key
Windows 7 serial number
genuine windows 7 product key
product key windows 7
Office 2007 Ultimate product key
Office 2007 Professional product key
Office 2007 Enterprise product key
Adobe Dreamweaver
Adobe Photoshop CS4
The key only works with the final retail versions of Windows 7 and office The page URL is: www.windowskeycity.net

# re: Recover your XP product key from the registry using C# 1/2/2011 7:36 AM Morry
Today I found a website that selling windows 7 keys and office keys with very good price and excellent service, their site: www.windowsmart.net, they already had a member group over 4800.
wholesale windows 7 key
wholesale windows 7 product key
cheap windows xp product key
Norton 360 product key
Windows 7 Ultimate key
Windows 7 Professional key
Windows 7 Home Premium key
Office 2007 Ultimate key
Office 2007 Professional key
Windows 7 Ultimate product key
Windows 7 Professional product key
Windows 7 Home Premium product key
windows 7 enterprise product key
windows 7 enterprise activation product key
windows 7 enterprise key
windows 7 download key
windows 7 cd key
Windows 7 serial key
Windows 7 serial number
genuine windows 7 product key
product key windows 7
Office 2007 Ultimate product key
Office 2007 Professional product key
Office 2007 Enterprise product key
Adobe Dreamweaver
Adobe Photoshop CS4
The key only works with the final retail versions of Windows 7 and office The page URL is: www.windowsmart.net

# re: Recover your XP product key from the registry using C# 1/14/2011 4:01 AM tiffany jewelry co
wholesale windows 7 key
wholesale windows 7 product key
cheap windows xp product key
Norton 360 product key

# re: Recover your XP product key from the registry using C# 3/15/2011 11:24 PM NFL Hats
All these tinny details are made with lot of background knowledge. I like it a lot.

# re: Recover your XP product key from the registry using C# 6/28/2011 10:14 AM Recover Product Key
Thanks for your useful tip!

# re: Recover your XP product key from the registry using C# 7/9/2011 8:31 AM Tomasz Karlinski
{
// Do the actual decoding.
int digitMapIndex = 0;
for (int j = decodeStringLength - 1; j >= 0; j--)
{
int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
hexPid[j] = (byte)(byteValue / 24);
digitMapIndex = byteValue % 24;
}
decodedChars[i] = digits[digitMapIndex];

}


# re: Recover your XP product key from the registry using vb .net 8/14/2011 9:42 PM Franjo
here is vb .net version. I compiled it and it works - produces some key (for office 2007) but I had no chance to test if it actually works:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim reg1 As Microsoft.Win32.RegistryKey

reg1 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Office\12.0\Registration\{91120000-0031-0000-0000-0000000FF1CE}", False)

Dim digitalProductId As Byte()
digitalProductId = reg1.GetValue("DigitalProductId")

Dim res As String = decode(digitalProductId)
Clipboard.SetDataObject(res)
MsgBox(res)
End Sub

Function decode(ByRef digitalProductId() As Byte) As String
Dim keyStartIndex As Integer = 52
Dim keyEndIndex As Integer = keyStartIndex + 15


Dim digits() As Char = {"B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", _
"T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9"}

' Length of decoded product key
Dim decodeLength As Integer = 29

' Length of decoded product key in byte-form.
' Each byte represents 2 chars.
Dim decodeStringLength As Integer = 15
' Array of containing the decoded product key.
Dim decodedChars(decodeLength) As Char
' Extract byte 52 to 67 inclusive.
Dim HEXPID As New ArrayList

For i As Integer = keyStartIndex To keyEndIndex
HEXPID.Add(digitalProductId(i))
Next

For i As Integer = decodeLength - 1 To 0 Step -1

' Every sixth char is a separator.
If ((i + 1) Mod 6 = 0) Then
decodedChars(i) = "-"
Else

' Do the actual decoding.
Dim digitMapIndex As Integer = 0
For j As Integer = decodeStringLength - 1 To 0 Step -1
Dim byteValue As Integer = (digitMapIndex << 8) Or HEXPID(j)
HEXPID(j) = byteValue \ 24

digitMapIndex = byteValue Mod 24

decodedChars(i) = digits(digitMapIndex)

Next
End If

Next
Return New String(decodedChars)
End Function
End Class





Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: