eclair4151 / samsung_encrypted_POC

A proof of concept to pair and send commands to H and J series Samsung TVs
10 stars 5 forks source link

Error: Max retries exceeded with url: /ws/apps/CloudPINPage #7

Closed ouija closed 6 years ago

ouija commented 6 years ago

Getting the following error when running main.py with Python3 in two different Ubuntu installations (one from a VM and another running via LinuxStation in a QNAP NAS -- so technically, both are VM):

Traceback (most recent call last): File "main.py", line 23, in requests.post(step0_pin_url,data='pin4') File "/home/admin/.local/lib/python3.5/site-packages/requests/api.py", line 112, in post return request('post', url, data=data, json=json, kwargs) File "/home/admin/.local/lib/python3.5/site-packages/requests/api.py", line 58, in request return session.request(method=method, url=url, kwargs) File "/home/admin/.local/lib/python3.5/site-packages/requests/sessions.py", line 508, in request resp = self.send(prep, send_kwargs) File "/home/admin/.local/lib/python3.5/site-packages/requests/sessions.py", line 618, in send r = adapter.send(request, kwargs) File "/home/admin/.local/lib/python3.5/site-packages/requests/adapters.py", line 508, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.0.0.46', port=8080): Max retries exceeded with url: /ws/apps/CloudPINPage (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8aa5661240>: Failed to establish a new connection: [Errno 110] Connection timed out',))

I realize this /ws/apps/CloudPINPage is the script trying to communicate with the television but is failing to do so; Any way I can define the IP address to look for? Does it auto-connect? Not sure why it's having issues, unless it has something to do with calling from a VM environment (

I do currently have the IP address for the television being assigned to a particular IP via my router, but haven't had issues with other pairing apps via Android such as Samsung's SmartView app, and am able to ping the TV from Linux.

Let me know if you have any suggestions.

eclair4151 commented 6 years ago

That error means it was not able to establish a connection with the TV. You have to change the IP address it is trying to use inside the main.py file line 17, it does not auto find TVs.

ouija commented 6 years ago

Well, don't I feel stupid :) I was quikly testing this out the other night and didn't even bother looking at the actual script -- you should mention that in the readme! (but I'm making excuses for my ineptness)

Had a hell of a time trying to get main.py to run (and was amazed that it did) as I was just randomly trying things after installing all the requirements (websocket-client, requests, pyCryptodome) and having it fail.

How I eventually managed to get it passed this error was to install both the crypto and pycrypto packages, then removed the pyCryptodome pacakage viv pip3 and installed it again via easyinstal (I know that having pycrypto and pyCryptodome alongside one another is a bad idea, but as I said, was just throwing everything at the wall here)_ and somehow this made it work! Or at least made the main.py script work, and I had it display the PIN code on the TV and send the test command successfully.

Running the debug.py script (after editing it with session and key) had a syntax error around the line "from Crypto import Random" I believe... I wanted to then try to not randomly get it working and figure out what I did to actually get it running, so I started over.

After attempting to run it again under an isolated virtual environment (using python3's venv command) I still ran into the same error when trying to run main.py the first time around:

# python3 main.py Traceback (most recent call last): File "main.py", line 7, in <module> import aes_lib File "/samsung/aes_lib.py", line 4, in <module> from Crypto.Cipher import AES File "/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 7, in <module> from Crypto.Cipher._mode_ctr import _create_ctr_cipher File "/lib/python3.6/site-packages/Crypto/Cipher/_mode_ctr.py", line 35, in <module> from Crypto.Util.number import long_to_bytes File "/lib/python3.6/site-packages/Crypto/Util/number.py", line 387 s = pack('>I', n & 0xffffffffL) + s ^ SyntaxError: invalid syntax

However, just managed to get it to finally pair with the TV again, but found that I had to use the pycrypto package over the pyCryptodome one to get it to work without the above error (which may be something to do with Python 3.6.2 on Entware-ng (which I'm using to run the script, on a QNAP based Intel NAS)

But alas, still having issue with debug.py:

Traceback (most recent call last): File "debug.py", line 3, in <module> from Crypto import Random File "/lib/python3.6/site-packages/Crypto/Random/__init__.py", line 28, in <module> from Crypto.Random import OSRNG File "/lib/python3.6/site-packages/Crypto/Random/OSRNG/__init__.py", line 32, in <module> from Crypto.Random.OSRNG.posix import new File "/lib/python3.6/site-packages/Crypto/Random/OSRNG/posix.py", line 66 except IOError, e: ^ SyntaxError: invalid syntax

But I figured since main.py was connecting and able to send a command, I might as well try and make that work for me... and I think it will! I've edited to a new script which seems to send commands to the TV without issue, even after a power on/off cycle (although I did read in that other post that removing the a/c completely will break the PIN pairing, so I won't be doing that)

Anyways, I just really wanted to thank you for this script and hopefully I'll be able to adapt it to my needs. If you have any ideas why I was running into any of these issues, I'm all ears...

Also curious about how the server for the DLLs is being hosted, in case it ever disappears -- I'm assuming this is what your https://github.com/eclair4151/SamsungEncryptServer repo is for? Could I possible have you send along the DLLs to me for safe keeping, in case I ever need to throw this up on another server for pairing purposes?

Thanks again!! Much appreciated for all your time and effort put into this project.

eclair4151 commented 6 years ago

The dlls are already included in the repo https://github.com/eclair4151/SamsungEncryptServer/tree/master/SamsungEncryptServer/Drivers