Exemple #1
0
 def fromString(self, data=None):
     next_byte = unpack('B',data[:1])[0]
     if next_byte != ASN1_SEQUENCE:
         raise Exception('SEQUENCE expected! (%x)' % next_byte)
     data = data[1:]
     decode_data , length = asn1decode(data)
     next_byte = unpack('B',decode_data[:1])[0]
     if next_byte != 0xa0:
         raise Exception('0xa0 expected!')
     decode_data2 , backuplength = asn1decode(decode_data[1:])
     next_byte = unpack('B',decode_data2[:1])[0]
     if next_byte != 0x02:
         raise Exception('0x02 expected!')
     decode_data2 , length = asn1decode(decode_data2[1:])
     self['credType']=unpack('B',decode_data2)
     #Here, we should get back to credentials
     decode_data = decode_data[backuplength+1:]
     next_byte=unpack('B',decode_data[:1])[0]
     if next_byte != 0xa1:
         raise Exception('0xa1 expected')
     decode_data, length = asn1decode(decode_data[1:])
     next_byte = unpack('B', decode_data[:1])[0]
     if next_byte != ASN1_OCTET_STRING:
         raise Exception('ASN1 expected')
     decode_data, length = asn1decode(decode_data[1:])
     self['credentials']=decode_data
Exemple #2
0
   def fromString(self, data=None):
        next_byte = unpack('B', data[:1])[0]
        if next_byte != ASN1_SEQUENCE:
            raise Exception('SEQUENCE expected')
        data = data[1:]
        decode_data , length = asn1decode(data)
        next_byte = unpack('B',decode_data[:1])[0]

        #Getting in domainName section
        if next_byte != 0xa0:
            raise Exception('0xa0 expected')
        decode_data2 , backuplength = asn1decode(decode_data[1:])
        next_byte = unpack('B', decode_data2[:1])[0]
        if next_byte != ASN1_OCTET_STRING:
            raise Exception('ASN OCTET expected')
        decode_data2, length = asn1decode(decode_data2[1:])
        self['domainName'] = decode_data2.decode('utf-16le')

        #Restoring length and moving on to username section
        decode_data = decode_data[backuplength+1:]
        next_byte = unpack('B', decode_data[:1])[0]
        if next_byte != 0xa1:
            raise Exception('0xa1 expected')
        decode_data2 , backuplength  = asn1decode(decode_data[1:])
        next_byte = unpack('B', decode_data2[:1])[0]
        if next_byte != ASN1_OCTET_STRING:
            raise Exception('ASN OCTET expected 2')
        decode_data2, length = asn1decode(decode_data2[1:])
        self['userName'] = decode_data2.decode('utf-16le')

        #Restoring length and moving on to password section
        decode_data = decode_data[backuplength+1:]
        next_byte = unpack('B', decode_data[:1])[0]
        if next_byte != 0xa2:
            raise Exception('0xa2 expected 3')
        decode_data2 , backuplength  = asn1decode(decode_data[1:])
        next_byte = unpack('B', decode_data2[:1])[0]
        if next_byte != ASN1_OCTET_STRING:
            raise Exception('ASN OCTET expected')
        decode_data2, length = asn1decode(decode_data2[1:])
        self['password'] = decode_data2.decode('utf-16le')
Exemple #3
0
   def fromString(self, data = None):
       next_byte = unpack('B',data[:1])[0]
       if next_byte != ASN1_SEQUENCE:
           raise Exception('SEQUENCE expected! (%x)' % next_byte)
       data = data[1:]
       decode_data, total_bytes = asn1decode(data) 

       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte !=  0xa0:
            raise Exception('0xa0 tag not found %x' % next_byte)
       decode_data = decode_data[1:]
       next_bytes, total_bytes = asn1decode(decode_data)                
       # The INTEGER tag must be here
       if unpack('B',next_bytes[0])[0] != 0x02:
           raise Exception('INTEGER tag not found %r' % next_byte)
       next_byte, _ = asn1decode(next_bytes[1:])
       self['Version'] = unpack('B',next_byte)[0]
       decode_data = decode_data[total_bytes:]
       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte == 0xa1:
           # We found the negoData token
           decode_data, total_bytes = asn1decode(decode_data[1:])
       
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])

           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])

           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != 0xa0:
               raise Exception('0xa0 tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])
   
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           # the rest should be the data
           self['NegoData'] = decode_data2
           decode_data = decode_data[total_bytes+1:]

       if next_byte == 0xa2:
           # ToDo: Check all this
           # We found the authInfo token
           decode_data, total_bytes = asn1decode(decode_data[1:])
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           self['authInfo'] = decode_data2
           decode_data = decode_data[total_bytes+1:]

       if next_byte == 0xa3:
           # ToDo: Check all this
           # We found the pubKeyAuth token
           decode_data, total_bytes = asn1decode(decode_data[1:])
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           self['pubKeyAuth'] = decode_data2
Exemple #4
0
   def fromString(self, data = None):
       next_byte = unpack('B',data[:1])[0]
       if next_byte != ASN1_SEQUENCE:
           raise Exception('SEQUENCE expected! (%x)' % next_byte)
       data = data[1:]
       decode_data, total_bytes = asn1decode(data) 

       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte !=  0xa0:
            raise Exception('0xa0 tag not found %x' % next_byte)
       decode_data = decode_data[1:]
       next_bytes, total_bytes = asn1decode(decode_data)                
       # The INTEGER tag must be here
       if unpack('B',next_bytes[0])[0] != 0x02:
           raise Exception('INTEGER tag not found %r' % next_byte)
       next_byte, _ = asn1decode(next_bytes[1:])
       self['Version'] = unpack('B',next_byte)[0]
       decode_data = decode_data[total_bytes:]
       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte == 0xa1:
           # We found the negoData token
           decode_data, total_bytes = asn1decode(decode_data[1:])
       
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])

           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])

           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != 0xa0:
               raise Exception('0xa0 tag not found %r' % next_byte)
           decode_data, total_bytes = asn1decode(decode_data[1:])
   
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           # the rest should be the data
           self['NegoData'] = decode_data2
           decode_data = decode_data[total_bytes+1:]

       if next_byte == 0xa2:
           # ToDo: Check all this
           # We found the authInfo token
           decode_data, total_bytes = asn1decode(decode_data[1:])
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           self['authInfo'] = decode_data2
           decode_data = decode_data[total_bytes+1:]

       if next_byte == 0xa3:
           # ToDo: Check all this
           # We found the pubKeyAuth token
           decode_data, total_bytes = asn1decode(decode_data[1:])
           next_byte = unpack('B',decode_data[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           self['pubKeyAuth'] = decode_data2
Exemple #5
0
    def fromString(self, data=None):
        next_byte = unpack('B', data[:1])[0]
        if next_byte != ASN1_SEQUENCE:
            raise Exception('SEQUENCE expected! (%x)' % next_byte)
        data = data[1:]
        decode_data, total_bytes = asn1decode(data)

        next_byte = unpack('B', decode_data[:1])[0]
        if next_byte != 0xa0:
            raise Exception('0xa0 tag not found %x' % next_byte)
        decode_data = decode_data[1:]
        next_bytes, total_bytes = asn1decode(decode_data)
        if unpack('B', next_bytes[0:1])[0] != 0x02:
            raise Exception('INTEGER tag not found %r' % next_byte)
        next_byte, _ = asn1decode(next_bytes[1:])
        self['Version'] = unpack('B', next_byte)[0]
        decode_data = decode_data[total_bytes:]
        next_byte = unpack('B', decode_data[:1])[0]
        if next_byte == 0xa1:
            decode_data, total_bytes = asn1decode(decode_data[1:])

            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != ASN1_SEQUENCE:
                raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
            decode_data, total_bytes = asn1decode(decode_data[1:])

            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != ASN1_SEQUENCE:
                raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
            decode_data, total_bytes = asn1decode(decode_data[1:])

            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != 0xa0:
                raise Exception('0xa0 tag not found %r' % next_byte)
            decode_data, total_bytes = asn1decode(decode_data[1:])

            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != ASN1_OCTET_STRING:
                raise Exception('ASN1_OCTET_STRING tag not found %r' %
                                next_byte)
            decode_data2, total_bytes = asn1decode(decode_data[1:])
            self['NegoData'] = decode_data2
            decode_data = decode_data[total_bytes + 1:]

        if next_byte == 0xa2:
            decode_data, total_bytes = asn1decode(decode_data[1:])
            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != ASN1_OCTET_STRING:
                raise Exception('ASN1_OCTET_STRING tag not found %r' %
                                next_byte)
            decode_data2, total_bytes = asn1decode(decode_data[1:])
            self['authInfo'] = decode_data2
            decode_data = decode_data[total_bytes + 1:]

        if next_byte == 0xa3:
            decode_data, total_bytes = asn1decode(decode_data[1:])
            next_byte = unpack('B', decode_data[:1])[0]
            if next_byte != ASN1_OCTET_STRING:
                raise Exception('ASN1_OCTET_STRING tag not found %r' %
                                next_byte)
            decode_data2, total_bytes = asn1decode(decode_data[1:])
            self['pubKeyAuth'] = decode_data2
Exemple #6
0
   def fromString(self, data = None):
       next_byte = unpack('B',data[:1])[0]
       if next_byte != ASN1_SEQUENCE:
           raise Exception('SEQUENCE expected! (%x)' % next_byte)
       data = data[1:]
       decode_data, total_bytes = asn1decode(data)

       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte !=  0xa0:
            raise Exception('0xa0 tag not found %x' % next_byte)
       decode_data = decode_data[1:]
       next_bytes, total_bytes = asn1decode(decode_data)
       # The INTEGER tag must be here
       if unpack('B',next_bytes[0:1])[0] != 0x02:
           raise Exception('INTEGER tag not found %r' % next_byte)
       next_byte, _ = asn1decode(next_bytes[1:])
       self['Version'] = unpack('B',next_byte)[0]
       decode_data = decode_data[total_bytes:]
       next_byte = unpack('B',decode_data[:1])[0]
       if next_byte == 0xa1:
           # We found the negoData token
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           backup_length = total_bytes

           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])

           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_SEQUENCE:
               raise Exception('ASN1_SEQUENCE tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])

           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != 0xa0:
               raise Exception('0xa0 tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])

           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])
           # the rest should be the data
           self['NegoData'] = decode_data2
           # Set decode data to the next part of the SPNEGO TOKEN
           decode_data = decode_data[backup_length+1:]
           #Check if we still have some data left. Setting next_byte for the next check in case we do.
           if len(decode_data) != 0:
              next_byte = unpack('B',decode_data[:1])[0]


       if next_byte == 0xa2:
           # ToDo: Check all this
           # We found the authInfo token
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           backup_length = total_bytes
           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])
           self['authInfo'] = decode_data2
           # Set decode data to the next part of the SPNEGO TOKEN
           decode_data = decode_data[backup_length+1:]
           #Check if we still have some data left. Setting next_byte for the next check in case we do.
           if len(decode_data) != 0 :
               next_byte = unpack('B',decode_data[:1])[0]

       if next_byte == 0xa3:
           # ToDo: Check all this
           # We found the pubKeyAuth token
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           backup_length = total_bytes
           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])
           self['pubKeyAuth'] = decode_data2
           # Set decode data to the next part of the SPNEGO TOKEN
           decode_data = decode_data[backup_length+1:]
           #Check if we still have some data left. Setting next_byte for the next check in case we do.
           if len(decode_data) != 0 :
               next_byte = unpack('B',decode_data[:1])[0]

       if next_byte == 0xa4:
           # ToDo: Check all this
           # We found an errorCode
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           backup_length = total_bytes
           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])
           self['errorCode'] = decode_data2
           # Set decode data to the next part of the SPNEGO TOKEN
           decode_data = decode_data[backup_length+1:]
           #Check if we still have some data left. Setting next_byte for the next check in case we do.
           if len(decode_data) != 0 :
               next_byte = unpack('B',decode_data[:1])[0]

       if next_byte == 0xa5:
           # ToDo: Check all this
           # We found an clientNonce
           decode_data2, total_bytes = asn1decode(decode_data[1:])
           backup_length = total_bytes
           next_byte = unpack('B',decode_data2[:1])[0]
           if next_byte != ASN1_OCTET_STRING:
               raise Exception('ASN1_OCTET_STRING tag not found %r' % next_byte)
           decode_data2, total_bytes = asn1decode(decode_data2[1:])
           self['clientNonce'] = decode_data2
           # Set decode data to the next part of the SPNEGO TOKEN
           decode_data = decode_data[backup_length+1:]
           #Check if we still have some data left. Setting next_byte for the next check in case we do.
           if len(decode_data) != 0 :
               next_byte = unpack('B',decode_data[:1])[0]