nohajc / netflix-mitm-proxy

A tool for analyzing Netflix MSL API
MIT License
70 stars 18 forks source link

im not able to find session.json #8

Closed rdlogout closed 2 years ago

rdlogout commented 3 years ago

got the logs 2021-08-08 14:02:37.164 INFO : Could not open session.json

nohajc commented 3 years ago

The session.json file should be created on first run and it is saved to current working directory. Make sure you have write permissions.

rdlogout commented 3 years ago

The session.json file should be created on first run and it is saved to current working directory. Make sure you have write permissions.

Yes it have write permission thats how proxy.log file is creating everytime, but not session.json

WINOFFRG commented 3 years ago

Yes facing the same issue, I think something is broken, a little bit tweaking might fix the issue.

Here is the snippet of Error that I kept on getting in terminal.

127.0.0.1:13107: POST https://www.netflix.com/nq/msl_v1/cadmium/pbo_licenses/%5E1.0.0/router?reqAttempt=1&reqPriority… HTTP/2.0
     << HTTP/2.0 200 OK 2.65k
Addon error: Traceback (most recent call last):
  File "msl_decrypt.py", line 407, in response
    cipher = AES.new(MSLAESKey, AES.MODE_CBC, iv)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\Cryptodome\Cipher\AES.py", line 232, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\Cryptodome\Cipher\__init__.py", line 79, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\Cryptodome\Cipher\_mode_cbc.py", line 274, in _create_cbc_cipher
    cipher_state = factory._create_base_cipher(kwargs)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\Cryptodome\Cipher\AES.py", line 93, in _create_base_cipher
    raise ValueError("Incorrect AES key length (%d bytes)" % len(key))
ValueError: Incorrect AES key length (0 bytes)

Would be great, If we get a solution. @nohajc Could you please look at it?

WINOFFRG commented 3 years ago

Update:

  1. Upon checking the proxy.log file it had an error something like "Cannot open session.json"

    So I manually created the session.json file.

  2. The second error in proxy.log was "cannot parse the JSON"

    So I added { } a blank.

  3. Received a new error in terminal
Addon error: Traceback (most recent call last):
  File "msl_decrypt.py", line 188, in request
    initSession()
  File "msl_decrypt.py", line 155, in initSession
    keyEncoded = session["AESKey"]
KeyError: 'AESKey'

And this error is probably due to empty file. So why isn't the data being written into session.json file needs to be looked.

nohajc commented 3 years ago

Hi, I've made a change which should hopefully mitigate this problem. Can you verify it works now?

You still need to make sure the MSL handshake is intercepted, otherwise nothing will get decrypted. Anyway, the Could not open session.json message can be ignored as long as the whole script doesn't throw an exception.

WINOFFRG commented 3 years ago

Hey, Yes it works now. Thanks a lot! I did received the JSON containing key of length 22 Chars. But do you think if we have intercepted the right key coz I doubt it, Since AES CBC keys are 16, 24, or 36 in Length.

Moreover, Is it expected that the script after extracting the key is able to decipher and print/save all the decoded requests that connects us to the API? As I personally tried to extract the ciphertext from the JWTs and using the same key to decipher the text, But I struggled in the length since here it is 22. Is that so? Or I am in the wrong direction?

nohajc commented 3 years ago

Yes, if it works, the script should start logging decrypted requests and responses. What can you see in the log now?

Obviously, Netflix can change things whenever they want and I haven't updated the script for some time, so it could be broken completely... I can't guarantee I'll be able to maintain it long-term.