Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Extracting TLS keys from an unwilling application (2020) (m1el.github.io)
145 points by wwarner on May 24, 2022 | hide | past | favorite | 19 comments


Another useful tool I have used in the past in windows is Nektra Deviare for function hooking. This is similar to the old Microsoft Detours framework, in that one can dynamically patch code in the running binary. I have used this to grab raw keys.

https://www.nektra.com/products/deviare-api-hook-windows/


Nice work!

I'm curious: did you consider hacking the Oculus binary to accept an SSL cert you made yourself, and MITM-ing it to see the traffic?

I'm sure they have it pinned and don't use the OS certs, but you could just overwrite the root cert that must exist in that binary somewhere with your own, right?


> I'm curious: did you consider hacking the Oculus binary to accept an SSL cert you made yourself, and MITM-ing it to see the traffic?

Is that what he refers to when he says "I didn’t want to add extra root certificates and proxies to inspect all TLS traffic going on the machine", or are we talking about different things?


Maybe? I don't understand why "proxies" and "certificates" are plural, you would need exactly one of each.


> but you could just overwrite the root cert that must exist in that binary somewhere with your own, right?

Unless they use certificate pinning, which is basically just verifying the CA's are not tampered with. Theoretically that could be attacked as well, but it prevents the "just replace the CA" case.


the attack here is to just invert the compares for all the checks, which means it'll accept any certificate thats not the original, then you can MitM all the traffic with only minor changes to the binary.


Finding the right branches to flip in the text seems a lot more time consuming than just replacing the cert data, which is probably in one place. Unless it's incredibly obfuscated or something...


In hindsight this is probably a lot easier.


If they don't pin it's trivial. But I strongly suspect they do.


Is there a similar tool that a non-security expert could use on the Mac?


Not sure about the non-security expert bit but I've done stuff[0] similar to this for iOS using Frida[1] which supports macOS too. For apps that use unpinned certificates and the builtin networking libraries(NSURLSession et.al.) you can directly use mimtproxy[2] or Charles[3]

0: https://hugotunius.se/2020/08/07/stealing-tls-sessions-keys-...

1: https://frida.re/

2: https://mitmproxy.org/

3: https://www.charlesproxy.com/


I think you need to disable SIP to get a Frida based approach to work on MacOS

And while not MacOS this eBPF based approach is interesting https://mobile.twitter.com/quarkslab/status/1527726910997815...


If the application isn't pinning certificates, you should be able to add your own root certificate to your machine and intercept all encrypted traffic. Same method used by corporations to monitor their own networks. I successfully used this method on a mobile game years ago.

Applications with pinned certificates don't use the system certificates at all which fixes the MITM vulnerability I described. You'd need to reverse engineer them in order to change the certificate to one under your control, difficulty can vary depending on how obfuscated the code is.


You could try this, also Frida-based: https://github.com/SySS-Research/hallucinate


If your application can also use clear text TCP sockets, then stunnel becomes an option.


What resources could I use to learn how to do this sort of work on my own initiative?


If OpenSSL was under LGPL you could relink the Oculus software with a version of OpenSSL that supports exporting the keys.


You can still do that, but maybe not publish your method.


[flagged]


Meta: it's on the front page now.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: