NTLM Negotiate message embended in cssp request

This commit is contained in:
speyrefitte
2015-02-20 10:13:24 +01:00
parent 1c3119cffd
commit 36c05faa11
2 changed files with 15 additions and 52 deletions

View File

@@ -26,12 +26,17 @@ from pyasn1.type import namedtype, univ, tag
from pyasn1.codec.der import encoder
from rdpy.core.type import Stream
class NegoToken(univ.Sequence):
componentType = namedtype.NamedTypes(
namedtype.NamedType('negoToken', univ.OctetString().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
)
class NegoData(univ.SequenceOf):
"""
@summary: contain spnego ntlm of kerberos data
@see: https://msdn.microsoft.com/en-us/library/cc226781.aspx
"""
componentType = univ.OctetString().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))
componentType = NegoToken()
class TSRequest(univ.Sequence):
"""
@@ -92,24 +97,26 @@ class TSSmartCardCreds(univ.Sequence):
namedtype.OptionalNamedType('domainHint', univ.OctetString().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
)
def createBERRequest(negoTokens):
def createBERRequest(negoTypes):
"""
@summary: create TSRequest from list of Type
@param negoTokens: {list(Type)}
@param negoTypes: {list(Type)}
@return: {str}
"""
negoData = NegoData()
negoData = NegoData().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))
#fill nego data tokens
i = 0
for negoToken in negoTokens:
for negoType in negoTypes:
s = Stream()
s.writeType(negoToken)
negoData.setComponentByPosition(i, s.getvalue())
s.writeType(negoType)
negoToken = NegoToken()
negoToken.setComponentByPosition(0, s.getvalue())
negoData.setComponentByPosition(i, negoToken)
i += 1
request = TSRequest()
request.setComponentByName("version", univ.Integer(2))
request.setComponentByName("version", univ.Integer(2).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
request.setComponentByName("negoTokens", negoData)
return encoder.encode(request)

View File

@@ -1,44 +0,0 @@
#
# Copyright (c) 2014-2015 Sylvain Peyrefitte
#
# This file is part of rdpy.
#
# rdpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
@summary: Simple and protected GSS-API Negotiation Mechanism
@see: https://msdn.microsoft.com/en-us/library/cc247021.aspx
"""
from pyasn1.type import namedtype, univ
class MechTypeList(univ.SequenceOf):
"""
@see: http://www.rfc-editor.org/rfc/rfc4178.txt section 4.1
"""
componentType = univ.ObjectIdentifier()
class NegTokenInit2(univ.Sequence):
"""
@summary: main structure
@see: https://msdn.microsoft.com/en-us/library/cc247039.aspx
"""
componentType = namedtype.NamedTypes(
namedtype.OptionalNamedType('mechTypes', MechTypeList()),
namedtype.OptionalNamedType('reqFlags', univ.BitString()),
namedtype.OptionalNamedType('mechToken', univ.OctetString()),
namedtype.OptionalNamedType('negHints', univ.OctetString()),
namedtype.OptionalNamedType('mechListMIC', univ.Integer())
)