Initial commit
Co-authored-by: neko <109633131+nekoppai@users.noreply.github.com> Co-authored-by: Lyssa <75037904+thecatontheceiling@users.noreply.github.com> Co-authored-by: abbodi1406 <33669284+abbodi1406@users.noreply.github.com>
This commit is contained in:
126
LibTSforge/Activators/AVMA4K.cs
Normal file
126
LibTSforge/Activators/AVMA4K.cs
Normal file
@ -0,0 +1,126 @@
|
||||
namespace LibTSforge.Activators
|
||||
{
|
||||
using System;
|
||||
using LibTSforge.PhysicalStore;
|
||||
using LibTSforge.SPP;
|
||||
|
||||
public static class AVMA4k
|
||||
{
|
||||
public static void Activate(PSVersion version, bool production, Guid actId)
|
||||
{
|
||||
if (version != PSVersion.WinModern)
|
||||
{
|
||||
throw new NotSupportedException("AVMA licenses are not available for this product.");
|
||||
}
|
||||
|
||||
Guid appId;
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
appId = SLApi.WINDOWS_APP_ID;
|
||||
actId = SLApi.GetDefaultActivationID(appId, false);
|
||||
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
throw new NotSupportedException("No applicable activation IDs found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appId = SLApi.GetAppId(actId);
|
||||
}
|
||||
|
||||
if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "VT:IA")
|
||||
{
|
||||
throw new NotSupportedException("Non-VT:IA product key installed.");
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
{
|
||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||
|
||||
ulong unknown = 0;
|
||||
ulong time1;
|
||||
ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime();
|
||||
ulong timerTime;
|
||||
|
||||
ulong expiry = Constants.TimerMax;
|
||||
|
||||
long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0);
|
||||
long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0);
|
||||
long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0);
|
||||
|
||||
time1 = (ulong)(creationTime + tickCount + deltaTime);
|
||||
timerTime = crcBindTime / 10000;
|
||||
expiry /= 10000;
|
||||
|
||||
VariableBag avmaBinding = new VariableBag();
|
||||
|
||||
avmaBinding.Blocks.AddRange(new CRCBlock[]
|
||||
{
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
Key = new byte[] { },
|
||||
Value = BitConverter.GetBytes(crcBindTime),
|
||||
},
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "AVMA4K",
|
||||
},
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "00491-50000-00001-AA666",
|
||||
}
|
||||
});
|
||||
|
||||
byte[] avmaBindingData = avmaBinding.Serialize();
|
||||
|
||||
Timer avmaTimer = new Timer
|
||||
{
|
||||
Unknown = unknown,
|
||||
Time1 = time1,
|
||||
Time2 = timerTime,
|
||||
Expiry = expiry
|
||||
};
|
||||
|
||||
string storeVal = string.Format("msft:spp/ia/bind/1.0/store/{0}/{1}", appId, actId);
|
||||
string timerVal = string.Format("msft:spp/ia/bind/1.0/timer/{0}/{1}", appId, actId);
|
||||
|
||||
store.DeleteBlock(key, storeVal);
|
||||
store.DeleteBlock(key, timerVal);
|
||||
|
||||
store.AddBlocks(new PSBlock[]
|
||||
{
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0x400,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = storeVal,
|
||||
Data = avmaBindingData,
|
||||
},
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.TIMER,
|
||||
Flags = 0x4,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = timerVal,
|
||||
Data = avmaTimer.CastToArray()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SLApi.RefreshLicenseStatus();
|
||||
SLApi.FireStateChangedEvent(appId);
|
||||
Logger.WriteLine("Activated using AVMA4k successfully.");
|
||||
}
|
||||
}
|
||||
}
|
165
LibTSforge/Activators/KMS4K.cs
Normal file
165
LibTSforge/Activators/KMS4K.cs
Normal file
@ -0,0 +1,165 @@
|
||||
namespace LibTSforge.Activators
|
||||
{
|
||||
using System;
|
||||
using LibTSforge.PhysicalStore;
|
||||
using LibTSforge.SPP;
|
||||
|
||||
public class KMS4k
|
||||
{
|
||||
public static void Activate(PSVersion version, bool production, Guid actId)
|
||||
{
|
||||
Guid appId;
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
appId = SLApi.WINDOWS_APP_ID;
|
||||
actId = SLApi.GetDefaultActivationID(appId, true);
|
||||
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
throw new NotSupportedException("No applicable activation IDs found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appId = SLApi.GetAppId(actId);
|
||||
}
|
||||
|
||||
if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "Volume:GVLK")
|
||||
{
|
||||
throw new NotSupportedException("Non-Volume:GVLK product key installed.");
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
{
|
||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||
|
||||
ulong unknown = 0;
|
||||
ulong time1;
|
||||
ulong time2 = (ulong)DateTime.UtcNow.ToFileTime();
|
||||
ulong expiry = Constants.TimerMax;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
{
|
||||
unknown = 0x800000000;
|
||||
time1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0);
|
||||
long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0);
|
||||
long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0);
|
||||
|
||||
time1 = (ulong)(creationTime + tickCount + deltaTime);
|
||||
time2 /= 10000;
|
||||
expiry /= 10000;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
kmsBinding.Blocks.AddRange(new CRCBlock[]
|
||||
{
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
Key = new byte[] { },
|
||||
Value = kmsResp
|
||||
},
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "msft:rm/algorithm/hwid/4.0"
|
||||
},
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.BINARY,
|
||||
KeyAsStr = "SppBindingLicenseData",
|
||||
Value = hwidBlock
|
||||
}
|
||||
});
|
||||
|
||||
if (version == PSVersion.WinModern)
|
||||
{
|
||||
kmsBinding.Blocks.AddRange(new CRCBlock[]
|
||||
{
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "massgrave.dev"
|
||||
},
|
||||
new CRCBlock
|
||||
{
|
||||
DataType = CRCBlockType.STRING,
|
||||
Key = new byte[] { },
|
||||
ValueAsStr = "6969"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
byte[] kmsBindingData = kmsBinding.Serialize();
|
||||
|
||||
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);
|
||||
|
||||
store.DeleteBlock(key, storeVal);
|
||||
store.DeleteBlock(key, timerVal);
|
||||
|
||||
store.AddBlocks(new PSBlock[]
|
||||
{
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = (version == PSVersion.WinModern) ? (uint)0x400 : 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = storeVal,
|
||||
Data = kmsBindingData
|
||||
},
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.TIMER,
|
||||
Flags = (version == PSVersion.Win7) ? (uint)0 : 0x4,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = timerVal,
|
||||
Data = kmsTimer.CastToArray()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SLApi.RefreshLicenseStatus();
|
||||
SLApi.FireStateChangedEvent(appId);
|
||||
Logger.WriteLine("Activated using KMS4k successfully.");
|
||||
}
|
||||
}
|
||||
}
|
145
LibTSforge/Activators/ZeroCID.cs
Normal file
145
LibTSforge/Activators/ZeroCID.cs
Normal file
@ -0,0 +1,145 @@
|
||||
namespace LibTSforge.Activators
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibTSforge.Crypto;
|
||||
using LibTSforge.PhysicalStore;
|
||||
using LibTSforge.SPP;
|
||||
|
||||
public static class ZeroCID
|
||||
{
|
||||
public static void Deposit(Guid actId, string instId)
|
||||
{
|
||||
uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID);
|
||||
Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status));
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to deposit fake CID.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Activate(PSVersion version, bool production, Guid actId)
|
||||
{
|
||||
Guid appId;
|
||||
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
appId = SLApi.WINDOWS_APP_ID;
|
||||
actId = SLApi.GetDefaultActivationID(appId, false);
|
||||
|
||||
if (actId == Guid.Empty)
|
||||
{
|
||||
throw new NotSupportedException("No applicable activation IDs found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appId = SLApi.GetAppId(actId);
|
||||
}
|
||||
|
||||
if (!SLApi.IsPhoneActivatable(actId))
|
||||
{
|
||||
throw new NotSupportedException("Phone license is unavailable for this product.");
|
||||
}
|
||||
|
||||
string instId = SLApi.GetInstallationID(actId);
|
||||
Guid pkeyId = SLApi.GetInstalledPkeyID(actId);
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
{
|
||||
Deposit(actId, instId);
|
||||
}
|
||||
|
||||
Utils.KillSPP();
|
||||
|
||||
Logger.WriteLine("Writing TrustedStore data...");
|
||||
|
||||
using (IPhysicalStore store = Utils.GetStore(version, production))
|
||||
{
|
||||
byte[] hwidBlock = Constants.UniversalHWIDBlock;
|
||||
|
||||
Logger.WriteLine("Activation ID: " + actId);
|
||||
Logger.WriteLine("Installation ID: " + instId);
|
||||
Logger.WriteLine("Product Key ID: " + pkeyId);
|
||||
|
||||
byte[] iidHash;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
{
|
||||
iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId));
|
||||
}
|
||||
else
|
||||
{
|
||||
iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId + '\0' + Constants.ZeroCID));
|
||||
}
|
||||
|
||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||
PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString());
|
||||
|
||||
if (keyBlock == null)
|
||||
{
|
||||
throw new InvalidDataException("Failed to get product key data for activation ID " + actId + ".");
|
||||
}
|
||||
|
||||
VariableBag pkb = new VariableBag(keyBlock.Data);
|
||||
|
||||
byte[] pkeyData;
|
||||
|
||||
if (version == PSVersion.Win7)
|
||||
{
|
||||
pkeyData = pkb.GetBlock("SppPkeyShortAuthenticator").Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkeyData = pkb.GetBlock("SppPkeyPhoneActivationData").Value;
|
||||
}
|
||||
|
||||
pkb.DeleteBlock("SppPkeyVirtual");
|
||||
store.SetBlock(key, pkeyId.ToString(), pkb.Serialize());
|
||||
|
||||
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
||||
writer.Write(0x20);
|
||||
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);
|
||||
writer.Write(pkeyData.Length);
|
||||
writer.Write(pkeyData);
|
||||
byte[] tsPkeyInfoData = writer.GetBytes();
|
||||
|
||||
store.AddBlocks(new PSBlock[] {
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = "msft:Windows/7.0/Phone/Cached/HwidBlock/" + pkeyId,
|
||||
Data = tsHwidData
|
||||
},
|
||||
new PSBlock
|
||||
{
|
||||
Type = BlockType.NAMED,
|
||||
Flags = 0,
|
||||
KeyAsStr = key,
|
||||
ValueAsStr = "msft:Windows/7.0/Phone/Cached/PKeyInfo/" + pkeyId,
|
||||
Data = tsPkeyInfoData
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (version != PSVersion.Win7)
|
||||
{
|
||||
Deposit(actId, instId);
|
||||
}
|
||||
|
||||
SLApi.RefreshLicenseStatus();
|
||||
SLApi.FireStateChangedEvent(appId);
|
||||
Logger.WriteLine("Activated using ZeroCID successfully.");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user