| 207 | |
| 208 | |
| 209 | class CCCredential(Packet): |
| 210 | fields_desc = [ |
| 211 | PacketField("client", CCPrincipal(), CCPrincipal), |
| 212 | PacketField("server", CCPrincipal(), CCPrincipal), |
| 213 | PacketField("keyblock", CCKeyBlock(), CCKeyBlock), |
| 214 | UTCTimeField("authtime", None), |
| 215 | UTCTimeField("starttime", None), |
| 216 | UTCTimeField("endtime", None), |
| 217 | UTCTimeField("renew_till", None), |
| 218 | ByteField("is_skey", 0), |
| 219 | FlagsField( |
| 220 | "ticket_flags", |
| 221 | 0, |
| 222 | 32, |
| 223 | # stored in reversed byte order (wtf) |
| 224 | (_TICKET_FLAGS + [""] * (32 - len(_TICKET_FLAGS)))[::-1], |
| 225 | ), |
| 226 | FieldLenField("num_address", None, count_of="addrs", fmt="I"), |
| 227 | PacketListField("addrs", [], CCAddress, count_from=lambda pkt: pkt.num_address), |
| 228 | FieldLenField("num_authdata", None, count_of="authdata", fmt="I"), |
| 229 | PacketListField( |
| 230 | "authdata", [], CCAuthData, count_from=lambda pkt: pkt.num_authdata |
| 231 | ), |
| 232 | PacketField("ticket", CCCountedOctetString(), CCCountedOctetString), |
| 233 | PacketField("second_ticket", CCCountedOctetString(), CCCountedOctetString), |
| 234 | ] |
| 235 | |
| 236 | def guess_payload_class(self, payload): |
| 237 | return conf.padding_layer |
| 238 | |
| 239 | def set_from_krb(self, tkt, clientpart, sessionkey, kdcrep): |
| 240 | self.ticket.data = bytes(tkt) |
| 241 | |
| 242 | # Set sname |
| 243 | self.server.name_type = tkt.sname.nameType.val |
| 244 | self.server.realm = CCCountedOctetString(data=tkt.realm.val) |
| 245 | self.server.components = [ |
| 246 | CCCountedOctetString(data=x.val) for x in tkt.sname.nameString |
| 247 | ] |
| 248 | |
| 249 | # Set cname |
| 250 | self.client.name_type = clientpart.cname.nameType.val |
| 251 | self.client.realm = CCCountedOctetString(data=clientpart.crealm.val) |
| 252 | self.client.components = [ |
| 253 | CCCountedOctetString(data=x.val) for x in clientpart.cname.nameString |
| 254 | ] |
| 255 | |
| 256 | # Set the sessionkey |
| 257 | self.keyblock = CCKeyBlock( |
| 258 | keytype=sessionkey.etype, |
| 259 | keyvalue=sessionkey.key, |
| 260 | ) |
| 261 | |
| 262 | # Set timestamps |
| 263 | self.authtime = kdcrep.authtime.datetime.timestamp() |
| 264 | if kdcrep.starttime is not None: |
| 265 | self.starttime = kdcrep.starttime.datetime.timestamp() |
| 266 | self.endtime = kdcrep.endtime.datetime.timestamp() |
no test coverage detected