louis49 / androidtv-remote

MIT License
74 stars 23 forks source link

Some keys not work #11

Closed XITRIX closed 2 years ago

XITRIX commented 2 years ago

Hi, thanks for your great work, I'm trying to rewrite your lib using Swift and it works pretty well already, but I've met the problem, that some important keys just don't work, in example KEYCODE_TV_INPUT, it's very important key on controller and it's not work.

In your lib they don't work either, do you have any idea why it could happen? Just for doublecheck I've tested the same key using ADB, and input source screen appears.

piyush2greedy commented 2 years ago

@XITRIX R u able to open tls connnection with server and get the response in ios.

XITRIX commented 2 years ago

Yes, I already have fully working prototype, the only problem - some keys not work

piyush2greedy commented 2 years ago

@XITRIX I also did implement for ios too in react native. can we connect over skype

louis49 commented 2 years ago

I use the key map from android ref : https://developer.android.com/reference/android/view/KeyEvent What’s the value work for that key ?

XITRIX commented 2 years ago

@louis49, yes, I'm also using it, and most of keys works perfectly, but some of them - doesn't and I cannot see any reason for it, the most valuable key for me is KEYCODE_TV_INPUT which is #178, this key does nothing using your lib and my replica of it, but using adb shell input keyevent 178 it opens sources screen without any problem. Tried with SHORT direction, and START_LONG\END_LONG, nothing. KEYCODE_PROG_RED and other 'colored' buttons also not work. Some other buttons also not works, but I don't even need them.

UP. Oh, I forgot, all keyboard keys like KEYCODE_A also not work

XITRIX commented 2 years ago

@louis49, what app did you used to capture socket traffic between your android device and android TV? If it's not a problem, could you write a small manual?

piyush2cloud commented 2 years ago

@XITRIX Did u used below library for making tls connection from ios to android TV. https://github.com/Kitura/BlueSSLService.

XITRIX commented 2 years ago

No, I've made it from scratch, maybe I'll try to modify BlueSSLService to be able to work with it, cause my implementation is not stable enough

piyush2greedy commented 2 years ago

@XITRIX Thanks. Any reference or doc if u can share to achieve tls connection. I am new to swift and ur guidance will be really helpful.

XITRIX commented 2 years ago

Sorry, but I cannot help with any detailed information until app I'm working on will be released

piyush2greedy commented 2 years ago

@XITRIX Ohk Ohk. I understand. I thought u r making it open source. Thanks by the way.

Will wait for ur app.

XITRIX commented 2 years ago

I think I'll open source it when it will be released

louis49 commented 2 years ago

@louis49, what app did you used to capture socket traffic between your android device and android TV? If it's not a problem, could you write a small manual?

You can use Wireshark to analyze packets : https://www.wireshark.org/

piyush2cloud commented 2 years ago

Hi, thanks for your great work, I'm trying to rewrite your lib using Swift and it works pretty well already, but I've met the problem, that some important keys just don't work, in example KEYCODE_TV_INPUT, it's very important key on controller and it's not work.

In your lib they don't work either, do you have any idea why it could happen? Just for doublecheck I've tested the same key using ADB, and input source screen appears.

@XITRIX Can u do a small favour in suggesting. Were u able to crack tls connection using swift. in other thread u said u did in C. https://github.com/Aymkdn/assistant-freebox-cloud/issues/131

XITRIX commented 2 years ago

There are bridging libraries for OpenSSL on Swift, I am using them

XITRIX commented 2 years ago

@louis49, Hi, I've tried to understand how to use Wireshark. I've tried to dump traffic using PCAPdroid, and dump ssl_keys.log using mitmproxy to decode ssl traffic inside Wireshark, but I always end with untrusted connection between phone and TV (System CA mitmproxy certificate installed), while I could see all ssl traffic of all other phone apps. SSL unpinning XPosed modules also doesn't help. Also tried Frida with Objection. Could you give some hints about how I could get decrypted traffic? May be you know some web articles where I could find useful information? Anyway the info I'm trying understand, is how phone send updates to the textfields on TV, so I could modify input text right from my device

techie-gabbar commented 2 years ago

There are bridging libraries for OpenSSL on Swift, I am using them

@XITRIX Thanks for your detailed work. I also need ur guidance. I only know Swift. Never did anything in Objective C or C. Is it possible to achieve it only using swift.

XITRIX commented 2 years ago

@techie-gabbar, Hi, yes, it is possible to do with Swift only + OpenSSL Swift bindings, but you still need to understand some C concepts, cause OpenSSL will work with OpaquePointers and also you will not find any manuals for OpenSSL on Swift, you'll need to translate C->Swift code manually.

louis49 commented 2 years ago

@louis49, Hi, I've tried to understand how to use Wireshark. I've tried to dump traffic using PCAPdroid, and dump ssl_keys.log using mitmproxy to decode ssl traffic inside Wireshark, but I always end with untrusted connection between phone and TV (System CA mitmproxy certificate installed), while I could see all ssl traffic of all other phone apps. SSL unpinning XPosed modules also doesn't help. Also tried Frida with Objection. Could you give some hints about how I could get decrypted traffic? May be you know some web articles where I could find useful information? Anyway the info I'm trying understand, is how phone send updates to the textfields on TV, so I could modify input text right from my device

You need to change the key/cert inside the application by decompile and recompile it : Then, you can set your own certificate inside whireshark to analyze packets

https://blog.isec.pl/introduction-to-apk-reverse-engineering-bypassing-root-detection-and-certificate-pinning/ https://braincoke.fr/blog/2021/03/android-reverse-engineering-for-beginners-decompiling-and-patching/#patching-with-apktool

XITRIX commented 2 years ago

@louis49, Thank you for the info, have you decompiled Home app or TV's service? I've tried to patch Home app with apktool, but it fails with recompiling it (guthub issues says, thats because google could uses some innersource versions of toolkits), with TV's service it works fine, but I could not install it, cause my TV cannot be rooted (my jailbroken Nintendo Switch with Android TV installed it perfectly, and my app could manipulate it's keys, but Home app just cannot see it). Anyway thanks for the articles, I'll investigate them carefully.

louis49 commented 2 years ago

@XITRIX I decompiled a remote app. I will investigate some day but not now how to add others functions that you speak about. i close this issue because it’s not relevant about this package

Ganime422 commented 2 years ago

@XITRIX have you managed to get the volume up & volume down keys to work? they also doesn't seem to work

techie-gabbar commented 2 years ago

@Ganime422 R u able to make Pairing work in IOS using Swift. Any insights would be helpful.

XITRIX commented 2 years ago

@Ganime422, no, they work without any problem, Google Home app sends default volume_up/down keycodes and they works fine

sz-ashik440 commented 2 years ago

Hello @XITRIX, I have generated SSL key with OpenSSL-for-iPhone. But can not find way to tap/ping/pair via socket with that SSL certificate. Any guidance would be helpful

Ganime422 commented 2 years ago

@XITRIX have you managed to send letters keys such as KEYCODE_A? I am able to send commands like dpads etc. but no letters nor numbers etc.

sz-ashik440 commented 1 year ago

With the help of Aymkdn/assistant-freebox-cloud KEYCODE_CHANNEL_UP, KEYCODE_CHANNEL_DOWN now working. All I have to do is change the send commands. For KEYCODE which has value over 2 digit(greater than 99) you have to send [ 82, 5, 8, <KEYCODE>, 1, 16, 3 ] other wise send [ 82, 4, 8, <KEYCODE>, 16, 3 ]

P.S: I still could not find any solution for keyboard inputs(KEYCODE_A and goes on to Z).