Skip to content

Instantly share code, notes, and snippets.

@Wack0
Last active June 20, 2024 02:10
Show Gist options
  • Save Wack0/663dc0a91056cf4431365f77036f3bf3 to your computer and use it in GitHub Desktop.
Save Wack0/663dc0a91056cf4431365f77036f3bf3 to your computer and use it in GitHub Desktop.
clipc!GetOfflineDeviceUniqueID PoC.
using System;
using System.Runtime.InteropServices;
enum RETRIEVAL_METHOD {
ODUID_DEFAULT = 0,
ODUID_TPM_EK,
ODUID_UEFI_VARIABLE_TPM,
ODUID_UEFI_VARIABLE_RANDOMSEED,
ODUID_UEFI_DEV_LOCK_UNLOCK, // there is no code for this in clipsvc.dll, given the enum name, this could be Windows Phone only?
ODUID_XBOX_CONSOLE_ID, // this should never be seen, with xbox one a different function is called to get the console ID
ODUID_REGISTRY_ENTRY // "fan name", RS2+ only.
}
class GODUID {
[DllImport("clipc.dll")]
// HRESULT GetOfflineDeviceUniqueID(DWORD cbSalt, PBYTE pbSalt, RETRIEVAL_METHOD* oMethod,PDWORD pcbSystemId,PBYTE rgbSystemId,PDWORD unkLength,PVOID unkPtr);
static extern int GetOfflineDeviceUniqueID(uint cbSalt, byte[] pbSalt, out RETRIEVAL_METHOD oMethod,ref uint pcbSystemId,byte[] rgbSystemId,uint unk1,uint unk2);
public static void Main(string[] args) {
RETRIEVAL_METHOD rm;
uint cbSalt;
byte[] pbSalt;
if (args.Length > 0) {
var arg = args[0];
if ((arg.StartsWith("0x")) && ((arg.Length & 1) == 0)) {
pbSalt = new byte[(arg.Length - 2) / 2];
for (int i = 2; i < arg.Length; i += 2)
pbSalt[(i / 2) - 1] = Convert.ToByte(arg.Substring(i, 2), 16);
} else {
pbSalt = System.Text.Encoding.ASCII.GetBytes(arg);
}
cbSalt = (uint)pbSalt.Length;
} else {
cbSalt = 0;
pbSalt = new byte[0];
}
uint cbSystemId = 32;
byte[] rgbSystemId = new byte[32];
var res = GetOfflineDeviceUniqueID(cbSalt,pbSalt,out rm,ref cbSystemId,rgbSystemId,0,0);
if (res < 0) throw new COMException("",res);
Console.WriteLine("Got device-unique ID via method {0}",rm);
foreach (var sidbyte in rgbSystemId) Console.Write(sidbyte.ToString("x2"));
Console.WriteLine("");
}
}
@koromaki
Copy link

hay!
where can we chat?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment