Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Convert a GUID into valid OIDs of different forms. This produces the ISO OID in the 2.25 tree, the Microsoft one, and
- # three in the WaterJuice OID tree space.
- #
- # This is free and unencumbered software released into the public domain. Read https://unlicense.dev for details
- import sys
- import uuid
- try:
- myGuid = uuid.UUID( sys.argv[1] )
- except:
- print( "Syntax: guid2oid.py <Guid>" )
- sys.exit( 1 )
- # Create a 2.25.* OID (makes one large decimal from the guid)
- bigInt = int( myGuid.hex, 16 )
- oidForm1 = '2.25.%u' % bigInt
- # Create an MS 1.2.840.113556.1.8000.2554.* OID (breaks GUID into smaller parts)
- oidParts = [None] * 7
- oidParts[0] = str( int( myGuid.hex[0:4], 16 ) )
- oidParts[1] = str( int( myGuid.hex[4:8], 16 ) )
- oidParts[2] = str( int( myGuid.hex[8:12], 16 ) )
- oidParts[3] = str( int( myGuid.hex[12:16], 16 ) )
- oidParts[4] = str( int( myGuid.hex[16:20], 16 ) )
- oidParts[5] = str( int( myGuid.hex[20:26], 16 ) )
- oidParts[6] = str( int( myGuid.hex[26:32], 16 ) )
- oidForm2 = '1.2.840.113556.1.8000.2554.%s' % '.'.join(oidParts)
- # Create a WJ 1.3.6.1.4.1.54392.1.* OID (breaks GUID into 2 64 bit decimals)
- oidParts = [None] * 2
- oidParts[0] = str( int( myGuid.hex[0:16], 16 ) )
- oidParts[1] = str( int( myGuid.hex[16:32], 16 ) )
- oidForm3 = '1.3.6.1.4.1.54392.1.%s' % '.'.join(oidParts)
- # Create a WJ 1.3.6.1.4.1.54392.2.* OID (breaks GUID into 4 32 bit decimals)
- oidParts = [None] * 4
- oidParts[0] = str( int( myGuid.hex[0:8], 16 ) )
- oidParts[1] = str( int( myGuid.hex[8:16], 16 ) )
- oidParts[2] = str( int( myGuid.hex[16:24], 16 ) )
- oidParts[3] = str( int( myGuid.hex[24:32], 16 ) )
- oidForm4 = '1.3.6.1.4.1.54392.2.%s' % '.'.join(oidParts)
- # Create a WJ 1.3.6.1.4.1.54392.3.* OID (breaks GUID into 8 16 bit decimals)
- oidParts = [None] * 8
- oidParts[0] = str( int( myGuid.hex[0:4], 16 ) )
- oidParts[1] = str( int( myGuid.hex[4:8], 16 ) )
- oidParts[2] = str( int( myGuid.hex[8:12], 16 ) )
- oidParts[3] = str( int( myGuid.hex[12:16], 16 ) )
- oidParts[4] = str( int( myGuid.hex[16:20], 16 ) )
- oidParts[5] = str( int( myGuid.hex[20:24], 16 ) )
- oidParts[6] = str( int( myGuid.hex[24:28], 16 ) )
- oidParts[7] = str( int( myGuid.hex[28:32], 16 ) )
- oidForm5 = '1.3.6.1.4.1.54392.3.%s' % '.'.join(oidParts)
- # Print it
- print( myGuid )
- print( oidForm1 )
- print( oidForm2 )
- print( oidForm3 )
- print( oidForm4 )
- print( oidForm5 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement