Roku device charles set up

Hi All,

Does anyone had any luck setting up charlesproxy for roku device. Was wondering so that i can track and debug the http calls going away from the roku device.

Thanks in advance.

Regards,
Prajwal

If you have a network card that supports promiscuous mode, you may have some luck with WireShark, but Roku doesn’t support proxies. If you’re trying to trace the calls from your channel, then you could just output them all to the debug console as you make them.

IIRC, you can put your Roku into a packet tracing mode, which creates a cycle of (3 in think) output files than can be read into wireshark as a history file which will parse and display them in complete detail.

“sjb64” wrote:
IIRC, you can put your Roku into a packet tracing mode, which creates a cycle of (3 in think) output files than can be read into wireshark as a history file which will parse and display them in complete detail.
The tcpdump captures are extremely limited though. Only the first 200 bytes or so of each packet are captured. That’s often not even enough to capture the http headers.

OK, that was what I was thinking about, but you have a point that 200 or so bytes certainly isn’t “complete detail”. Still depending on need it might work, definitely helped me when I was dealing with debugging ECP launching and a M3U8 web server routine.

It has its uses, yes. I just wish they let you capture the whole packet. It’s probably a hangover from the days when Rokus had fewer gigabytes in their memories.

Sometimes I’ll run my server on my computer connected to the same local network as my Roku, and use Wireshark to capture the traffic on my computer’s wireless adapter.

As I mentioned in an email to a developer today who was having problems with Charles Proxy, you might consider using something that acts as the default gateway for your network, like:

https://mitmproxy.org/
http://grinder.sourceforge.net/g3/tcpproxy.html

http://xmodulo.com/how-to-set-up-transparent-proxy-on-linux.html

  • Joel

If you’re just looking to debug APIs I highly recommend Runscope. It’s a handy remote proxy https://www.runscope.com/docs/debugging.

Hi,

Thanks for all the help. Might be foolish question. The scenario i am trying to accomplish is capture all the traffic going out from my roku application from my machine. Both my PC and TV is connected to wireless.

Is there anything else i have to do apart from trying out the below apps.

Regards,
Prajwal

“prajwalshetty” wrote:
Hi,

Thanks for all the help. Might be foolish question. The scenario i am trying to accomplish is capture all the traffic going out from my roku application from my machine. Both my PC and TV is connected to wireless.

Is there anything else i have to do apart from trying out the below apps.

Regards,
Prajwal
Another way to do this if you’re running a Windows PC is to set up an ad-hoc network (or “hostednetwork” as they call it now on Windows 8 ), along with ICS (Internet Connection Sharing). Configure your Roku to connect to this network. Now all your Roku traffic will be going through your PC’s wireless card, and you can use Wireshark to examine it. As long as your network adapter supports hosted networks this may be the way to go, since you don’t need any additional hardware or proxies or APIs. You can capture any traffic going to/from your Roku, not just your own development channel, but other channels as well.

I’m not sure how you’d do this on a Mac or Linux system, but if you have Windows (I’ve been using it under Windows 8.1), then here are the steps involved:

First, set up the ad-hoc network:

  • Start a Windows command prompt (as Administrator!!)
  • Type: netsh wlan show drivers
  • Find the entry for your wireless interface and look for something that says “Hosted Network Supported: Yes”. If it says “Yes” then this should work, otherwise your wireless adapter does not support hosted networks.
  • Type: netsh wlan set hostednetwork mode=Allow ssid=“my-ssid” key=“my-password”
    where my-ssid is the name of the new network’s ssid and my-password is the password
  • Type: netsh wlan start hostednetwork

[Note that each time you restart your computer, or resume from Sleep state, you’ll have to reissue the above start hostednetwork command]

Next, set up Internet Connection Sharing:

  • Right-click on the wi-fi network icon in the system tray, then select ‘Open Network and Sharing Center’
  • Click on ‘Change Adapter Settings’
  • Right-click on the entry for your Wi-Fi adapter (NOT the new ad-hoc network), then click on ‘Properties’
  • If you successfully started the ad-hoc network you will see a ‘Sharing’ tab. Click the ‘Sharing’ tab
  • Check the box labelled ‘Allow other network users to connect through this computer’s Internet connection’, then click ‘OK’

Next, configure your Roku to connect to the new ad-hoc network:

  • Settings>Network>Wireless (Wi-Fi)>Set up new Wi-Fi connection
  • Select the ssid you specified above (my-ssid) for the new ad-hoc network, enter the password (my-password), then select Connect

Next, install Wireshark if you haven’t already installed it:

  • Download from https://www.wireshark.org/download.html. You can use the Windows Installer 64-bit version if you have a 64-bit PC
  • Run the installer selecting all default options, making sure to install WInPcap when asked

Finally, capture and examine your Roku traffic:

  • Run Wireshark
  • In the ‘Capture’ pane, select your Wi-Fi interface
  • Click the green ‘Start’ icon to start capturing
  • You can use the ‘Filter’ box to filter the traffic you’re interested in, e.g. to capture Http traffic to/from my Roku’s ip address, I’d type:
    http && ip.addr==192.168.0.8
    then click ‘Apply’
  • When you find an entry you’re interested in (e.g. an Http GET command), right-click on it and select ‘Follow TCP Stream’. This will bring up a window containing the entire Http dialog with options to display it in various formats, save it, etc.

Prajwal! It’s Tim! We got this working on OSX.

Note: This was tested with OS X 10.10 Yosemite

  1. Connect a Cat 5 ethernet cable to your Roku and your Mac’s ethernet port (I used the thunderbolt adapter)
  2. Go to System Preferences → Sharing → Internet Sharing
  3. Under "Share your connection from: ", select your WiFi. Then under "To computers using: ", select Thunderbolt Ethernet.
  4. Start up Charles and take note of the HTTP Proxy port set under Proxy Settings, by default its 8888. Make sure “Enable transparent HTTP Proxying” is checked.
  5. To route all traffic to the Charles proxy, we need to set the following Port Forwarding rule in the OS X terminal:
    echo "
    rdr pass inet proto tcp from any to any port http → 127.0.0.1 port 8888
    rdr pass inet proto tcp from any to any port https → 127.0.0.1 port 8888
    rdr pass inet proto udp from any to any port http → 127.0.0.1 port 8888
    rdr pass inet proto udp from any to any port https → 127.0.0.1 port 8888
    " | sudo pfctl -ef -
    After hitting enter it will prompt you to enter your machine password
  6. Connect the Roku to WIred (Ethernet) in the Network settings, and you should get a prompt to accept a connection in Charles once an internet request is made on the device
    :sunglasses: Note the Roku IP so you can debug using telnet

Has anyone figured out how to replicate this in Windows? Beating my head on the wall at this point…

Thanks

“tim_beynart” wrote:
Prajwal! It’s Tim! We got this working on OSX.

Note: This was tested with OS X 10.10 Yosemite

  1. Connect a Cat 5 ethernet cable to your Roku and your Mac’s ethernet port (I used the thunderbolt adapter)
  2. Go to System Preferences → Sharing → Internet Sharing
  3. Under "Share your connection from: ", select your WiFi. Then under "To computers using: ", select Thunderbolt Ethernet.
  4. Start up Charles and take note of the HTTP Proxy port set under Proxy Settings, by default its 8888. Make sure “Enable transparent HTTP Proxying” is checked.
  5. To route all traffic to the Charles proxy, we need to set the following Port Forwarding rule in the OS X terminal:
    echo "
    rdr pass inet proto tcp from any to any port http → 127.0.0.1 port 8888
    rdr pass inet proto tcp from any to any port https → 127.0.0.1 port 8888
    rdr pass inet proto udp from any to any port http → 127.0.0.1 port 8888
    rdr pass inet proto udp from any to any port https → 127.0.0.1 port 8888
    " | sudo pfctl -ef -
    After hitting enter it will prompt you to enter your machine password
  6. Connect the Roku to WIred (Ethernet) in the Network settings, and you should get a prompt to accept a connection in Charles once an internet request is made on the device
    :sunglasses: Note the Roku IP so you can debug using telnet
    This method worked for me and I see the http call without any error in charles but https calls does not work. Roku does not have option to install the charles certificate in Roku device. Do you have any input for https:// calls

This method worked for me and I see the http call without any error in charles but https calls does not work. Roku does not have option to install the charles certificate in Roku device. Do you have any input for https:// calls

we are trying to work out https, apparently you have to install the cert using Brightscript and forward all traffic to Charles. I’ll post once we get it to work.

I had no luck getting https to work with Charles. I have the iptable rules set up in a DDWRT router and route all traffic to the ip hosting Charles. I have the Charles cert in my app and point to it using “setCertificatesFile” for each instance of roUrlTransfer. But the secure traffic just shows up as blank lines with “invalid first character” errors.
I am out of my depth here, if anyone has figured out how to capture https then please let us know!

I have not gotten this to work for HTTPS at all. I tried every way to install a Charles cert I could think of, as did multiple other people here at work.
Wireshark is an option to at least see the HTTPS requests happening (not decrypted), but it it hideous to work with. Charles is part of our workflow for all other devices and platforms, I really wish Roku would add the ability to define a proxy like iOS and Android.
We reached out to Roku for assistance and are waiting for some guidance.

+1. Anything from Roku on this?

I’m 99% sure that you cannot do this.
The entire purpose of HTTPS is to prevent this.

Care to explain why? You can easily set up MITM with Charles on desktop. I am not a networking guru, so I would love a simple explanation of why this is impossible on a Roku.

I see no reason why you can’t set up a pass-through proxy by using whatever fudged SSL certificate client side it wants you to for a MitM. That does not contradict HTTPS security, since it is the client app that “willingly decides” to trust an additional cert. authority.

I am not in the thick of things here - but i heard from a 3rd party they’ve had problems setting Charles Proxy as MitM - but success using https://mitmproxy.org/ with Roku.

@tim_beynart - what did your inquiry with us resulted in?