GithubHelp home page GithubHelp logo

Extracting the keys about scapy-ssl_tls HOT 2 CLOSED

tintinweb avatar tintinweb commented on May 28, 2024
Extracting the keys

from scapy-ssl_tls.

Comments (2)

alexmgr avatar alexmgr commented on May 28, 2024

Hi Chaitanya,

Glad the tool helps!

(b) is trivial. Keys are stored inside the TLSSessionCtx. This is accessible via the tls_ctx property of the TLSSocket, or you can just build a TLSSessionCtx yourself.
From there, you can access the crypto material using:

tls_socket_ctx = tls_socket.tls_ctx
client_mac = tls_socket_ctx.session.key.client.mac
# Repeat for other crypto material

You can also convert to hex using the standard binascii module

>>> a = '-a\xc4\xdc\xb8\xb0\r\x0ck\xabK\x93\xe4\x9b\xb4\x0b\x86\xeb\x1f'
>>> import binascii
>>> binascii.hexlify(a)
'2d61c4dcb8b00d0c6bab4b93e49bb40b86eb1f'
>>> binascii.unhexlify(_)
'-a\xc4\xdc\xb8\xb0\r\x0ck\xabK\x93\xe4\x9b\xb4\x0b\x86\xeb\x1f'

Regarding (a), to get access to the master key (I'm assuming you're using RSA as key exchange), you can access tls_ctx.crypto.session.premaster_secret after the client hello. That will allow you to seed the PRF and derive the keys you need. The thing is that we currently generate the keys after the ClientKeyExchange, so you'll have to override the generated crypto material with the one you generate after that (always in the TLSSessionCtx)

Hope that helps!

from scapy-ssl_tls.

ch4174nya avatar ch4174nya commented on May 28, 2024

Yes, thanks that helped!

from scapy-ssl_tls.

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.