Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › KERB_TICKET_PROFILE

KERB_TICKET_PROFILE

構造体
サイズx64: 176 バイト / x86: 128 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
ProfileKERB_INTERACTIVE_PROFILE160/112+0+0基となる対話ログオンプロファイル(KERB_INTERACTIVE_PROFILE)。
SessionKeyKERB_CRYPTO_KEY16/12+160+112ログオンセッションの暗号鍵(KERB_CRYPTO_KEY)。

各言語での定義

#include <windows.h>

// LSA_UNICODE_STRING  (x64 16 / x86 8 バイト)
typedef struct LSA_UNICODE_STRING {
    WORD Length;
    WORD MaximumLength;
    LPWSTR Buffer;
} LSA_UNICODE_STRING;

// KERB_INTERACTIVE_PROFILE  (x64 160 / x86 112 バイト)
typedef struct KERB_INTERACTIVE_PROFILE {
    KERB_PROFILE_BUFFER_TYPE MessageType;
    WORD LogonCount;
    WORD BadPasswordCount;
    LONGLONG LogonTime;
    LONGLONG LogoffTime;
    LONGLONG KickOffTime;
    LONGLONG PasswordLastSet;
    LONGLONG PasswordCanChange;
    LONGLONG PasswordMustChange;
    LSA_UNICODE_STRING LogonScript;
    LSA_UNICODE_STRING HomeDirectory;
    LSA_UNICODE_STRING FullName;
    LSA_UNICODE_STRING ProfilePath;
    LSA_UNICODE_STRING HomeDirectoryDrive;
    LSA_UNICODE_STRING LogonServer;
    DWORD UserFlags;
} KERB_INTERACTIVE_PROFILE;

// KERB_CRYPTO_KEY  (x64 16 / x86 12 バイト)
typedef struct KERB_CRYPTO_KEY {
    KERB_CRYPTO_KEY_TYPE KeyType;
    DWORD Length;
    BYTE* Value;
} KERB_CRYPTO_KEY;

// KERB_TICKET_PROFILE  (x64 176 / x86 128 バイト)
typedef struct KERB_TICKET_PROFILE {
    KERB_INTERACTIVE_PROFILE Profile;
    KERB_CRYPTO_KEY SessionKey;
} KERB_TICKET_PROFILE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LSA_UNICODE_STRING
{
    public ushort Length;
    public ushort MaximumLength;
    public IntPtr Buffer;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_INTERACTIVE_PROFILE
{
    public int MessageType;
    public ushort LogonCount;
    public ushort BadPasswordCount;
    public long LogonTime;
    public long LogoffTime;
    public long KickOffTime;
    public long PasswordLastSet;
    public long PasswordCanChange;
    public long PasswordMustChange;
    public LSA_UNICODE_STRING LogonScript;
    public LSA_UNICODE_STRING HomeDirectory;
    public LSA_UNICODE_STRING FullName;
    public LSA_UNICODE_STRING ProfilePath;
    public LSA_UNICODE_STRING HomeDirectoryDrive;
    public LSA_UNICODE_STRING LogonServer;
    public uint UserFlags;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_CRYPTO_KEY
{
    public int KeyType;
    public uint Length;
    public IntPtr Value;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KERB_TICKET_PROFILE
{
    public KERB_INTERACTIVE_PROFILE Profile;
    public KERB_CRYPTO_KEY SessionKey;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LSA_UNICODE_STRING
    Public Length As UShort
    Public MaximumLength As UShort
    Public Buffer As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_INTERACTIVE_PROFILE
    Public MessageType As Integer
    Public LogonCount As UShort
    Public BadPasswordCount As UShort
    Public LogonTime As Long
    Public LogoffTime As Long
    Public KickOffTime As Long
    Public PasswordLastSet As Long
    Public PasswordCanChange As Long
    Public PasswordMustChange As Long
    Public LogonScript As LSA_UNICODE_STRING
    Public HomeDirectory As LSA_UNICODE_STRING
    Public FullName As LSA_UNICODE_STRING
    Public ProfilePath As LSA_UNICODE_STRING
    Public HomeDirectoryDrive As LSA_UNICODE_STRING
    Public LogonServer As LSA_UNICODE_STRING
    Public UserFlags As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_CRYPTO_KEY
    Public KeyType As Integer
    Public Length As UInteger
    Public Value As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KERB_TICKET_PROFILE
    Public Profile As KERB_INTERACTIVE_PROFILE
    Public SessionKey As KERB_CRYPTO_KEY
End Structure
import ctypes
from ctypes import wintypes

class LSA_UNICODE_STRING(ctypes.Structure):
    _fields_ = [
        ("Length", ctypes.c_ushort),
        ("MaximumLength", ctypes.c_ushort),
        ("Buffer", ctypes.c_void_p),
    ]

class KERB_INTERACTIVE_PROFILE(ctypes.Structure):
    _fields_ = [
        ("MessageType", ctypes.c_int),
        ("LogonCount", ctypes.c_ushort),
        ("BadPasswordCount", ctypes.c_ushort),
        ("LogonTime", ctypes.c_longlong),
        ("LogoffTime", ctypes.c_longlong),
        ("KickOffTime", ctypes.c_longlong),
        ("PasswordLastSet", ctypes.c_longlong),
        ("PasswordCanChange", ctypes.c_longlong),
        ("PasswordMustChange", ctypes.c_longlong),
        ("LogonScript", LSA_UNICODE_STRING),
        ("HomeDirectory", LSA_UNICODE_STRING),
        ("FullName", LSA_UNICODE_STRING),
        ("ProfilePath", LSA_UNICODE_STRING),
        ("HomeDirectoryDrive", LSA_UNICODE_STRING),
        ("LogonServer", LSA_UNICODE_STRING),
        ("UserFlags", wintypes.DWORD),
    ]

class KERB_CRYPTO_KEY(ctypes.Structure):
    _fields_ = [
        ("KeyType", ctypes.c_int),
        ("Length", wintypes.DWORD),
        ("Value", ctypes.c_void_p),
    ]

class KERB_TICKET_PROFILE(ctypes.Structure):
    _fields_ = [
        ("Profile", KERB_INTERACTIVE_PROFILE),
        ("SessionKey", KERB_CRYPTO_KEY),
    ]
#[repr(C)]
pub struct LSA_UNICODE_STRING {
    pub Length: u16,
    pub MaximumLength: u16,
    pub Buffer: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct KERB_INTERACTIVE_PROFILE {
    pub MessageType: i32,
    pub LogonCount: u16,
    pub BadPasswordCount: u16,
    pub LogonTime: i64,
    pub LogoffTime: i64,
    pub KickOffTime: i64,
    pub PasswordLastSet: i64,
    pub PasswordCanChange: i64,
    pub PasswordMustChange: i64,
    pub LogonScript: LSA_UNICODE_STRING,
    pub HomeDirectory: LSA_UNICODE_STRING,
    pub FullName: LSA_UNICODE_STRING,
    pub ProfilePath: LSA_UNICODE_STRING,
    pub HomeDirectoryDrive: LSA_UNICODE_STRING,
    pub LogonServer: LSA_UNICODE_STRING,
    pub UserFlags: u32,
}

#[repr(C)]
pub struct KERB_CRYPTO_KEY {
    pub KeyType: i32,
    pub Length: u32,
    pub Value: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct KERB_TICKET_PROFILE {
    pub Profile: KERB_INTERACTIVE_PROFILE,
    pub SessionKey: KERB_CRYPTO_KEY,
}
import "golang.org/x/sys/windows"

type LSA_UNICODE_STRING struct {
	Length uint16
	MaximumLength uint16
	Buffer uintptr
}

type KERB_INTERACTIVE_PROFILE struct {
	MessageType int32
	LogonCount uint16
	BadPasswordCount uint16
	LogonTime int64
	LogoffTime int64
	KickOffTime int64
	PasswordLastSet int64
	PasswordCanChange int64
	PasswordMustChange int64
	LogonScript LSA_UNICODE_STRING
	HomeDirectory LSA_UNICODE_STRING
	FullName LSA_UNICODE_STRING
	ProfilePath LSA_UNICODE_STRING
	HomeDirectoryDrive LSA_UNICODE_STRING
	LogonServer LSA_UNICODE_STRING
	UserFlags uint32
}

type KERB_CRYPTO_KEY struct {
	KeyType int32
	Length uint32
	Value uintptr
}

type KERB_TICKET_PROFILE struct {
	Profile KERB_INTERACTIVE_PROFILE
	SessionKey KERB_CRYPTO_KEY
}
type
  LSA_UNICODE_STRING = record
    Length: Word;
    MaximumLength: Word;
    Buffer: Pointer;
  end;

  KERB_INTERACTIVE_PROFILE = record
    MessageType: Integer;
    LogonCount: Word;
    BadPasswordCount: Word;
    LogonTime: Int64;
    LogoffTime: Int64;
    KickOffTime: Int64;
    PasswordLastSet: Int64;
    PasswordCanChange: Int64;
    PasswordMustChange: Int64;
    LogonScript: LSA_UNICODE_STRING;
    HomeDirectory: LSA_UNICODE_STRING;
    FullName: LSA_UNICODE_STRING;
    ProfilePath: LSA_UNICODE_STRING;
    HomeDirectoryDrive: LSA_UNICODE_STRING;
    LogonServer: LSA_UNICODE_STRING;
    UserFlags: DWORD;
  end;

  KERB_CRYPTO_KEY = record
    KeyType: Integer;
    Length: DWORD;
    Value: Pointer;
  end;

  KERB_TICKET_PROFILE = record
    Profile: KERB_INTERACTIVE_PROFILE;
    SessionKey: KERB_CRYPTO_KEY;
  end;
const LSA_UNICODE_STRING = extern struct {
    Length: u16,
    MaximumLength: u16,
    Buffer: ?*anyopaque,
};

const KERB_INTERACTIVE_PROFILE = extern struct {
    MessageType: i32,
    LogonCount: u16,
    BadPasswordCount: u16,
    LogonTime: i64,
    LogoffTime: i64,
    KickOffTime: i64,
    PasswordLastSet: i64,
    PasswordCanChange: i64,
    PasswordMustChange: i64,
    LogonScript: LSA_UNICODE_STRING,
    HomeDirectory: LSA_UNICODE_STRING,
    FullName: LSA_UNICODE_STRING,
    ProfilePath: LSA_UNICODE_STRING,
    HomeDirectoryDrive: LSA_UNICODE_STRING,
    LogonServer: LSA_UNICODE_STRING,
    UserFlags: u32,
};

const KERB_CRYPTO_KEY = extern struct {
    KeyType: i32,
    Length: u32,
    Value: ?*anyopaque,
};

const KERB_TICKET_PROFILE = extern struct {
    Profile: KERB_INTERACTIVE_PROFILE,
    SessionKey: KERB_CRYPTO_KEY,
};
type
  LSA_UNICODE_STRING {.bycopy.} = object
    Length: uint16
    MaximumLength: uint16
    Buffer: pointer

  KERB_INTERACTIVE_PROFILE {.bycopy.} = object
    MessageType: int32
    LogonCount: uint16
    BadPasswordCount: uint16
    LogonTime: int64
    LogoffTime: int64
    KickOffTime: int64
    PasswordLastSet: int64
    PasswordCanChange: int64
    PasswordMustChange: int64
    LogonScript: LSA_UNICODE_STRING
    HomeDirectory: LSA_UNICODE_STRING
    FullName: LSA_UNICODE_STRING
    ProfilePath: LSA_UNICODE_STRING
    HomeDirectoryDrive: LSA_UNICODE_STRING
    LogonServer: LSA_UNICODE_STRING
    UserFlags: uint32

  KERB_CRYPTO_KEY {.bycopy.} = object
    KeyType: int32
    Length: uint32
    Value: pointer

  KERB_TICKET_PROFILE {.bycopy.} = object
    Profile: KERB_INTERACTIVE_PROFILE
    SessionKey: KERB_CRYPTO_KEY
struct LSA_UNICODE_STRING
{
    ushort Length;
    ushort MaximumLength;
    void* Buffer;
}

struct KERB_INTERACTIVE_PROFILE
{
    int MessageType;
    ushort LogonCount;
    ushort BadPasswordCount;
    long LogonTime;
    long LogoffTime;
    long KickOffTime;
    long PasswordLastSet;
    long PasswordCanChange;
    long PasswordMustChange;
    LSA_UNICODE_STRING LogonScript;
    LSA_UNICODE_STRING HomeDirectory;
    LSA_UNICODE_STRING FullName;
    LSA_UNICODE_STRING ProfilePath;
    LSA_UNICODE_STRING HomeDirectoryDrive;
    LSA_UNICODE_STRING LogonServer;
    uint UserFlags;
}

struct KERB_CRYPTO_KEY
{
    int KeyType;
    uint Length;
    void* Value;
}

struct KERB_TICKET_PROFILE
{
    KERB_INTERACTIVE_PROFILE Profile;
    KERB_CRYPTO_KEY SessionKey;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; KERB_TICKET_PROFILE サイズ: 128 バイト(x86)
dim st, 32    ; 4byte整数×32(構造体サイズ 128 / 4 切り上げ)
; Profile : KERB_INTERACTIVE_PROFILE (+0, 112byte)  varptr(st)+0 を基点に操作(112byte:入れ子/配列)
; SessionKey : KERB_CRYPTO_KEY (+112, 12byte)  varptr(st)+112 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; KERB_TICKET_PROFILE サイズ: 176 バイト(x64)
dim st, 44    ; 4byte整数×44(構造体サイズ 176 / 4 切り上げ)
; Profile : KERB_INTERACTIVE_PROFILE (+0, 160byte)  varptr(st)+0 を基点に操作(160byte:入れ子/配列)
; SessionKey : KERB_CRYPTO_KEY (+160, 16byte)  varptr(st)+160 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global LSA_UNICODE_STRING
    #field short Length
    #field short MaximumLength
    #field intptr Buffer
#endstruct

#defstruct global KERB_INTERACTIVE_PROFILE
    #field int MessageType
    #field short LogonCount
    #field short BadPasswordCount
    #field int64 LogonTime
    #field int64 LogoffTime
    #field int64 KickOffTime
    #field int64 PasswordLastSet
    #field int64 PasswordCanChange
    #field int64 PasswordMustChange
    #field LSA_UNICODE_STRING LogonScript
    #field LSA_UNICODE_STRING HomeDirectory
    #field LSA_UNICODE_STRING FullName
    #field LSA_UNICODE_STRING ProfilePath
    #field LSA_UNICODE_STRING HomeDirectoryDrive
    #field LSA_UNICODE_STRING LogonServer
    #field int UserFlags
#endstruct

#defstruct global KERB_CRYPTO_KEY
    #field int KeyType
    #field int Length
    #field intptr Value
#endstruct

#defstruct global KERB_TICKET_PROFILE
    #field KERB_INTERACTIVE_PROFILE Profile
    #field KERB_CRYPTO_KEY SessionKey
#endstruct

stdim st, KERB_TICKET_PROFILE        ; NSTRUCT 変数を確保