示例#1
0
        protected virtual SECURITY_HANDLE AcquireCredential()
        {
            IntPtr pAuthData = IntPtr.Zero;

            SECURITY_HANDLE phCredential = default(SECURITY_HANDLE);

            var result = AcquireCredentialsHandle_0(
                null,
                Mechanism,
                SECPKG_CRED_INBOUND,
                IntPtr.Zero,
                ref pAuthData,
                IntPtr.Zero,
                IntPtr.Zero,
                ref phCredential,
                IntPtr.Zero
                );

            if (result < 0)
            {
                var ex = new Win32Exception(result);

                throw ex;
            }

            return(phCredential);
        }
示例#2
0
        public static uint InitializeSecurityContext(
            ref SECURITY_HANDLE phCredential,          //PCredHandle
            ref SECURITY_HANDLE phContext,             //PCtxtHandle
            string pszTargetName,
            int fContextReq,
            int Reserved1,
            int TargetDataRep,
            ref SecBufferDesc SecBufferDesc,    //PSecBufferDesc SecBufferDesc
            int Reserved2,
            out SECURITY_HANDLE phNewContext,   //PCtxtHandle
            out SecBufferDesc pOutput,          //PSecBufferDesc SecBufferDesc
            out uint pfContextAttr,             //managed ulong == 64 bits!!!
            out SECURITY_INTEGER ptsExpiry)     //PTimeStamp
        {
            NotImplemented(MethodBase.GetCurrentMethod());

            phNewContext  = new SECURITY_HANDLE {
            };
            pOutput       = new SecBufferDesc {
            };
            pfContextAttr = 0;
            ptsExpiry     = new SECURITY_INTEGER {
            };

            return(0);
        }
示例#3
0
 private void CloseClientCredentials()
 {
     if (!(clientCredentials.HighPart == IntPtr.Zero && clientCredentials.LowPart == IntPtr.Zero))
     {
         FreeCredentialsHandle(ref clientCredentials);
         clientCredentials = new SECURITY_HANDLE(0);
     }
 }
示例#4
0
 public static int MakeSignature(ref SECURITY_HANDLE phContext,                  // Context to use
                                 uint fQOP,                                      // Quality of Protection
                                 ref SecBufferDesc pMessage,                     // Message to sign
                                 uint MessageSeqNo)                              // Message Sequence Num.
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     return(0);
 }
示例#5
0
 public static int EncryptMessage(ref SECURITY_HANDLE phContext,
                                  uint fQOP,                                                               //managed ulong == 64 bits!!!
                                  ref SecBufferDesc pMessage,
                                  uint MessageSeqNo)                                                       //managed ulong == 64 bits!!!
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     return(0);
 }
示例#6
0
 private void CloseClientContext()
 {
     if (!(clientContext.HighPart == IntPtr.Zero && clientContext.LowPart == IntPtr.Zero))
     {
         DeleteSecurityContext(ref clientContext);
         clientContext = new SECURITY_HANDLE(0);
     }
 }
示例#7
0
 public static int VerifySignature(ref SECURITY_HANDLE phContext,                  // Context to use
                                   ref SecBufferDesc pMessage,                     // Message to sign
                                   uint MessageSeqNo,                              // Message Sequence Num.
                                   out uint pfQOP)                                 // Quality of Protection
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     pfQOP = 0;
     return(0);
 }
示例#8
0
 public static int DecryptMessage(ref SECURITY_HANDLE phContext,
                                  ref SecBufferDesc pMessage,
                                  uint MessageSeqNo,
                                  out uint pfQOP)
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     pfQOP = 0;
     return(0);
 }
示例#9
0
 public static int QueryContextAttributes(ref SECURITY_HANDLE phContext,
                                          uint ulAttribute,
                                          out SecPkgContext_Sizes pContextAttributes)
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     pContextAttributes = new SecPkgContext_Sizes {
     };
     return(0);
 }
示例#10
0
 public static extern int AcceptSecurityContext(ref SECURITY_HANDLE phCredential,
                                                ref SECURITY_HANDLE phContext,
                                                ref SecBufferDesc pInput,
                                                uint fContextReq,
                                                uint TargetDataRep,
                                                out SECURITY_HANDLE phNewContext,
                                                out SecBufferDesc pOutput,
                                                out uint pfContextAttr, //managed ulong == 64 bits!!!
                                                out SECURITY_INTEGER ptsTimeStamp);
示例#11
0
 internal static extern uint AcquireCredentialsHandle(
     IntPtr pszPrincipal,
     string pszPackage,
     int fCredentialUse,
     IntPtr PAuthenticationID,
     IntPtr pAuthData,
     int pGetKeyFn,
     IntPtr pvGetKeyArgument,
     ref SECURITY_HANDLE phCredential,
     ref SecurityPackages.SECURITY_INTEGER ptsExpiry);
示例#12
0
 internal static extern uint AcceptSecurityContext(
     ref SECURITY_HANDLE phCredential,
     IntPtr phContext,
     ref SecBufferDesc pInput,
     uint fContextReq,
     uint TargetDataRep,
     out SECURITY_HANDLE phNewContext,
     out SecBufferDesc pOutput,
     out uint pfContextAttr,
     out SecurityPackages.SECURITY_INTEGER ptsTimeStamp);
示例#13
0
 public static extern int AcquireCredentialsHandle(
     System.IntPtr pszPrincipal,       //SEC_CHAR*
     string pszPackage,                //SEC_CHAR* //"Kerberos","NTLM","Negotiative"
     int fCredentialUse,
     IntPtr PAuthenticationID,         //_LUID AuthenticationID,//pvLogonID, //PLUID
     ref AuthIdentityEx pAuthData,     //PVOID
     int pGetKeyFn,                    //SEC_GET_KEY_FN
     IntPtr pvGetKeyArgument,          //PVOID
     ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref
     ref SECURITY_INTEGER ptsExpiry);  //PTimeStamp //TimeStamp ref
示例#14
0
 internal static extern SecStatus AcceptSecurityContext_1(
     ref SECURITY_HANDLE phCredential,
     ref SECURITY_HANDLE phContext,
     ref SecBufferDesc pInput,
     ContextFlag fContextReq,
     uint TargetDataRep,
     ref SECURITY_HANDLE phNewContext,
     out SecBufferDesc pOutput,
     out ContextFlag pfContextAttr,
     out SECURITY_INTEGER ptsTimeStamp
     );
示例#15
0
 internal static extern int AcceptSecurityContext_0(
     ref SECURITY_HANDLE phCredential,
     IntPtr phContext,
     ref SecBufferDesc pInput,
     ContextFlags fContextReq,
     uint TargetDataRep,
     out SECURITY_HANDLE phNewContext,
     out SecBufferDesc pOutput,
     out ContextFlags pfContextAttr,    //managed ulong == 64 bits!!!
     out SECURITY_INTEGER ptsTimeStamp
     );
示例#16
0
 internal static extern SecStatus AcquireCredentialsHandle(
     string pszPrincipal,
     string pszPackage,
     int fCredentialUse,
     IntPtr PAuthenticationID,
     void *pAuthData,
     IntPtr pGetKeyFn,
     IntPtr pvGetKeyArgument,
     ref SECURITY_HANDLE phCredential,
     IntPtr ptsExpiry
     );
示例#17
0
 internal static extern int AcquireCredentialsHandle_1(
     string pszPrincipal,              //SEC_CHAR*
     string pszPackage,                //SEC_CHAR* //"Kerberos","NTLM","Negotiative"
     int fCredentialUse,
     IntPtr PAuthenticationID,         //_LUID AuthenticationID,//pvLogonID, //PLUID
     ref SEC_WINNT_AUTH_IDENTITY pAuthData,
     IntPtr pGetKeyFn,                 //SEC_GET_KEY_FN
     IntPtr pvGetKeyArgument,          //PVOID
     ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref
     IntPtr ptsExpiry                  //PTimeStamp //TimeStamp ref
     );
示例#18
0
 public static extern int InitializeSecurityContext(ref SECURITY_HANDLE phCredential, //PCredHandle
                                                    ref SECURITY_HANDLE phContext,    //PCtxtHandle
                                                    string pszTargetName,
                                                    int fContextReq,
                                                    int Reserved1,
                                                    int TargetDataRep,
                                                    ref SecBufferDesc SecBufferDesc,  //PSecBufferDesc SecBufferDesc
                                                    int Reserved2,
                                                    out SECURITY_HANDLE phNewContext, //PCtxtHandle
                                                    out SecBufferDesc pOutput,        //PSecBufferDesc SecBufferDesc
                                                    out uint pfContextAttr,           //managed ulong == 64 bits!!!
                                                    out SECURITY_INTEGER ptsExpiry);  //PTimeStamp
示例#19
0
 internal static extern uint InitializeSecurityContext(
     ref SECURITY_HANDLE phCredential,
     ref SECURITY_HANDLE phContext,
     IntPtr pszTargetName,
     int fContextReq,
     int Reserved1,
     int TargetDataRep,
     ref SecBufferDesc pInput,
     int Reserved2,
     out SECURITY_HANDLE phNewContext,
     out SecBufferDesc pOutput,
     out uint pfContextAttr,
     out SecurityPackages.SECURITY_INTEGER ptsExpiry);
示例#20
0
 public static uint AcquireCredentialsHandle(
     string pszPrincipal,              //SEC_CHAR*
     string pszPackage,                //SEC_CHAR* //"Kerberos","NTLM","Negotiative"
     int fCredentialUse,
     IntPtr PAuthenticationID,         //_LUID AuthenticationID,//pvLogonID, //PLUID
     IntPtr pAuthData,                 //PVOID
     int pGetKeyFn,                    //SEC_GET_KEY_FN
     IntPtr pvGetKeyArgument,          //PVOID
     ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref
     ref SECURITY_INTEGER ptsExpiry)   //PTimeStamp //TimeStamp ref
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     return(0);
 }
示例#21
0
 internal static extern int InitializeSecurityContext_1(
     ref SECURITY_HANDLE phCredential, //PCredHandle
     SECURITY_HANDLE phContext,        //PCtxtHandle
     string pszTargetName,
     int fContextReq,
     int Reserved1,
     int TargetDataRep,
     SecBufferDesc pInput,             //PSecBufferDesc SecBufferDesc
     int Reserved2,
     ref SECURITY_HANDLE phNewContext, //PCtxtHandle
     ref SecBufferDesc pOutput,        //PSecBufferDesc SecBufferDesc
     out ContextFlags pfContextAttr,   //managed ulong == 64 bits!!!
     IntPtr ptsExpiry                  //PTimeStamp
     );
示例#22
0
 internal static extern SecStatus InitializeSecurityContext_1(
     ref SECURITY_HANDLE phCredential,
     ref SECURITY_HANDLE phContext,
     string pszTargetName,
     ContextFlag fContextReq,
     int Reserved1,
     int TargetDataRep,
     ref SecBufferDesc pInput,
     int Reserved2,
     ref SECURITY_HANDLE phNewContext,
     ref SecBufferDesc pOutput,
     out ContextFlag pfContextAttr,
     ref IntPtr ptsExpiry
     );
示例#23
0
    public NTLMExecutor()
    {
        client_buffer = new SecBuffer();
        client_desc   = new SecBufferDesc();

        server_buffer = new SecBuffer();
        server_desc   = new SecBufferDesc();

        cred_handle   = new SECURITY_HANDLE(0);
        ctxt_handle   = new SECURITY_HANDLE(0);
        p_cred_handle = Marshal.AllocHGlobal(Marshal.SizeOf(cred_handle));
        Marshal.StructureToPtr(cred_handle, p_cred_handle, false);
        p_ctxt_handle = Marshal.AllocHGlobal(Marshal.SizeOf(ctxt_handle));
        Marshal.StructureToPtr(ctxt_handle, p_ctxt_handle, false);

        p_elevated_handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
    }
示例#24
0
        protected override SECURITY_HANDLE AcquireCredential()
        {
            if (Settings.AcquisitionCredentials == null ||
                string.IsNullOrWhiteSpace(Settings.AcquisitionCredentials.UserName) ||
                string.IsNullOrWhiteSpace(Settings.AcquisitionCredentials.Password))
            {
                return(base.AcquireCredential());
            }

            SEC_WINNT_AUTH_IDENTITY pAuthData = new SEC_WINNT_AUTH_IDENTITY(
                Settings.AcquisitionCredentials.Domain,
                Settings.AcquisitionCredentials.UserName,
                Settings.AcquisitionCredentials.Password,
                SEC_WINNT_AUTH_IDENTITY_FLAGS.Unicode
                );

            SECURITY_HANDLE phCredential = default(SECURITY_HANDLE);

            var result = AcquireCredentialsHandle_1(
                null,
                Mechanism,
                SECPKG_CRED_INBOUND,
                IntPtr.Zero,
                ref pAuthData,
                IntPtr.Zero,
                IntPtr.Zero,
                ref phCredential,
                IntPtr.Zero
                );

            if (result < 0)
            {
                throw new Win32Exception(result);
            }

            return(phCredential);
        }
示例#25
0
 public static extern int DecryptMessage(ref SECURITY_HANDLE phContext,
                                          ref SecBufferDesc pMessage,
                                          uint MessageSeqNo,
                                          out uint pfQOP);
示例#26
0
 static extern int FreeCredentialsHandle(ref SECURITY_HANDLE phCredential); //PCredHandle
示例#27
0
 internal static extern uint FreeCredentialsHandle(ref SECURITY_HANDLE phCredential);
示例#28
0
 internal static extern uint DeleteSecurityContext(ref SECURITY_HANDLE phCredential);
示例#29
0
 static extern int DeleteSecurityContext(ref SECURITY_HANDLE phContext); //PCtxtHandle
示例#30
0
 public static extern int AcquireCredentialsHandle(
 System.IntPtr pszPrincipal, //SEC_CHAR*
 string pszPackage, //SEC_CHAR* //"Kerberos","NTLM","Negotiative"
 int fCredentialUse,
 IntPtr PAuthenticationID,//_LUID AuthenticationID,//pvLogonID, //PLUID
 System.IntPtr pAuthData,//PVOID
 int pGetKeyFn, //SEC_GET_KEY_FN
 IntPtr pvGetKeyArgument, //PVOID
 ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref
 ref SECURITY_INTEGER ptsExpiry);
示例#31
0
 public static extern int ImpersonateSecurityContext(ref SECURITY_HANDLE phContext);
示例#32
0
 public static extern int DeleteSecurityContext(SECURITY_HANDLE phContext);
示例#33
0
 public static extern int InitializeSecurityContext(ref SECURITY_HANDLE phCredential,//PCredHandle
     ref SECURITY_HANDLE phContext, //PCtxtHandle
     string pszTargetName,
     int fContextReq,
     int Reserved1,
     int TargetDataRep,
     ref SecBufferDesc SecBufferDesc, //PSecBufferDesc SecBufferDesc
     int Reserved2,
     out SECURITY_HANDLE phNewContext, //PCtxtHandle
     out SecBufferDesc pOutput, //PSecBufferDesc SecBufferDesc
     out uint pfContextAttr, //managed ulong == 64 bits!!!
     out SECURITY_INTEGER ptsExpiry);
示例#34
0
 public static extern int MakeSignature(ref SECURITY_HANDLE phContext,          // Context to use
                                         uint fQOP,         // Quality of Protection
                                         ref SecBufferDesc pMessage,        // Message to sign
                                         uint MessageSeqNo);
示例#35
0
 public static extern int AcceptSecurityContext(ref SECURITY_HANDLE phCredential,
                                         IntPtr phContext,
                                         ref SecBufferDesc pInput,
                                         uint fContextReq,
                                         uint TargetDataRep,
                                         out SECURITY_HANDLE phNewContext,
                                         out SecBufferDesc pOutput,
                                         out uint pfContextAttr,    //managed ulong == 64 bits!!!
                                         out SECURITY_INTEGER ptsTimeStamp);
示例#36
0
 public static extern int VerifySignature(ref SECURITY_HANDLE phContext,          // Context to use
                                         ref SecBufferDesc pMessage,        // Message to sign
                                         uint MessageSeqNo,            // Message Sequence Num.
                                         out uint pfQOP);
示例#37
0
 public static extern int QueryContextAttributes(ref SECURITY_HANDLE phContext,
                                                 uint ulAttribute,
                                                 out SecPkgContext_Sizes pContextAttributes);
示例#38
0
 internal static extern SecStatus QueryContextAttributesString(
     ref SECURITY_HANDLE phContext,
     SecurityContextAttribute ulAttribute,
     ref SecPkgContext_SecString pBuffer
     );
示例#39
0
 public static extern int EncryptMessage(ref SECURITY_HANDLE phContext,
                                         uint fQOP,        //managed ulong == 64 bits!!!
                                         ref SecBufferDesc pMessage,
                                         uint MessageSeqNo);