Skip to content

callidus/DecodeTTLV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DecodeTTLV

This little utility script will decode TTLV byte buffers as used in the KMIP protocol. The script requires the PyKMIP library for enum definitions. To use the script run it providing hex encoded TTLV data on the command line.

For example, the following data:

2022-08-22 14:15:28 [nae_srvr:4840:3086060352] INFO CryptoServices.cc:782 cmd.ingrian.nae.server.CryptoServices KMIP_RECV 10.35.0.218:47247 10.35.180.79:5696 3038 42007801000001084200770100000088420069010000002042006a0200000004000000010000000042006b0200000004000000000000000042000c01000000484200230100000040420024050000000400000001000000004200250100000028420099070000000d69647261632d4c4844343436310000004200a1070000000864656c6c3132333442000d0200000004000000010000000042000f010000007042005c05000000040000000a00000000420079010000005842009407000000403939463430383239373839433138394536373637393942454146353430333535323732333033324642444336414234384537434442394546373542363142334142004205000000040000000100000000
2022-08-22 14:15:28 [nae_srvr:4840:3086060352] INFO CryptoServices.cc:1023 cmd.ingrian.nae.server.CryptoServices KMIP_SEND 10.35.0.218:47247 10.35.180.79:5696 3038 42007b010000014842007a0100000048420069010000002042006a0200000004000000010000000042006b020000000400000000000000004200920900000008000000006303d5d042000d0200000004000000010000000042000f01000000f042005c05000000040000000a0000000042007f0500000004000000000000000042007c01000000c84200570500000004000000020000000042009407000000403939463430383239373839433138394536373637393942454146353430333535323732333033324642444336414234384537434442394546373542363142334142008f010000006842004001000000604200420500000004000000010000000042004501000000284200430800000020b019c1589222df7f0c930d943707b979bea2de78cafae531f7691ec5fd4ed4c64200280500000004000000030000000042002a02000000040000010000000000

Will be converted to human readable output like so:

python decode_ttlv.py "42007801000001084200770100000088420069010000002042006a0200000004000000010000000042006b0200000004000000000000000042000c01000000484200230100000040420024050000000400000001000000004200250100000028420099070000000d69647261632d4c4844343436310000004200a1070000000864656c6c3132333442000d0200000004000000010000000042000f010000007042005c05000000040000000a00000000420079010000005842009407000000403939463430383239373839433138394536373637393942454146353430333535323732333033324642444336414234384537434442394546373542363142334142004205000000040000000100000000"
REQUEST_MESSAGE:STRUCTURE(264):stru1
 REQUEST_HEADER:STRUCTURE(136):stru2
  PROTOCOL_VERSION:STRUCTURE(32):stru3
   PROTOCOL_VERSION_MAJOR:INTEGER(4):1
   PROTOCOL_VERSION_MINOR:INTEGER(4):0
  AUTHENTICATION:STRUCTURE(72):stru3
   CREDENTIAL:STRUCTURE(64):stru4
    CREDENTIAL_TYPE:ENUMERATION(4):USERNAME_AND_PASSWORD
    CREDENTIAL_VALUE:STRUCTURE(40):stru5
     USERNAME:TEXT_STRING(13):bytearray(b'idrac-LHD4461')
     PASSWORD:TEXT_STRING(8):bytearray(b'dell1234')
    BATCH_COUNT:INTEGER(4):1
    BATCH_ITEM:STRUCTURE(112):stru5
     OPERATION:ENUMERATION(4):GET
     REQUEST_PAYLOAD:STRUCTURE(88):stru6
      UNIQUE_IDENTIFIER:TEXT_STRING(64):bytearray(b'99F40829789C189E676799BEAF5403552723032FBDC6AB48E7CDB9EF75B61B3A')
      KEY_FORMAT_TYPE:ENUMERATION(4):RAW

python decode_ttlv.py "42007b010000014842007a0100000048420069010000002042006a0200000004000000010000000042006b020000000400000000000000004200920900000008000000006303d5d042000d0200000004000000010000000042000f01000000f042005c05000000040000000a0000000042007f0500000004000000000000000042007c01000000c84200570500000004000000020000000042009407000000403939463430383239373839433138394536373637393942454146353430333535323732333033324642444336414234384537434442394546373542363142334142008f010000006842004001000000604200420500000004000000010000000042004501000000284200430800000020b019c1589222df7f0c930d943707b979bea2de78cafae531f7691ec5fd4ed4c64200280500000004000000030000000042002a02000000040000010000000000"
RESPONSE_MESSAGE:STRUCTURE(328):stru1
 RESPONSE_HEADER:STRUCTURE(72):stru2
  PROTOCOL_VERSION:STRUCTURE(32):stru3
   PROTOCOL_VERSION_MAJOR:INTEGER(4):1
   PROTOCOL_VERSION_MINOR:INTEGER(4):0
  TIME_STAMP:DATE_TIME(8):Mon Aug 22 14:15:28 2022
  BATCH_COUNT:INTEGER(4):1
 BATCH_ITEM:STRUCTURE(240):stru2
  OPERATION:ENUMERATION(4):GET
  RESULT_STATUS:ENUMERATION(4):SUCCESS
  RESPONSE_PAYLOAD:STRUCTURE(200):stru3
   OBJECT_TYPE:ENUMERATION(4):SYMMETRIC_KEY
   UNIQUE_IDENTIFIER:TEXT_STRING(64):bytearray(b'99F40829789C189E676799BEAF5403552723032FBDC6AB48E7CDB9EF75B61B3A')
   SYMMETRIC_KEY:STRUCTURE(104):stru4
    KEY_BLOCK:STRUCTURE(96):stru5
     KEY_FORMAT_TYPE:ENUMERATION(4):RAW
     KEY_VALUE:STRUCTURE(40):stru6
      KEY_MATERIAL:BYTE_STRING(32):b'b019c1589222df7f0c930d943707b979bea2de78cafae531f7691ec5fd4ed4c6'
     CRYPTOGRAPHIC_ALGORITHM:ENUMERATION(4):AES
     CRYPTOGRAPHIC_LENGTH:INTEGER(4):256

About

Decode TTLV byte buffers used in the KMIP protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages