コード例 #1
0
ファイル: 40573.cs プロジェクト: Amoenus/HoundSploit
 static extern int NtCreateKey(
     out IntPtr KeyHandle,
     GenericAccessRights DesiredAccess,
     [In] ObjectAttributes ObjectAttributes,
     int TitleIndex,
     [In] UnicodeString Class,
     KeyCreateOptions CreateOptions,
     out int Disposition);
コード例 #2
0
ファイル: NtKeyNative.cs プロジェクト: codehz/winsilo
 public static extern NtStatus NtCreateKey(
     out SafeKernelObjectHandle KeyHandle,
     KeyAccessRights DesiredAccess,
     [In] ObjectAttributes ObjectAttributes,
     int TitleIndex,
     UnicodeString Class,
     KeyCreateOptions CreateOptions,
     out KeyDisposition Disposition
     );
コード例 #3
0
        public async Task CreateKeyWithOptions()
        {
            var keyOptions = new KeyCreateOptions()
            {
                KeyOperations = new List <KeyOperations>()
                {
                    KeyOperations.Verify
                },
                Enabled = false
            };

            Key key = await Client.CreateKeyAsync(Recording.GenerateId(), KeyType.EllipticCurve, keyOptions);

            RegisterForCleanup(key);

            Key keyReturned = await Client.GetKeyAsync(key.Name);

            AssertKeysEqual(key, keyReturned);
        }
コード例 #4
0
        public async Task CreateKeyWithOptions()
        {
            var            exp = new DateTimeOffset(new DateTime(637027248120000000, DateTimeKind.Utc));
            DateTimeOffset nbf = exp.AddDays(-30);

            var keyOptions = new KeyCreateOptions()
            {
                KeyOperations = new List <KeyOperation>()
                {
                    KeyOperation.Verify
                },
                Enabled   = false,
                Expires   = exp,
                NotBefore = nbf,
            };

            Key key = await Client.CreateKeyAsync(Recording.GenerateId(), KeyType.Ec, keyOptions);

            RegisterForCleanup(key.Name);

            Key keyReturned = await Client.GetKeyAsync(key.Name);

            AssertKeysEqual(key, keyReturned);
        }
コード例 #5
0
ファイル: NtKeyNative.cs プロジェクト: codehz/winsilo
 public static extern NtStatus NtOpenKeyTransactedEx(out SafeKernelObjectHandle KeyHandle, KeyAccessRights DesiredAccess, [In] ObjectAttributes ObjectAttributes, KeyCreateOptions OpenOptions, [In] SafeKernelObjectHandle TransactionHandle);
コード例 #6
0
 /// <summary>
 /// Create a new Key
 /// </summary>
 /// <param name="key_name">Path to the key to create</param>
 /// <param name="desired_access">Desired access for the root key</param>
 /// <param name="options">Create options</param>
 /// <returns>The opened key</returns>
 /// <exception cref="NtException">Thrown on error.</exception>
 public NtKey Create(string key_name, KeyAccessRights desired_access, KeyCreateOptions options)
 {
     return(Create(key_name, this, desired_access, options));
 }
コード例 #7
0
 /// <summary>
 /// Create a new Key
 /// </summary>
 /// <param name="key_name">Path to the key to create</param>
 /// <param name="root">Root key if key_name is relative</param>
 /// <param name="desired_access">Desired access for the root key</param>
 /// <param name="options">Create options</param>
 /// <returns>The opened key</returns>
 /// <exception cref="NtException">Thrown on error.</exception>
 public static NtKey Create(string key_name, NtObject root, KeyAccessRights desired_access, KeyCreateOptions options)
 {
     using (ObjectAttributes obja = new ObjectAttributes(key_name, AttributeFlags.CaseInsensitive, root))
     {
         return(Create(obja, desired_access, options));
     }
 }
コード例 #8
0
        /// <summary>
        /// Create a new Key
        /// </summary>
        /// <param name="obj_attributes">Object attributes for the key name</param>
        /// <param name="desired_access">Desired access for the root key</param>
        /// <param name="options">Create options</param>
        /// <returns>The opened key</returns>
        /// <exception cref="NtException">Thrown on error.</exception>
        public static NtKey Create(ObjectAttributes obj_attributes, KeyAccessRights desired_access, KeyCreateOptions options)
        {
            SafeKernelObjectHandle key;
            KeyDisposition         disposition;

            NtSystemCalls.NtCreateKey(out key, desired_access, obj_attributes, 0, null, options, out disposition).ToNtException();
            return(new NtKey(key));
        }
コード例 #9
0
 /// <summary>
 /// Open a Key
 /// </summary>
 /// <param name="obj_attributes">Object attributes for the key name</param>
 /// <param name="desired_access">Desired access for the root key</param>
 /// <param name="open_options">Open options.</param>
 /// <returns>The opened key</returns>
 /// <exception cref="NtException">Thrown on error.</exception>
 public static NtKey Open(ObjectAttributes obj_attributes, KeyAccessRights desired_access, KeyCreateOptions open_options)
 {
     return(Open(obj_attributes, desired_access, open_options, true).Result);
 }
コード例 #10
0
        /// <summary>
        /// Try and open a Key
        /// </summary>
        /// <param name="obj_attributes">Object attributes for the key name</param>
        /// <param name="desired_access">Desired access for the root key</param>
        /// <param name="open_options">Open options.</param>
        /// <param name="throw_on_error">True to throw an exception on error.</param>
        /// <returns>The NT status code and object result.</returns>
        public static NtResult <NtKey> Open(ObjectAttributes obj_attributes, KeyAccessRights desired_access, KeyCreateOptions open_options, bool throw_on_error)
        {
            SafeKernelObjectHandle handle;

            return(NtSystemCalls.NtOpenKeyEx(out handle, desired_access, obj_attributes, open_options)
                   .CreateResult(throw_on_error, () => new NtKey(handle, KeyDisposition.OpenedExistingKey)));
        }
コード例 #11
0
        /// <summary>
        /// Create a new Key
        /// </summary>
        /// <param name="obj_attributes">Object attributes for the key name</param>
        /// <param name="desired_access">Desired access for the root key</param>
        /// <param name="options">Create options</param>
        /// <param name="throw_on_error">True to throw an exception on error.</param>
        /// <returns>The NT status code and object result.</returns>
        public static NtResult <NtKey> Create(ObjectAttributes obj_attributes, KeyAccessRights desired_access, KeyCreateOptions options, bool throw_on_error)
        {
            SafeKernelObjectHandle handle;
            KeyDisposition         disposition;

            return(NtSystemCalls.NtCreateKey(out handle, desired_access, obj_attributes, 0, null, options, out disposition)
                   .CreateResult(throw_on_error, () => new NtKey(handle, disposition)));
        }
コード例 #12
0
ファイル: 40573.cs プロジェクト: Amoenus/HoundSploit
 static SafeRegistryHandle CreateKey(SafeRegistryHandle rootkey, string path, AttributeFlags flags, KeyCreateOptions options)
 {
     using (ObjectAttributes obja = new ObjectAttributes(path, flags | AttributeFlags.CaseInsensitive, rootkey != null ? rootkey.DangerousGetHandle() : IntPtr.Zero))
     {
         IntPtr handle;
         int    disposition = 0;
         StatusToNtException(NtCreateKey(out handle, GenericAccessRights.MaximumAllowed, obja, 0, null, options, out disposition));
         return(new SafeRegistryHandle(handle, true));
     }
 }