Create a Kerberos ticket
(self, **kwargs)
| 928 | ) |
| 929 | |
| 930 | def create_ticket(self, **kwargs): |
| 931 | """ |
| 932 | Create a Kerberos ticket |
| 933 | """ |
| 934 | user = kwargs.get("user", self._prompt("User [User]: ") or "User") |
| 935 | domain = kwargs.get( |
| 936 | "domain", (self._prompt("Domain [DOM.LOCAL]: ") or "DOM.LOCAL").upper() |
| 937 | ) |
| 938 | domain_sid = kwargs.get( |
| 939 | "domain_sid", |
| 940 | self._prompt("Domain SID [S-1-5-21-1-2-3]: ") or "S-1-5-21-1-2-3", |
| 941 | ) |
| 942 | group_ids = kwargs.get( |
| 943 | "group_ids", |
| 944 | [ |
| 945 | int(x.strip()) |
| 946 | for x in ( |
| 947 | self._prompt("Group IDs [513, 512, 520, 518, 519]: ") |
| 948 | or "513, 512, 520, 518, 519" |
| 949 | ).split(",") |
| 950 | ], |
| 951 | ) |
| 952 | user_id = kwargs.get("user_id", int(self._prompt("User ID [500]: ") or "500")) |
| 953 | primary_group_id = kwargs.get( |
| 954 | "primary_group_id", int(self._prompt("Primary Group ID [513]: ") or "513") |
| 955 | ) |
| 956 | extra_sids = kwargs.get("extra_sids", None) |
| 957 | if extra_sids is None: |
| 958 | extra_sids = self._prompt("Extra SIDs [] :") or [] |
| 959 | if extra_sids: |
| 960 | extra_sids = [x.strip() for x in extra_sids.split(",")] |
| 961 | duration = kwargs.get( |
| 962 | "duration", int(self._prompt("Expires in (h) [10]: ") or "10") |
| 963 | ) |
| 964 | now_time = datetime.now(timezone.utc).replace(microsecond=0) |
| 965 | rand = random.SystemRandom() |
| 966 | key = Key.random_to_key( |
| 967 | EncryptionType.AES256_CTS_HMAC_SHA1_96, rand.randbytes(32) |
| 968 | ) |
| 969 | store = { |
| 970 | # KRB |
| 971 | "flags": ASN1_BIT_STRING("01000000111000010000000000000000"), |
| 972 | "key": { |
| 973 | "keytype": ASN1_INTEGER(key.etype), |
| 974 | "keyvalue": ASN1_STRING(key.key), |
| 975 | }, |
| 976 | "crealm": ASN1_GENERAL_STRING(domain), |
| 977 | "cname": { |
| 978 | "nameString": [ASN1_GENERAL_STRING(user)], |
| 979 | "nameType": ASN1_INTEGER(1), |
| 980 | }, |
| 981 | "authtime": ASN1_GENERALIZED_TIME(now_time), |
| 982 | "starttime": ASN1_GENERALIZED_TIME(now_time + timedelta(hours=duration)), |
| 983 | "endtime": ASN1_GENERALIZED_TIME(now_time + timedelta(hours=duration)), |
| 984 | "renewTill": ASN1_GENERALIZED_TIME(now_time + timedelta(hours=duration)), |
| 985 | # PAC |
| 986 | # Validation info |
| 987 | "VI.LogonTime": self._time_to_filetime(now_time.timestamp()), |
nothing calls this directly
no test coverage detected