Superfly-Inc / ShowKeyPlus

Windows product key finder and validation checker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There's no code in here.

kriskomar opened this issue · comments

It's not open source - is there any code in particular you are interested in?

I can't speak for the other individual but I'd love to see documentation or code on how to determine what version of Windows a key is for.

@Firehawke

It decrypts the key from the Base64 encrypted pkconfig file using the pidgenx dll's

I don't like posting isolated code but to give you an idea... (the Native methods class just loads dll's and frees memory etc - old school stuff)

`class PKChecker
{

public static byte[] BPrivateKey { get; private set; } = { 0xfe, 0x31, 0x98, 0x75, 0xfb, 0x48, 0x84, 0x86, 0x9c, 0xf3, 0xf1, 0xce, 0x99, 0xa8, 0x90, 0x64,
0xab, 0x57, 0x1f, 0xca, 0x47, 0x04, 0x50, 0x58, 0x30, 0x24, 0xe2, 0x14, 0x62, 0x87, 0x79, 0xa0 };

    public async Task<List<string>> CheckProductKey(string ProductKey, string Edition,bool Check)
    {
        List<string> result = new List<string>();
        int RetID = 0;
        byte[] gpid = new byte[0x32];
        byte[] opid = new byte[0xA4];
        byte[] npid = new byte[0x04F8];

        IntPtr PID = Marshal.AllocHGlobal(0x32);
        IntPtr DPID = Marshal.AllocHGlobal(0xA4);
        IntPtr DPID4 = Marshal.AllocHGlobal(0x04F8);
        string PKeyPath = string.Empty;
        string temp = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
        string PidDll = temp + @"\pidgenx.dll";

        try
        {
            switch (Edition)
            {
                case "Win10":
                    temp += "\\Win10pkeyconfig.xrm-ms";
                    File.WriteAllText(temp, GetResourceTextFile("Win10pkeyconfig.xrm-ms"));
                    PKeyPath = temp;
                    break;
                case "Win8":
                    temp += "\\Win8pkeyconfig.xrm-ms";
                    File.WriteAllText(temp, GetResourceTextFile("Win8pkeyconfig.xrm-ms"));
                    PKeyPath = temp;
                    break;
                case "Win7":
                    temp += "\\Win7pkeyconfig.xrm-ms";
                    File.WriteAllText(temp, GetResourceTextFile("Win7pkeyconfig.xrm-ms"));
                    PKeyPath = temp;
                    break;
                case "Win7SLP":
                    temp += "\\Win7SLPpkeyconfig.xrm-ms";
                    File.WriteAllText(temp, GetResourceTextFile("Win7SLPpkeyconfig.xrm-ms"));
                    PKeyPath = temp;
                    break;
                default:
                    PKeyPath = Environment.SystemDirectory + @"\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms";
                    break;
            }

            string MSPID = "00000";

            gpid[0] = 0x32;
            opid[0] = 0xA4;
            npid[0] = 0xF8;
            npid[1] = 0x04;
         
            Marshal.Copy(gpid, 0, PID, 0x32);
            Marshal.Copy(opid, 0, DPID, 0xA4);
            Marshal.Copy(npid, 0, DPID4, 0x04F8);

            IntPtr pDll = IntPtr.Zero;
            GetResourceFile(PidDll);
            pDll = NativeMethods.LoadLibrary(PidDll);

            IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "PidGenX");
            NativeMethods.PidGenX PidgenX = (NativeMethods.PidGenX) Marshal.GetDelegateForFunctionPointer(
                                                                        pAddressOfFunctionToCall,
                                                                        typeof(NativeMethods.PidGenX));

             await Task.Run(() => RetID = PidgenX(ProductKey, PKeyPath, MSPID, 0, PID, DPID, DPID4));

            File.SetAttributes(PKeyPath, FileAttributes.Hidden);
            File.SetAttributes(PidDll, FileAttributes.Hidden);

            if (RetID == 0)
            {

                Marshal.Copy(DPID4, npid, 0, npid.Length);
                string eid = GetString(npid, 0x0008);
                string aid = GetString(npid, 0x0088);
                string edi = GetString(npid, 0x0118);
                string lic = GetString(npid, 0x0478);
                string prd = GetProductDescription(PKeyPath, "{" + aid + "}", edi);
                string mak = prd.Contains("mak".ToUpper()) ? GetCount(eid) : string.Empty;

                if (Check)
                {
                    result.Add(prd);
                    result.Add(lic);
                    result.Add(mak.Contains("Error") ? string.Empty : mak);
                }
                else
                {
                    result.Add(prd);
                }
            }
               
            else
            {
               result.Add("Invalid Key");
               result.Add("Not applicable");
               result.Add("");
            }

            bool res = NativeMethods.FreeLibrary(pDll);
        }  
        
        catch (Exception ex) {
            throw new Exception(ex.Message);
        }

        finally
        {
            Marshal.FreeHGlobal(DPID);
            Marshal.FreeHGlobal(DPID4);

            if (File.Exists(temp)) File.Delete(temp);
            {
                try { File.Delete(PidDll); }
                catch (DirectoryNotFoundException) { }
            }

            if (File.Exists(PidDll))
            {
                try {File.Delete(PidDll); }
                catch (DirectoryNotFoundException) { }
            }
        }
   return result;
   }
    static string GetString(byte[] bytes, int index)
    {
        int n = index;
        while (!(bytes[n] == 0 && bytes[n + 1] == 0)) n++;
        return Encoding.ASCII.GetString(bytes, index, n - index).Replace("\0", "");
    }    `