当前位置: 首页>>代码示例>>Python>>正文


Python decoder.decode函数代码示例

本文整理汇总了Python中pyasn1.codec.ber.decoder.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getpac

def getpac(key, rawticket, debug=False, verbose=False):
	# attempt decoding of ticket
	try:
		ramticket, extra = decoder.decode(rawticket)
		serverticket = ramticket.getComponentByPosition(2)
		localticket = ramticket.getComponentByPosition(3)
		encserverticket = serverticket.getComponentByPosition(0).getComponentByPosition(3).getComponentByPosition(2).asOctets()
	except:
		raise ValueError('Unable to decode ticket. Invalid file.')
	if verbose: print 'Ticket succesfully decoded'

	decserverticketraw, nonce = kerberos.decrypt(key, 2, encserverticket)

	if decserverticketraw == None:
		raise ValueError('Unable to decrypt ticket. Invalid key.')
	elif verbose:
		print 'Decryption successful'

	
	decserverticket, extra = decoder.decode(decserverticketraw)
	# have two here because I was using one to verify that the rewrite matched
	# This stuff should be removed, if it is still here Tim forgot...again
	origdecserverticket, extra = decoder.decode(decserverticketraw)

	# change the validity times in the server ticket
	updatetimestampsserverticket(decserverticket, str(decserverticket[5]), str(decserverticket[6]), str(decserverticket[7]), str(decserverticket[8]))

	adifrelevant, extra = decoder.decode(decserverticket[9][0][1])
	pac = str(adifrelevant.getComponentByPosition(0).getComponentByPosition(1))

	return pac
开发者ID:KorayAgaya,项目名称:kerberoast,代码行数:31,代码来源:kerberoast.py

示例2: testShortEncoding

 def testShortEncoding(self):
     try:
         decoder.decode(ints2octs((9, 1, 131)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'accepted too-short real'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例3: decodeMessageVersion

def decodeMessageVersion(wholeMsg):
    try:
        seq, wholeMsg = decoder.decode(wholeMsg, recursiveFlag=0)
        ver, wholeMsg = decoder.decode(wholeMsg, recursiveFlag=0)
        return ver
    except PyAsn1Error:
        raise ProtocolError('Invalid BER at SNMP version component')
开发者ID:BoundaryDev,项目名称:boundary-plugin-mongodb-enterprise-dev,代码行数:7,代码来源:verdec.py

示例4: testDefiniteNoEoo

 def testDefiniteNoEoo(self):
     try:
         decoder.decode(ints2octs((0x23, 0x02, 0x00, 0x00)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted inside definite-length encoding'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例5: testNoConstructedEoo

 def testNoConstructedEoo(self):
     try:
         decoder.decode(ints2octs((0x23, 0x80, 0x20, 0x00)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted with invalid constructed encoding'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例6: testUnexpectedEoo

 def testUnexpectedEoo(self):
     try:
         decoder.decode(ints2octs((0, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted at top level'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例7: testReservedLength

 def testReservedLength(self):
     try:
         decoder.decode(ints2octs((6, 255, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'reserved length tolarated'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例8: testNoEooData

 def testNoEooData(self):
     try:
         decoder.decode(ints2octs((0x23, 0x80, 0x00, 0x01, 0x00)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted with unexpected data'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例9: testZeroLength

 def testZeroLength(self):
     try:
         decoder.decode(ints2octs((6, 0, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'zero length tolarated'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例10: testIndefiniteLength

 def testIndefiniteLength(self):
     try:
         decoder.decode(ints2octs((6, 128, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'indefinite length tolarated'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例11: testTypeChecking

 def testTypeChecking(self):
     try:
         decoder.decode(ints2octs((35, 4, 2, 2, 42, 42)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'accepted mis-encoded bit-string constructed out of an integer'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例12: testBadSpec

 def testBadSpec(self):
     try:
         decoder.decode(ints2octs((48, 2, 5, 0)), asn1Spec='not an Asn1Item')
     except PyAsn1Error:
         pass
     else:
         assert 0, 'Invalid asn1Spec accepted'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例13: testTagFormat

 def testTagFormat(self):
     try:
         decoder.decode(ints2octs((33, 1, 1)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'wrong tagFormat worked out'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例14: crackTicket

def crackTicket(ticket, label, hashList):
	try:
		data = base64.b64decode(ticket)
	except:
		#print "DEBUG\n" + str(ticket) + "DEBUG\n\n"
		return "FAIL" + str(label) + "\n"
	
	manager = Manager()
	enctickets = manager.list()

	if data[0] == '\x76':
		try:
			enctickets.append((str(decoder.decode(data)[0][2][0][3][2])))
		except:
			#print "DEBUG\n" + str(ticket) + "DEBUG\n\n"
			return "FAIL" + str(label)
	elif data[:2] == '6d':
		for ticket in data.strip().split('\n'):
			try:
				enctickets.append((str(decoder.decode(ticket.decode('hex'))[0][4][3][2])))
			except:
				#print "DEBUG\n" + str(ticket) + "DEBUG\n\n"
				return "FAIL" + str(label)

	print "\nAccount: " + label

	for currentHash in hashList:
		ntlmHash_hex = binascii.unhexlify(currentHash)
		kdata, nonce = kerberos.decrypt(ntlmHash_hex, 2, enctickets[0])
		if kdata:
			print "NTLM Hash: " + currentHash
			break

	return ""
开发者ID:xan7r,项目名称:kerberoast,代码行数:34,代码来源:autoTGS_NtlmCrack.py

示例15: testLeading0x80Case4

 def testLeading0x80Case4(self):
     try:
         decoder.decode(ints2octs((6, 2, 0x80, 0x7F)))
     except PyAsn1Error:
         pass
     else:
         assert 0, "Leading 0x80 tolarated"
开发者ID:shobull,项目名称:hue,代码行数:7,代码来源:test_decoder.py


注:本文中的pyasn1.codec.ber.decoder.decode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。