Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to implement an X509TrustManager using Frida
'use strict';
var TrustManager;
var manager;
Java.perform(function () {
var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');
TrustManager = Java.registerClass({
name: 'com.example.TrustManager',
implements: [X509TrustManager],
methods: {
checkClientTrusted: function (chain, authType) {
console.log('checkClientTrusted');
},
checkServerTrusted: function (chain, authType) {
console.log('checkServerTrusted');
},
getAcceptedIssuers: function () {
console.log('getAcceptedIssuers');
return [];
}
}
});
manager = TrustManager.$new();
});
@yehgdotnet

This comment has been minimized.

yehgdotnet commented Feb 25, 2018

Not working in Android 4.4.2 👎

[Samsung GT-I9505::PID::13669]-> 'use strict';

                                 var TrustManager;
                                 var manager;

                                 Java.perform(function () {
                                   var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');

                                   TrustManager = Java.registerClass({
                                     name: 'com.example.TrustManager',
                                     implements: [X509TrustManager],
                                     methods: {
                                       checkClientTrusted: function (chain, authType) {
                                         console.log('checkClientTrusted');
                                       },
                                       checkServerTrusted: function (chain, authType) {
                                         console.log('checkServerTrusted');
                                       },
                                       getAcceptedIssuers: function () {
                                         console.log('getAcceptedIssuers');
                                         return [];
                                       }
                                     }
                                   });
                                   manager = TrustManager.$new();
                                 });
undefined
Error: java.lang.ClassNotFoundException: Didn't find class "com.example.TrustManager" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at frida/node_modules/frida-java/lib/env.js:220
    at ensureClass (frida/node_modules/frida-java/lib/class-factory.js:737)
    at frida/node_modules/frida-java/lib/class-factory.js:120
    at registerClass (frida/node_modules/frida-java/lib/class-factory.js:1939)
    at input:24
    at frida/node_modules/frida-java/lib/vm.js:39
    at y (frida/node_modules/frida-java/index.js:331)
    at frida/node_modules/frida-java/index.js:302
    at frida/node_modules/frida-java/lib/vm.js:39
[Samsung GT-I9505::PID::13669]-> exit

https://asciinema.org/a/KgLeRC2zDO4gEcoT8tdOerowt

@GeekTan

This comment has been minimized.

GeekTan commented Jul 24, 2018

same to error in ZTE U988S 4.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment