• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python decoder.decode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testLeading0x80Case1

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


示例17: testNoLongFormEoo

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


示例18: testSpec

 def testSpec(self):
     try:
         decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Null()) == (12, null)
     except PyAsn1Error:
         pass
     else:
         assert 0, "wrong asn1Spec worked out"
     assert decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Integer()) == (12, null)
开发者ID:shobull,项目名称:hue,代码行数:8,代码来源:test_decoder.py


示例19: tst_info

 def tst_info(self):
      x, substrate = decoder.decode(str(self.content['contentInfo']['content']))
      if substrate:
          raise ValueError('Incomplete decoding')
      x, substrate = decoder.decode(str(x), asn1Spec=TSTInfo())
      if substrate:
          raise ValueError('Incomplete decoding')
      return x
开发者ID:gebi,项目名称:python-rfc3161,代码行数:8,代码来源:types.py


示例20: updatepac

def updatepac(key, rawticket, pac, 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)

	#for i in range(len(decserverticket[3])):
	#	print '---%i---' % i
	#	print decserverticket[3][i]

	# 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])


	chksum = kerberos.chksum(key, '\x11\x00\x00\x00', pac)
	#print 'newchecksum:  %s' %  chksum.encode('hex')

	# repair server checksum
	newpac = pac[:-44] + chksum + pac[-28:]
	# rebuild AD-IF-RELEVANT
	#print adifrelevant
	#print dir(adifrelevant.getComponentByPosition(0).getComponentByPosition(1))
	adifrelevant.getComponentByPosition(0).getComponentByPosition(1)._value = newpac
	#print adifrelevant
	decserverticket.getComponentByPosition(9).getComponentByPosition(0).getComponentByPosition(1)._value = encoder.encode(adifrelevant)


	# put the ticket back together again
	newencserverticket = kerberos.encrypt(key, 2, encoder.encode(decserverticket), nonce)
	ramticket.getComponentByPosition(2).getComponentByPosition(0).getComponentByPosition(3).getComponentByPosition(2)._value = newencserverticket

	#print decserverticket

	return encoder.encode(ramticket)
开发者ID:KorayAgaya,项目名称:kerberoast,代码行数:55,代码来源:kerberoast.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python encoder.encode函数代码示例发布时间:2022-05-25
下一篇:
Python widget.WidgetConfigView类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap