Python pyasn1.type.useful.GeneralizedTime() Examples
The following are 3
code examples of pyasn1.type.useful.GeneralizedTime().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyasn1.type.useful
, or try the search function
.
Example #1
Source File: kerberoast.py From kerberoast with Apache License 2.0 | 6 votes |
def updatetimestampsserverticket(ticket, authtime=None, starttime=None, endtime=None, renewtiltime=None): now = datetime.datetime.now() # yes, this regex isn't perfect, but neither are you if not authtime or not re.match(r'^20\d\d[0-1]\d[0-3]\d[0-2]\d[0-6]\d[0-6]\dZ$', authtime): authtime = now.strftime('%Y%m%d%H%M%SZ') if not starttime or not re.match(r'^20\d\d[0-1]\d[0-3]\d[0-2]\d[0-6]\d[0-6]\dZ$', starttime): starttime = now.strftime('%Y%m%d%H%M%SZ') if not endtime or not re.match(r'^20\d\d[0-1]\d[0-3]\d[0-2]\d[0-6]\d[0-6]\dZ$', endtime): endtime = (now + datetime.timedelta(hours=10)).strftime('%Y%m%d%H%M%SZ') if not renewtiltime or not re.match(r'^20\d\d[0-1]\d[0-3]\d[0-2]\d[0-6]\d[0-6]\dZ$', renewtiltime): renewtiltime = (now + datetime.timedelta(hours=24)).strftime('%Y%m%d%H%M%SZ') # Dear, pyasn1 # Why do I have to use a _ method to update a value. You expect me to write # an entire spec, I don't want to. Because of this I HATE YOU. Please # DIAF # -Tim # P.S. Suck it ticket.getComponentByPosition(5)._value = useful.GeneralizedTime(authtime) ticket.getComponentByPosition(6)._value = useful.GeneralizedTime(starttime) ticket.getComponentByPosition(7)._value = useful.GeneralizedTime(endtime) ticket.getComponentByPosition(8)._value = useful.GeneralizedTime(renewtiltime) return ticket
Example #2
Source File: x509.py From encompass with GNU General Public License v3.0 | 5 votes |
def extract_dates(self): validity = self.tbs.getComponentByName('validity') not_before = validity.getComponentByName('notBefore') not_before = str(not_before.getComponent()) not_after = validity.getComponentByName('notAfter') not_after = str(not_after.getComponent()) if isinstance(not_before, GeneralizedTime): not_before = datetime.strptime(not_before, '%Y%m%d%H%M%SZ') else: not_before = datetime.strptime(not_before, '%y%m%d%H%M%SZ') if isinstance(not_after, GeneralizedTime): not_after = datetime.strptime(not_after, '%Y%m%d%H%M%SZ') else: not_after = datetime.strptime(not_after, '%y%m%d%H%M%SZ') return not_before, not_after
Example #3
Source File: kerberoast.py From kerberoast with Apache License 2.0 | 5 votes |
def walk(t): if type(t) == str: print('String: %s' % t) else: print('Length: %i' % len(t)) for i in range(len(t)): print('---%i---' % i) print(t[i]) #Sequence().setComponentByPosition(0, BitString("'01000000101000010000000000000000'B")).setComponentByPosition(1, Sequence().setComponentByPosition(0, Integer(23)).setComponentByPosition(1, OctetString(hexValue='dfa121845d72f43271bbb33cd9e69443'))).setComponentByPosition(2, GeneralString('MEDIN.LOCAL')).setComponentByPosition(3, Sequence().setComponentByPosition(0, Integer(1)).setComponentByPosition(1, Sequence().setComponentByPosition(0, GeneralString('tm')))).setComponentByPosition(4, Sequence().setComponentByPosition(0, Integer(1)).setComponentByPosition(1, OctetString(''))).setComponentByPosition(5, GeneralizedTime('20140403172846Z')).setComponentByPosition(6, GeneralizedTime('20140403173119Z'))