Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////
        //
        ////////////////////////////////////////////////////////////////////////////////
        public bool DuplicateToken(Winnt._SECURITY_IMPERSONATION_LEVEL impersonationLevel)
        {
            if (IntPtr.Zero == hExistingToken)
            {
                return(false);
            }

            Winbase._SECURITY_ATTRIBUTES securityAttributes = new Winbase._SECURITY_ATTRIBUTES();
            if (!advapi32.DuplicateTokenEx(
                    hWorkingToken,
                    (uint)Winnt.ACCESS_MASK.MAXIMUM_ALLOWED,
                    ref securityAttributes,
                    impersonationLevel,
                    Winnt._TOKEN_TYPE.TokenImpersonation,
                    out phNewToken
                    ))
            {
                Misc.GetWin32Error("DuplicateTokenEx: ");
                return(false);
            }

            Console.WriteLine(" [+] Duplicate Token Handle: 0x{0}", phNewToken.ToString("X4"));
            return(true);
        }
Ejemplo n.º 2
0
 public static extern bool ImpersonateSelf(Winnt._SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
Ejemplo n.º 3
0
 public static extern bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, ref Winbase._SECURITY_ATTRIBUTES lpTokenAttributes, Winnt._SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, Winnt._TOKEN_TYPE TokenType, out IntPtr phNewToken);
Ejemplo n.º 4
0
 public static extern Boolean DuplicateTokenEx(IntPtr hExistingToken, UInt32 dwDesiredAccess, IntPtr lpTokenAttributes, Winnt._SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, Winnt._TOKEN_TYPE TokenType, out IntPtr phNewToken);