Last active
September 30, 2026 22:09
-
-
Save markuta/166dcc8d6f50e6044186362645b61b8e to your computer and use it in GitHub Desktop.
frida native libssl.so hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setTimeout(function() { | |
| console.log("\n[*] Hooking libssl.so.3"); | |
| function patchOpenSSL() { | |
| var setVerifyPtr = null; | |
| var getVerifyResultPtr = null; | |
| try { | |
| var libssl = Process.getModuleByName("libssl.so.3"); | |
| setVerifyPtr = libssl.findExportByName("SSL_CTX_set_verify"); | |
| getVerifyResultPtr = libssl.findExportByName("SSL_get_verify_result"); | |
| } catch (modError) { | |
| // Module isn't loaded or visible yet | |
| console.log("[!] libssl.so.3 not loaded."); | |
| } | |
| if (setVerifyPtr) { | |
| console.log("[+] Hooking SSL_CTX_set_verify at " + setVerifyPtr); | |
| Interceptor.attach(setVerifyPtr, { | |
| onEnter: function(args) { | |
| // OpenSSL prototype: void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb cb) | |
| var originalMode = args[1].toInt32(); | |
| console.log("[+] Replace (" + originalMode + ") -> 0") | |
| // Directly write 0 (SSL_VERIFY_NONE) into the argument register index | |
| args[1] = ptr(0); | |
| } | |
| }); | |
| } | |
| if (getVerifyResultPtr) { | |
| console.log("[+] Hooking SSL_get_verify_result at " + getVerifyResultPtr); | |
| Interceptor.attach(getVerifyResultPtr, { | |
| onLeave: function (retval) { | |
| console.log("[+] Return (" + retval + ") -> 0"); | |
| // A return which points to 0 means a pass | |
| retval.replace(ptr(0)); | |
| } | |
| }); | |
| } | |
| return (setVerifyPtr || getVerifyResultPtr); | |
| } | |
| patchOpenSSL(); | |
| }, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment