Parse chanllenge response from server
This commit is contained in:
@@ -137,7 +137,7 @@ class RawLayerClientFactory(protocol.ClientFactory):
|
||||
"""
|
||||
raise CallPureVirtualFuntion("%s:%s defined by interface %s"%(self.__class__, "connectionLost", "RawLayerClientFactory"))
|
||||
|
||||
class RawLayerServerFactory(protocol.ClientFactory):
|
||||
class RawLayerServerFactory(protocol.ServerFactory):
|
||||
"""
|
||||
@summary: Abstract class for Raw layer server factory
|
||||
"""
|
||||
|
||||
@@ -125,5 +125,9 @@ def decodeDERTRequest(s):
|
||||
@summary: Decode the stream as
|
||||
@param s: {Stream}
|
||||
"""
|
||||
tRequest = decoder.decode(s.getvalue(), asn1Spec=TSRequest())
|
||||
print tRequest
|
||||
tRequest = decoder.decode(s.getvalue(), asn1Spec=TSRequest())[0]
|
||||
negoData = tRequest.getComponentByName("negoTokens")
|
||||
|
||||
result = [Stream(negoData.getComponentByPosition(i).getComponentByPosition(0).asOctets()) for i in range(len(negoData))]
|
||||
|
||||
return result
|
||||
@@ -94,7 +94,7 @@ class NegotiateMessage(CompositeType):
|
||||
"""
|
||||
def __init__(self):
|
||||
CompositeType.__init__(self)
|
||||
self.Signature = String("NTLMSSP\x00", constant = True)
|
||||
self.Signature = String("NTLMSSP\x00", readLen = CallableValue(8), constant = True)
|
||||
self.MessageType = UInt32Le(0x00000001, constant = True)
|
||||
|
||||
self.NegotiateFlags = UInt32Le(Negotiate.NTLMSSP_NEGOTIATE_KEY_EXCH |
|
||||
@@ -105,6 +105,7 @@ class NegotiateMessage(CompositeType):
|
||||
Negotiate.NTLMSSP_NEGOTIATE_SIGN |
|
||||
Negotiate.NTLMSSP_NEGOTIATE_SEAL |
|
||||
Negotiate.NTLMSSP_REQUEST_TARGET |
|
||||
Negotiate.NTLMSSP_NEGOTIATE_VERSION |
|
||||
Negotiate.NTLMSSP_NEGOTIATE_UNICODE)
|
||||
|
||||
self.DomainNameLen = UInt16Le()
|
||||
@@ -126,7 +127,7 @@ class ChallengeMessage(CompositeType):
|
||||
"""
|
||||
def __init__(self):
|
||||
CompositeType.__init__(self)
|
||||
self.Signature = String("NTLMSSP\x00", constant = True)
|
||||
self.Signature = String("NTLMSSP\x00", readLen = CallableValue(8), constant = True)
|
||||
self.MessageType = UInt32Le(0x00000002, constant = True)
|
||||
|
||||
self.TargetNameLen = UInt16Le()
|
||||
|
||||
@@ -230,5 +230,9 @@ class TPKT(RawLayer, IFastPathSender):
|
||||
def readNTLMChallenge(self, data):
|
||||
"""
|
||||
@summary: server NTLM challenge
|
||||
@param data: {Stream}
|
||||
"""
|
||||
print "toto"
|
||||
s = cssp.decodeDERTRequest(data)
|
||||
challenge = ntlm.ChallengeMessage()
|
||||
s[0].readType(challenge)
|
||||
print challenge.ServerChallenge.value
|
||||
@@ -148,11 +148,8 @@ def extractRSAKey(certificate):
|
||||
"""
|
||||
#http://www.alvestrand.no/objectid/1.2.840.113549.1.1.1.html
|
||||
|
||||
#extract binary data
|
||||
l = 0L
|
||||
for b in certificate.getComponentByName('tbsCertificate').getComponentByName('subjectPublicKeyInfo').getComponentByName('subjectPublicKey'):
|
||||
l = (l << 1) | b
|
||||
|
||||
binaryTuple = certificate.getComponentByName('tbsCertificate').getComponentByName('subjectPublicKeyInfo').getComponentByName('subjectPublicKey')
|
||||
l = int("".join([str(i) for i in binaryTuple]), 2)
|
||||
rsaKey = decoder.decode(hex(l)[2:-1].decode('hex'), asn1Spec=RSAPublicKey())[0]
|
||||
return rsaKey.getComponentByName('modulus')._value , rsaKey.getComponentByName('publicExponent')._value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user