6767 print ("Not found :(" )
6868
6969## Extract certificates of a PE file
70+ ## This code is not a fixed API and the current state of my tests
7071
7172print ("" )
7273print ("== PE Analysis ==" )
7374TARGET_FILE = r"C:\windows\system32\ntdll.dll"
7475print ("Target sha1 = <{0}>" .format (hashlib .sha1 (open (TARGET_FILE , "rb" ).read ()).hexdigest ()))
7576cryptobj = windows .crypto .CryptObject (TARGET_FILE )
7677print ("Analysing {0}" .format (cryptobj ))
77- print ("File has {0} signer(s):" .format (cryptobj .nb_signer ))
78- for i , signer in (( i , cryptobj .get_signer_data ( i )) for i in range ( cryptobj . nb_signer ) ):
78+ print ("File has {0} signer(s):" .format (cryptobj .crypt_msg . nb_signer ))
79+ for i , signer in enumerate ( cryptobj .crypt_msg . signers ):
7980 print ("Signer {0}:" .format (i ))
8081 print (" * Issuer: {0!r}" .format (windows .crypto .ECRYPT_DATA_BLOB (signer .Issuer .cbData , signer .Issuer .pbData ).data ))
8182 print (" * HashAlgorithme: {0}" .format (signer .HashAlgorithm .pszObjId ))
82- cert = cryptobj .get_signer_certificate ( i )
83+ cert = cryptobj .cert_store . find ( signer . Issuer , signer . SerialNumber )
8384 print (" * Certificate: {0}" .format (cert ))
8485
8586print ("" )
86- print ("File embdeds {0} certificate(s):" .format (cryptobj .nb_cert ))
87- for i , certificate in (( i , cryptobj .get_cert ( i )) for i in range ( cryptobj . nb_cert ) ):
87+ print ("File embdeds {0} certificate(s):" .format (cryptobj .crypt_msg . nb_cert ))
88+ for i , certificate in enumerate ( cryptobj .crypt_msg . certs ):
8889 print (" * {0}) {1}" .format (i , certificate ))
0 commit comments