objection icon indicating copy to clipboard operation
objection copied to clipboard

Support output of Android byte[]s

Open aph3rson opened this issue 5 years ago • 8 comments

There's some preliminary information here on outputting a byte[] from Frida's JS environment.

aph3rson avatar Jan 25 '19 22:01 aph3rson

Hey, does this relate to using a byte array instead of the base64 encoding used for file transfers, or does this relate to something else?

leonjza avatar Jan 26 '19 07:01 leonjza

This is related to hooking an Android method - a custom encryption method I'm trying to reverse takes in/outputs an array of bytes. These are outputted in the Objection console as [object Object].

aph3rson avatar Jan 27 '19 01:01 aph3rson

I think I understand! We will have to sniff the argument type on the hook I think and handle byte arrays if we come across them separately. Keeping this one open.

leonjza avatar Jan 28 '19 18:01 leonjza

+1, would love to see this function in objection

mirkorobocop avatar Oct 01 '19 19:10 mirkorobocop

I would need a test case to replicate to work on this.

leonjza avatar Oct 01 '19 20:10 leonjza

@leonjza so here i have sample apk with this code:

public class MainActivity extends AppCompatActivity {

    private Button mButton;

    public byte[] a(){
        byte[] bArr = new byte[8];
        new SecureRandom().nextBytes(bArr);
        return bArr;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mButton = findViewById(R.id.clickButton);
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view)
            {
                a();
            }
        });
    }
}

apk link: https://mega.nz/#!aUR3AQgA!v8klzQvZpaVcUO-g2m9svkYKLCYzcmEA0bG7OBDJRNQ

adb install app-debug.apk
objection -g com.example.myapplication explore
Using USB device `Samsung XXX`
Agent injected and responds ok!

     _   _         _   _
 ___| |_|_|___ ___| |_|_|___ ___
| . | . | | -_|  _|  _| | . |   |
|___|___| |___|___|_| |_|___|_|_|
      |___|(object)inject(ion) v1.7.5

     Runtime Mobile Exploration
        by: @leonjza from @sensepost

[tab] for command suggestions
com.example.myapplication on (samsung: 9) [usb] # android hooking watch class_method com.example.myapplication.MainActivity.a --dump-args --dump-return
(agent) Attempting to watch class com.example.myapplication.MainActivity and method a.
(agent) Hooking com.example.myapplication.MainActivity.a()
(agent) Registering job pbjx954xbxb. Type: watch-method for: com.example.myapplication.MainActivity.a

now i click on button in app and get console output:

com.example.myapplication on (samsung: 9) [usb] # (agent) [pbjx954xbxb] Called com.example.myapplication.MainActivity.a()
(agent) [pbjx954xbxb] Return Value: [object Object]

mirkorobocop avatar Oct 01 '19 21:10 mirkorobocop

Hey guys, I’m bumping this hoping to see if it’s still on the radar. I would love to contribute to this myself since it’s something that I need quite urgently, however I’m not expert enough with objection codebase or frida to implement in a timely manner. With that being said, I’m willing to contribute financially if you’re able to implement this ASAP. Please let me know if/what example cases you may need. Thanks

jj0e avatar Jun 12 '21 04:06 jj0e

This being an open issue means it's still on the radar. However, I am just spread too thin at the moment to look at this right now.

leonjza avatar Jun 12 '21 07:06 leonjza