scripts/hook_durian.js
/*
     Show raw bytes as sent/received within locationd. Already misses the L2CAP metadata.
    */
Show raw bytes as sent/received within locationd. Already misses the L2CAP metadata.
Show raw bytes as sent / received within locationd . Already misses the L2CAP metadata .
showBytes() {
        var self = this;
        var {CLDurianDeviceManager} = ObjC.classes;
        Interceptor.attach(CLDurianDeviceManager['- centralManager:didSendBytes:toPeripheral:withError:'].implementation, {
            onEnter: function(args) {
                console.log("  * Sent bytes!");
            }
        });
        Interceptor.attach(CLDurianDeviceManager['- centralManager:didReceiveData:fromPeripheral:'].implementation, {
            onEnter: function(args) {
                var len = args[3].add(8).readU32();
                var op = args[3].add(0x10).readU8();
                console.log("  * Received " + len + " bytes! Opcode " + op + " (" + self.getDurianOpcodeDescription(op) + ")");
                if (op == 0) {
                    op = args[3].add(0x11).readU8();
                    console.log("              > ACKed Opcode " + op + " (" + self.getDurianOpcodeDescription(op) + ")");
                }
                else if (op == 255) {
                    op = args[3].add(0x11).readU8();
                    console.log("              > NACKed Opcode " + op + " (" + self.getDurianOpcodeDescription(op) + ")");
                }
                if (self.log_verbose) {
                    console.log(args[3].add(0x10).readByteArray(len));
                }
            }
        });
    }
showBytes ( ) { var self = this ; var { CLDurianDeviceManager } = ObjC . classes ; Interceptor . attach ( CLDurianDeviceManager [ '- centralManager:didSendBytes:toPeripheral:withError:' ] . implementation , { onEnter : function ( args ) { console . log ( "  * Sent bytes!" ) ; } } ) ; Interceptor . attach ( CLDurianDeviceManager [ '- centralManager:didReceiveData:fromPeripheral:' ] . implementation , { onEnter : function ( args ) { var len = args [ 3 ] . add ( 8 ) . readU32 ( ) ; var op = args [ 3 ] . add ( 0x10 ) . readU8 ( ) ; console . log ( "  * Received " + len + " bytes! Opcode " + op + " (" + self . getDurianOpcodeDescription ( op ) + ")" ) ; if ( op == 0 ) { op = args [ 3 ] . add ( 0x11 ) . readU8 ( ) ; console . log ( "              > ACKed Opcode " + op + " (" + self . getDurianOpcodeDescription ( op ) + ")" ) ; } else if ( op == 255 ) { op = args [ 3 ] . add ( 0x11 ) . readU8 ( ) ; console . log ( "              > NACKed Opcode " + op + " (" + self . getDurianOpcodeDescription ( op ) + ")" ) ; } if ( self . log_verbose ) { console . log ( args [ 3 ] . add ( 0x10 ) . readByteArray ( len ) ) ; } } } ) ; }
Show raw bytes as sent/received within locationd.
Show raw bytes as sent / received within locationd .
//self.print_backtrace(this.ctx); // log acknowledged opcode // also log raw bytes