This commit is contained in:
speyrefitte
2014-12-17 18:19:36 +01:00
parent 69b3f6befe
commit d330564d2b
3 changed files with 14 additions and 7 deletions

View File

@@ -403,12 +403,12 @@ class RSAPublicKey(CompositeType):
def __init__(self, readLen):
CompositeType.__init__(self, readLen = readLen)
self.magic = UInt32Le(0x31415352, constant = True)
self.keylen = UInt32Le(lambda:sizeof(self.modulus))
self.keylen = UInt32Le(lambda:(sizeof(self.modulus) + sizeof(self.padding)))
self.bitlen = UInt32Le(lambda:((self.keylen.value - 8) * 8))
self.datalen = UInt32Le(lambda:((self.bitlen.value / 8) - 1))
self.pubExp = UInt32Le()
self.modulus = String(readLen = UInt16Le(lambda:(self.keylen.value - 8)))
self.padding = String(readLen = UInt8(8))
self.padding = String("\x00" * 8, readLen = UInt8(8))
class ChannelDef(CompositeType):
"""

View File

@@ -488,14 +488,11 @@ class Server(MCSLayer):
"""
#basic rdp security layer
if self._transport._selectedProtocol == 0:
certificate = gcc.ProprietaryServerCertificate()
certificate.PublicKeyBlob.modulus.value = hex(self._presentation._rsaPublicKey.n)[2:-1].decode('hex')[::-1]
certificate.PublicKeyBlob.pubExp.value = self._presentation._rsaPublicKey.e
self._serverSettings.SC_SECURITY.encryptionMethod.value = gcc.EncryptionMethod.ENCRYPTION_FLAG_128BIT
self._serverSettings.SC_SECURITY.encryptionLevel.value = gcc.EncryptionLevel.ENCRYPTION_LEVEL_HIGH
self._serverSettings.SC_SECURITY.serverRandom.value = rsa.randnum.read_random_bits(256)
self._serverSettings.SC_SECURITY.serverCertificate.certData = certificate
self._serverSettings.SC_SECURITY.serverCertificate.certData = self._presentation.getCertificate()
self._serverSettings.SC_CORE.clientRequestedProtocol.value = self._transport._requestedProtocol
self.setNextState(self.recvConnectInitial)

View File

@@ -591,7 +591,7 @@ class Server(SecLayer):
@param presentation: {Layer}
"""
SecLayer.__init__(self, presentation)
self._rsaPublicKey, self._rsaPrivateKey = rsa.newkeys(512)
self._rsaPublicKey, self._rsaPrivaterKey = rsa.newkeys(512)
def connect(self):
"""
@@ -602,6 +602,16 @@ class Server(SecLayer):
self.setNextState(self.recvClientRandom)
else:
self.setNextState(self.recvInfoPkt)
def getCertificate(self):
"""
@summary: generate proprietary certificate from rsa public key
"""
certificate = gcc.ProprietaryServerCertificate()
certificate.PublicKeyBlob.modulus.value = hex(self._rsaPublicKey.n)[2:-1].decode('hex')[::-1]
certificate.PublicKeyBlob.pubExp.value = self._rsaPublicKey.e
certificate.SignatureBlob.value = "\x00" * 72
return certificate
def recvClientRandom(self, s):
"""