Standard XML Format for Microsoft Product Keys

Discussion in 'Mixed Languages' started by Calistoga, Nov 12, 2010.

  1. Calistoga

    Calistoga MDL Senior Member

    Jul 25, 2009
    420
    198
    10
    #1 Calistoga, Nov 12, 2010
    Last edited by a moderator: Apr 20, 2017
    A Work in Progress

    There has been developed a lot of projects here at MDL. Some of them utilizes a collection of OEM:SLP keys for their operation. Some automate the installation of GVLK keys for Office 2010. Some install Windows 7 KMS Client keys or OEM:SLP keys. A significant part of creating such an application involves creating a list, or format, of keys so that it can be parsed and used efficiently.

    I have attempted to create a format that can be reused by all those applications. This will allow us to have one central - regularly updated - key source, which might simplify application development. I do not expect everyone to use this format, but if it can be of use for someone, then that's great.

    I opted for XML, and a short snippet of the format is presented below:
    Code:
    <microsoft xmlns="urn:clstgamdlmspk">
      <product name="Windows Vista" slp="2.0">
        <edition name="Starter">
          <slp key="23Q4W-YQPHY-TY89Y-7Q3VX-W72KT">
            <pid>OEM-7332204-00589</pid>
            <oem>Lenovo</oem>
          </slp>
          <slp key="2X4FQ-86GPG-WWD8J-MF47M-MGMT3">
            <pid>OEM-7332204-00585</pid>
            <oem>Unknown</oem>
          </slp>
        </edition>
      </product>
    </microsoft>
    The following is how the format is structured:
    "Microsoft" is the root element.
    [​IMG]
    A complete copy of the XML file can be found in the post attachment View attachment [XML] oemslp.zip .

    1 Microsoft .NET 3.5 Library oemslp.dll

    I am working on a C# .NET library that handles the interaction with the XML engine, so that any .NET programmer can take advantage of the format without any prior knowledge of XML.

    The format is intended to support all kinds of Microsoft product keys (such as Microsoft Office 2010 GVLK's), but my .NET library currently supports only OEM:SLP keys.

    An updated copy of the XML file provided in this post ( View attachment [XML] oemslp.zip ) will be embedded in the library on each update.

    The library contains two public classes in the namespace Microsoft.Licensing;
    • OemSlp
    • OemSlpCollection

    [​IMG]
    1.1 Contructors
    Code:
    public OemSlp(string product, string edition, string oem, string key, string pid, string version)
    • string product: the name of the product, e.g. "Windows 7"
    • string edition: the product edition, e.g. "Professional"
    • string oem: The owner of the OEM:SLP key, e.g. "Dell"
    • string key: The OEM:SLP key itself
    • string pid: The Product ID of the key
    • string version: The SLP version corresponding to the key, e.g. "2.1"

    Code:
    public OemSlpCollection()
    The OemSlpCollection class implements the Collection<T> class of the .NET framework, where T == OemSlp.

    1.2 Example usage
    Code:
    using Microsoft.Licensing;
    
    OemSlpCollection osc = new OemSlpCollection();
    osc.Load(); // Load entries from the embedded XML file.
    
    // Loop through all keys and print them to the console.
    foreach (OemSlp key in osc)
    {
        Console.WriteLine(key.Key);
    }
    
    // Loop through all Dell keys and print them to the console.
    foreach (OemSlp key in osc.GetByManufacturer("Dell"))
    {
        Console.WriteLine(key.Key);
    }
    
    // Loop through all keys containing the letter sequence "HP" and print them to the console.
    foreach (OemSlp key in osc.GetByProductKey("HP"))
    {
        Console.WriteLine(key.Key);
    }
    How to save a set of keys:
    Code:
    using Microsoft.Licensing;
    
    OemSlpCollection osc = new OemSlpCollection();
    osc.Load(); // Load entries from the embedded XML file.
    
    OemSlpCollection oscDellKeys = new OemSlpCollection();
    oscDellKeys.AddRange(osc.GetByManufacturer("Dell").ToArray<OemSlp>());
    
    oscDellKeys.Save(@"C:\oemslp_dell.xml");

    Download
    - XML file: View attachment [XML] oemslp.zip
    - .NET Library v1.0.0.0: Mediafire
    - Beta: Mediafire (added EditionID, ActivationID and CryptoID. Changed a few methods, removed some. Will try to assemble enough willpower to write a proper changelog).

    Issues does not apply to the beta
    - The library will currently write "Generated by slpmgrcli with oemslp.dll" in the comment header of generated XML files. This will be fixed - and optional.

    1.3 Planning
    I plan on supporting online key sources, such as the Windows 7 OEM SLP Key Collection. The contents of that thread would eventually be parsed and converted to XML.

    Considering to add EditionID, ActivationID and CryptoID - as well as maybe a unique identifier for manufacturers. Such as one GUID for Dell, one for HP etc.

    2 Feedback
    Feedback, such as constructive critique or suggestions are most appreciated.

    3 Credits
    OemSlp.IsValidProductKey() Uses a regular expression by MasterDisaster.
    OemSlp.ClientProductKey retrieves the local Windows product key and decrypts it using this class.

    (Admins, do you have any opportunity to allow XML as attachment file type?)
     
  2. Calistoga

    Calistoga MDL Senior Member

    Jul 25, 2009
    420
    198
    10
    #2 Calistoga, Nov 15, 2010
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Slpmgrcli

    Software Licensing Manager v0.1.0.0
    [​IMG]
    Console-based consumer of the .NET library. Requires .NET 3.5.

    Download: Mediafire

    Examples
    Code:
    slpmgrcli -oem:dell -edition:ultimate -save:"C:\dell_ultimate.xml"
    Code:
    slpmgrcli -slp:2.1 -oem:hp
    Code:
    slpmgrcli -product:"Windows Vista" -edition:professional -save:"C:\vista_pro.xml"
    Help
    Code:
    slpmgrcli -help
     
  3. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,503
    3,614
    120
    I have created a export function on my OEM:SLP collection using Calistoga's 'Standard XML Format for Microsoft Product Keys', check it out here: http://d-fault.nl/keys/
     
  4. Calistoga

    Calistoga MDL Senior Member

    Jul 25, 2009
    420
    198
    10
    #4 Calistoga, Nov 19, 2010
    Last edited by a moderator: Apr 20, 2017
    (OP)
    I've been discussing with FreeStyler, and he suggested to add OEMIDs to the XML file - which I think is a great idea. I'm currently looking into a practical way of doing this.

    One way this can be done is
    1. Define a list of OEMs in a separate element in the XML document
    2. Give each OEM a unique ID (GUID?)
    3. Point each OEM:SLP key to the manufacturer with name and ID
    4. Support more than one OEM per key

    Example:
    Code:
    <microsoft xmlns="urn:clstgamdlmspk">
      <manufacturers>
        <oem name="Toshiba" id="461C6DE6-E72B-4B9D-8F87-A0C7996240AB">
          <oemid>TOSASU</oemid>
          <oemid>TOSCPL</oemid>
          <oemid>TOSHIB</oemid>
          <oemid>TOSINV</oemid>
          <oemid>TOSQCI</oemid>
        </oem>
        <oem name="Acer" id="AC99BFBA-B81B-43FB-9EBD-F12132C4999A">
          <oemid>ACRSYS</oemid>
        </oem>
      </manufacturers>
    [all the products/editions/keys here]
    </microsoft>
    The point of using a GUID to reference the OEMs instead of their names, is because it is more precise than when just grouping keys together based on the name of the manufacturer, case-sensitive or insensitive matching, what if there is a parenthesis in the name? Ex: (Not Verified)
    Code:
    <slp key="38MK6-4QYC6-GJQQX-9DYQ4-H9MQD">
      <pid>XXXXX-OEM-7332141-00232</pid>
      <oem name="Toshiba">461C6DE6-E72B-4B9D-8F87-A0C7996240AB</oem>
    </slp>
    I also want to include a new attribute on the <oem/> element, "verified":
    Code:
    <oem name="Toshiba" verified="True">461C6DE6-E72B-4B9D-8F87-A0C7996240AB</oem>
    Then there's the question on how one key could reference two OEMs. Maybe simply by having two <oem></oem> elements. Should there be any casing rules? Capital first letter, and the rest lowercase? Such as: Acer instead of ACER.

    Maybe nothing will be changed after all. Just thinking out loud, thoughts are welcome. I just want the format to be useful and complete, regardless of how many will actually use it.