Add partial support (zcid, rtmr, non-functional kms4k) for vista
Co-authored-by: InvoxiPlayGames <22731889+InvoxiPlayGames@users.noreply.github.com>
This commit is contained in:
@ -34,11 +34,11 @@ namespace LibTSforge.Activators
|
||||
throw new NotSupportedException("Non-VT:IA product key installed.");
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
SPPUtils.KillSPP(version);
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
||||
{
|
||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||
|
||||
@ -57,23 +57,23 @@ namespace LibTSforge.Activators
|
||||
timerTime = crcBindTime / 10000;
|
||||
expiry /= 10000;
|
||||
|
||||
VariableBag avmaBinding = new VariableBag();
|
||||
VariableBag avmaBinding = new VariableBag(version);
|
||||
|
||||
avmaBinding.Blocks.AddRange(new CRCBlock[]
|
||||
avmaBinding.Blocks.AddRange(new CRCBlockModern[]
|
||||
{
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
Key = new byte[] { },
|
||||
Value = BitConverter.GetBytes(crcBindTime),
|
||||
},
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "AVMA4K",
|
||||
},
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
|
@ -29,11 +29,11 @@ namespace LibTSforge.Activators
|
||||
throw new NotSupportedException("Non-Volume:GVLK product key installed.");
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
SPPUtils.KillSPP(version);
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
||||
{
|
||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||
|
||||
@ -42,7 +42,7 @@ namespace LibTSforge.Activators
|
||||
ulong time2 = (ulong)DateTime.UtcNow.ToFileTime();
|
||||
ulong expiry = Constants.TimerMax;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
if (version == PSVersion.Vista || version == PSVersion.Win7)
|
||||
{
|
||||
unknown = 0x800000000;
|
||||
time1 = 0;
|
||||
@ -58,86 +58,119 @@ namespace LibTSforge.Activators
|
||||
expiry /= 10000;
|
||||
}
|
||||
|
||||
byte[] hwidBlock = Constants.UniversalHWIDBlock;
|
||||
byte[] kmsResp;
|
||||
|
||||
switch (version)
|
||||
if (version == PSVersion.Vista)
|
||||
{
|
||||
case PSVersion.Win7:
|
||||
kmsResp = Constants.KMSv4Response;
|
||||
break;
|
||||
case PSVersion.Win8:
|
||||
kmsResp = Constants.KMSv5Response;
|
||||
break;
|
||||
case PSVersion.WinBlue:
|
||||
case PSVersion.WinModern:
|
||||
kmsResp = Constants.KMSv6Response;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unsupported PSVersion.");
|
||||
VistaTimer vistaTimer = new VistaTimer();
|
||||
vistaTimer.Time = time2;
|
||||
vistaTimer.Expiry = expiry;
|
||||
|
||||
string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId);
|
||||
|
||||
store.DeleteBlock(key, vistaTimerName);
|
||||
store.DeleteBlock(key, "45E81E65-6944-422E-9C02-D83F7E5F5A58");
|
||||
|
||||
store.AddBlocks(new PSBlock[]
|
||||
{
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.TIMER,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = vistaTimerName,
|
||||
Data = vistaTimer.CastToArray()
|
||||
},
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = "45E81E65-6944-422E-9C02-D83F7E5F5A58",
|
||||
Data = new Guid().ToByteArray()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
VariableBag kmsBinding = new VariableBag();
|
||||
|
||||
kmsBinding.Blocks.AddRange(new CRCBlock[]
|
||||
else
|
||||
{
|
||||
new CRCBlock
|
||||
byte[] hwidBlock = Constants.UniversalHWIDBlock;
|
||||
byte[] kmsResp;
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case PSVersion.Win7:
|
||||
kmsResp = Constants.KMSv4Response;
|
||||
break;
|
||||
case PSVersion.Win8:
|
||||
kmsResp = Constants.KMSv5Response;
|
||||
break;
|
||||
case PSVersion.WinBlue:
|
||||
case PSVersion.WinModern:
|
||||
kmsResp = Constants.KMSv6Response;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unsupported PSVersion.");
|
||||
}
|
||||
|
||||
VariableBag kmsBinding = new VariableBag(version);
|
||||
|
||||
kmsBinding.Blocks.AddRange(new CRCBlockModern[]
|
||||
{
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
Key = new byte[] { },
|
||||
Value = kmsResp
|
||||
},
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "msft:rm/algorithm/hwid/4.0"
|
||||
},
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
KeyAsStr = "SppBindingLicenseData",
|
||||
Value = hwidBlock
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (version == PSVersion.WinModern)
|
||||
{
|
||||
kmsBinding.Blocks.AddRange(new CRCBlock[]
|
||||
if (version == PSVersion.WinModern)
|
||||
{
|
||||
new CRCBlock
|
||||
kmsBinding.Blocks.AddRange(new CRCBlockModern[]
|
||||
{
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "massgrave.dev"
|
||||
},
|
||||
new CRCBlock
|
||||
new CRCBlockModern
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "6969"
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
byte[] kmsBindingData = kmsBinding.Serialize();
|
||||
byte[] kmsBindingData = kmsBinding.Serialize();
|
||||
|
||||
Timer kmsTimer = new Timer
|
||||
{
|
||||
Unknown = unknown,
|
||||
Time1 = time1,
|
||||
Time2 = time2,
|
||||
Expiry = expiry
|
||||
};
|
||||
Timer kmsTimer = new Timer
|
||||
{
|
||||
Unknown = unknown,
|
||||
Time1 = time1,
|
||||
Time2 = time2,
|
||||
Expiry = expiry
|
||||
};
|
||||
|
||||
string storeVal = string.Format("msft:spp/kms/bind/2.0/store/{0}/{1}", appId, actId);
|
||||
string timerVal = string.Format("msft:spp/kms/bind/2.0/timer/{0}/{1}", appId, actId);
|
||||
string storeVal = string.Format("msft:spp/kms/bind/2.0/store/{0}/{1}", appId, actId);
|
||||
string timerVal = string.Format("msft:spp/kms/bind/2.0/timer/{0}/{1}", appId, actId);
|
||||
|
||||
store.DeleteBlock(key, storeVal);
|
||||
store.DeleteBlock(key, timerVal);
|
||||
store.DeleteBlock(key, storeVal);
|
||||
store.DeleteBlock(key, timerVal);
|
||||
|
||||
store.AddBlocks(new PSBlock[]
|
||||
{
|
||||
store.AddBlocks(new PSBlock[]
|
||||
{
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
@ -154,10 +187,11 @@ namespace LibTSforge.Activators
|
||||
ValueAsStr = timerVal,
|
||||
Data = kmsTimer.CastToArray()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SLApi.RefreshLicenseStatus();
|
||||
SPPUtils.RestartSPP(version);
|
||||
SLApi.FireStateChangedEvent(appId);
|
||||
Logger.WriteLine("Activated using KMS4k successfully.");
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ namespace LibTSforge.Activators
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using LibTSforge.Crypto;
|
||||
using LibTSforge.PhysicalStore;
|
||||
using LibTSforge.SPP;
|
||||
@ -46,16 +48,16 @@ namespace LibTSforge.Activators
|
||||
string instId = SLApi.GetInstallationID(actId);
|
||||
Guid pkeyId = SLApi.GetInstalledPkeyID(actId);
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
if (version == PSVersion.Vista || version == PSVersion.Win7)
|
||||
{
|
||||
Deposit(actId, instId);
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
SPPUtils.KillSPP(version);
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
||||
{
|
||||
byte[] hwidBlock = Constants.UniversalHWIDBlock;
|
||||
|
||||
@ -65,7 +67,11 @@ namespace LibTSforge.Activators
|
||||
|
||||
byte[] iidHash;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
if (version == PSVersion.Vista)
|
||||
{
|
||||
iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId)).Take(0x10).ToArray();
|
||||
}
|
||||
else if (version == PSVersion.Win7)
|
||||
{
|
||||
iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId));
|
||||
}
|
||||
@ -82,11 +88,44 @@ namespace LibTSforge.Activators
|
||||
throw new InvalidDataException("Failed to get product key data for activation ID " + actId + ".");
|
||||
}
|
||||
|
||||
VariableBag pkb = new VariableBag(keyBlock.Data);
|
||||
VariableBag pkb = new VariableBag(keyBlock.Data, version);
|
||||
|
||||
byte[] pkeyData;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
if (version == PSVersion.Vista)
|
||||
{
|
||||
pkeyData = pkb.GetBlock("PKeyBasicInfo").Value;
|
||||
string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray());
|
||||
string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray());
|
||||
|
||||
uint group = 0;
|
||||
uint.TryParse(extPid.Split('-')[1], out group);
|
||||
|
||||
if (group == 0)
|
||||
{
|
||||
throw new FormatException("Extended PID has invalid format.");
|
||||
}
|
||||
|
||||
ulong shortauth;
|
||||
|
||||
try
|
||||
{
|
||||
shortauth = BitConverter.ToUInt64(Convert.FromBase64String(uniqueId.Split('&')[1]), 0);
|
||||
} catch
|
||||
{
|
||||
throw new FormatException("Key Unique ID has invalid format.");
|
||||
}
|
||||
|
||||
Console.WriteLine(group);
|
||||
Console.WriteLine(shortauth);
|
||||
|
||||
shortauth |= (ulong)group << 41;
|
||||
|
||||
Console.WriteLine(shortauth);
|
||||
|
||||
pkeyData = BitConverter.GetBytes(shortauth);
|
||||
}
|
||||
else if (version == PSVersion.Win7)
|
||||
{
|
||||
pkeyData = pkb.GetBlock("SppPkeyShortAuthenticator").Value;
|
||||
}
|
||||
@ -99,26 +138,34 @@ namespace LibTSforge.Activators
|
||||
store.SetBlock(key, pkeyId.ToString(), pkb.Serialize());
|
||||
|
||||
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
||||
writer.Write(0x20);
|
||||
writer.Write(iidHash.Length);
|
||||
writer.Write(iidHash);
|
||||
writer.Write(hwidBlock.Length);
|
||||
writer.Write(hwidBlock);
|
||||
byte[] tsHwidData = writer.GetBytes();
|
||||
|
||||
writer = new BinaryWriter(new MemoryStream());
|
||||
writer.Write(0x20);
|
||||
writer.Write(iidHash.Length);
|
||||
writer.Write(iidHash);
|
||||
writer.Write(pkeyData.Length);
|
||||
writer.Write(pkeyData);
|
||||
byte[] tsPkeyInfoData = writer.GetBytes();
|
||||
|
||||
string phoneVersion = version == PSVersion.Vista ? "6.0" : "7.0";
|
||||
Guid indexSlid = version == PSVersion.Vista ? actId : pkeyId;
|
||||
string hwidBlockName = string.Format("msft:Windows/{0}/Phone/Cached/HwidBlock/{1}", phoneVersion, indexSlid);
|
||||
string pkeyInfoName = string.Format("msft:Windows/{0}/Phone/Cached/PKeyInfo/{1}", phoneVersion, indexSlid);
|
||||
|
||||
store.DeleteBlock(key, hwidBlockName);
|
||||
store.DeleteBlock(key, pkeyInfoName);
|
||||
|
||||
store.AddBlocks(new PSBlock[] {
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = "msft:Windows/7.0/Phone/Cached/HwidBlock/" + pkeyId,
|
||||
ValueAsStr = hwidBlockName,
|
||||
Data = tsHwidData
|
||||
},
|
||||
new PSBlock
|
||||
@ -126,18 +173,18 @@ namespace LibTSforge.Activators
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = "msft:Windows/7.0/Phone/Cached/PKeyInfo/" + pkeyId,
|
||||
ValueAsStr = pkeyInfoName,
|
||||
Data = tsPkeyInfoData
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (version != PSVersion.Win7)
|
||||
if (version != PSVersion.Vista && version != PSVersion.Win7)
|
||||
{
|
||||
Deposit(actId, instId);
|
||||
}
|
||||
|
||||
SLApi.RefreshLicenseStatus();
|
||||
SPPUtils.RestartSPP(version);
|
||||
SLApi.FireStateChangedEvent(appId);
|
||||
Logger.WriteLine("Activated using ZeroCID successfully.");
|
||||
}
|
||||
|
Reference in New Issue
Block a user