diff --git a/.travis.yml b/.travis.yml index f707463..e349468 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - sudo apt-get install python-qt4 - ln -s /usr/lib/python2.7/dist-packages/PyQt4/ $VIRTUAL_ENV/lib/python2.7/site-packages/ - ln -s /usr/lib/python2.7/dist-packages/sip.so $VIRTUAL_ENV/lib/python2.7/site-packages/ - - pip install qt4reactor pyopenssl twisted service_identity rsa + - pip install qt4reactor pyopenssl twisted service_identity rsa pyasn1 install: - python setup.py install diff --git a/README.md b/README.md index 76edd06..4502a54 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ x86 | x86_64 ``` $ git clone https://github.com/citronneur/rdpy.git rdpy -$ pip install twisted pyopenssl qt4reactor service_identity rsa +$ pip install twisted pyopenssl qt4reactor service_identity rsa pyasn1 $ python rdpy/setup.py install ``` diff --git a/rdpy/security/ntlm.py b/rdpy/security/ntlm.py new file mode 100644 index 0000000..1bf83dc --- /dev/null +++ b/rdpy/security/ntlm.py @@ -0,0 +1,81 @@ +# +# 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 . +# + +""" +@summary: NTLM Authentication +@see: https://msdn.microsoft.com/en-us/library/cc236621.aspx +""" + +from rdpy.core.type import CompositeType, String, UInt8, UInt16Le, UInt24Le, UInt32Le + +class MajorVersion(object): + """ + @see: https://msdn.microsoft.com/en-us/library/cc236654.aspx + @see: https://msdn.microsoft.com/en-us/library/a211d894-21bc-4b8b-86ba-b83d0c167b00#id29 + """ + WINDOWS_MAJOR_VERSION_5 = 0x05 + WINDOWS_MAJOR_VERSION_6 = 0x06 + +class MinorVersion(object): + """ + @see: https://msdn.microsoft.com/en-us/library/cc236654.aspx + @see: https://msdn.microsoft.com/en-us/library/a211d894-21bc-4b8b-86ba-b83d0c167b00#id30 + """ + WINDOWS_MINOR_VERSION_0 = 0x00 + WINDOWS_MINOR_VERSION_1 = 0x01 + WINDOWS_MINOR_VERSION_2 = 0x02 + WINDOWS_MINOR_VERSION_3 = 0x03 + +class NTLMRevision(object): + """ + @see: https://msdn.microsoft.com/en-us/library/cc236654.aspx + """ + NTLMSSP_REVISION_W2K3 = 0x0F + +class Version(CompositeType): + """ + @summary: Version structure as describe in NTLM spec + @see: https://msdn.microsoft.com/en-us/library/cc236654.aspx + """ + def __init__(self): + self.ProductMajorVersion = UInt8(MajorVersion.WINDOWS_MAJOR_VERSION_6) + self.ProductMinorVersion = UInt8(MinorVersion.WINDOWS_MINOR_VERSION_2) + self.ProductBuild = UInt16Le() + self.Reserved = UInt24Le() + self.NTLMRevisionCurrent = UInt8(NTLMRevision.NTLMSSP_REVISION_W2K3) + +class NegotiateMessage(CompositeType): + """ + @summary: Negotiate capability of NTLM Authentication + @see: https://msdn.microsoft.com/en-us/library/cc236641.aspx + """ + def __init__(self): + CompositeType.__init__(self) + self.Signature = String("NTLMSSP\x00", constant = True) + self.MessageType = UInt32Le(0x00000001) + self.NegotiateFlags = UInt32Le() + self.DomainNameLen = UInt16Le() + self.DomainNameMaxLen = UInt16Le(self.DomainNameLen) + self.DomainNameBufferOffset = UInt32Le() + self.WorkstationLen = UInt16Le() + self.WorkstationMaxLen = UInt16Le(self.WorkstationLen) + self.WorkstationBufferOffset = UInt32Le() + self.Version = Version() + self.Payload = String() + \ No newline at end of file