Beispiel #1
0
def tgt_to_kirbi(tgs, encTGSRepPart):
	#encTGSRepPart is already decrypted at this point
	ci = {}
	ci['key'] = encTGSRepPart['key']
	ci['prealm'] = tgs['crealm']
	ci['pname'] = tgs['cname']
	ci['flags'] = encTGSRepPart['flags']
	ci['authtime'] = encTGSRepPart['authtime']
	ci['starttime'] = encTGSRepPart['starttime']
	ci['endtime'] = encTGSRepPart['endtime']
	ci['renew-till'] = encTGSRepPart['renew-till']
	ci['srealm'] = encTGSRepPart['srealm']
	ci['sname'] = encTGSRepPart['sname']

	ti = {}
	ti['ticket-info'] = [KrbCredInfo(ci)]

	te = {}
	te['etype']  = 0
	te['cipher'] = EncKrbCredPart(ti).dump()

	t = {}
	t['pvno'] = 5
	t['msg-type'] = 22
	t['enc-part'] = EncryptedData(te)
	t['tickets'] = [tgs['ticket']]

	return KRB_CRED(t)
Beispiel #2
0
	def to_kirbi(self):
		filename = '%s@%s_%s' % (self.client.to_string() , self.server.to_string(), hashlib.sha1(self.ticket.to_asn1()).hexdigest()[:8])
		krbcredinfo = {}
		krbcredinfo['key'] = EncryptionKey(self.key.to_asn1())
		krbcredinfo['prealm'] = self.client.realm.to_string()
		krbcredinfo['pname'] = self.client.to_asn1()[0]
		krbcredinfo['flags'] = core.IntegerBitString(self.tktflags).cast(TicketFlags)
		if self.time.authtime != 0: #this parameter is not mandatory, and most of the time not present
			krbcredinfo['authtime'] = datetime.datetime.fromtimestamp(self.time.authtime)
		krbcredinfo['starttime'] = datetime.datetime.fromtimestamp(self.time.starttime)
		krbcredinfo['endtime'] = datetime.datetime.fromtimestamp(self.time.endtime)
		if self.time.renew_till != 0: #this parameter is not mandatory, and sometimes it's not present
			krbcredinfo['renew-till'] = datetime.datetime.fromtimestamp(self.time.authtime)
		krbcredinfo['srealm'] = self.server.realm.to_string()
		krbcredinfo['sname'] = self.server.to_asn1()[0]
		
		enc_krbcred = {}
		enc_krbcred['ticket-info'] = [KrbCredInfo(krbcredinfo)]
		
		krbcred = {}
		krbcred['pvno'] = krb5_pvno
		krbcred['msg-type'] = MESSAGE_TYPE.KRB_CRED.value
		krbcred['tickets'] = [Ticket.load(self.ticket.to_asn1())]
		krbcred['enc-part'] = EncryptedData({'etype': EncryptionType.NULL.value, 'cipher': EncKrbCredPart(enc_krbcred).dump()})
	
	
	
		kirbi = KRBCRED(krbcred)
		return kirbi, filename
Beispiel #3
0
    def to_asn1(self):
        krbcredinfo = {}
        krbcredinfo['key'] = EncryptionKey({
            'keytype': self.KeyType,
            'keyvalue': self.Key
        })
        krbcredinfo['prealm'] = self.AltTargetDomainName
        krbcredinfo['pname'] = PrincipalName({
            'name-type': self.EClientName_type,
            'name-string': self.EClientName
        })
        krbcredinfo['flags'] = core.IntegerBitString(
            self.TicketFlags).cast(TicketFlags)
        krbcredinfo['starttime'] = self.StartTime
        krbcredinfo['endtime'] = self.EndTime
        krbcredinfo['renew-till'] = self.RenewUntil
        krbcredinfo['srealm'] = self.DomainName
        krbcredinfo['sname'] = PrincipalName({
            'name-type': self.ServiceName_type,
            'name-string': self.ServiceName
        })

        enc_krbcred = {}
        enc_krbcred['ticket-info'] = [KrbCredInfo(krbcredinfo)]

        ticket = {}
        ticket['tkt-vno'] = krb5_pvno
        ticket['realm'] = self.DomainName
        ticket['sname'] = PrincipalName({
            'name-type': NAME_TYPE.SRV_INST.value,
            'name-string': self.ServiceName
        })
        ticket['enc-part'] = EncryptedData({
            'etype': self.TicketEncType,
            'kvno': self.TicketKvno,
            'cipher': self.Ticket
        })

        krbcred = {}
        krbcred['pvno'] = krb5_pvno
        krbcred['msg-type'] = MESSAGE_TYPE.KRB_CRED.value
        krbcred['tickets'] = [Ticket(ticket)]
        krbcred['enc-part'] = EncryptedData({
            'etype':
            EncryptionType.NULL.value,
            'cipher':
            EncKrbCredPart(enc_krbcred).dump()
        })

        return KRBCRED(krbcred)