Code Monkey home page Code Monkey logo

Comments (3)

jxb5151 avatar jxb5151 commented on September 23, 2024

I don't believe we are extracting this information within the module. After looking over the code for the module, this snippet is instructive:

   # Eight bytes in due to the struct spec
   # typedef struct _WIN_CERTIFICATE
   # {
   #     DWORD       dwLength;
   #     WORD        wRevision;
   #     WORD        wCertificateType;   
   #     BYTE        bCertificate[ANYSIZE_ARRAY];
   # } WIN_CERTIFICATE, *LPWIN_CERTIFICATE;
   sig_buff = buff[address + 8 : address + 8 + size]

So we are just focusing on the buffer containing the bCertificate data exclusively, and parsing that data.

from fsf.

mayarblack avatar mayarblack commented on September 23, 2024

Thanks for replying.
I try to write a process of validating PE’s signature:
`

  1. Read PEHeaders: (done)

  • Read DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress
  • ReadDataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size
  1. Validate Certificate: (I don't know how)

  • Access attribute certificate table, parse PKCS #7 and X.509 v3 and extract the data (issuer, hashes, etc).
  • Validate the certificate information against the Certificates store using CryptQueryObject,
    CryptMsgGetParam and CertFindCertificateInStore.
  1. Validate File's Hash: (I don't know how)

  • Compare file's hash against the hash mentioned in PKCS #7's SignedData. If it matches, the file has a
    valid signature. If not, the digital signature is invalid`

Can you please help me to write a python script that do that process ?

from fsf.

jxb5151 avatar jxb5151 commented on September 23, 2024

Hmm, I'm not directly familiar with this process, but a little research turned up a few methods out there that might be of use to you:

x509 verification - http://aviadas.com/blog/2015/06/18/verifying-x509-certificate-chain-of-trust-in-python/
PKCS#7 - http://stackoverflow.com/questions/15979542/verify-signature-of-pkcs7-signed-file-using-python

You might also want to look at hashlib for hash comparisons.

from fsf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.