P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
380 stars 130 forks source link

EMMCPServiceRequest misses NASContainer decoding #225

Closed Marc-Egli closed 1 year ago

Marc-Egli commented 1 year ago

When decoding an EMMCPServiceRequest is seems that the NASContainer field is not recursively decoded.

Here is a code snippet that shows the wrong behavior:

from pycrate_mobile.NAS import *
from pycrate_mobile import *

# EMMCPServiceRequest is Mobile Originated
Msg, err = parse_NASLTE_MO(unhexlify('074d70780001ce6703091011570233c9d1'))

# NASContainer is not corretly decoded
show(Msg)

# EMMULNASTransport
Msg, err = parse_NASLTE_MO(unhexlify('0763020904'))

# NASContainer is correctly decoded
show(Msg)

EMMCPServiceRequest is a message from the UE to the network which means the condition in parse_NASLTE_MO should be modified.

https://github.com/P1sec/pycrate/blob/5120eb20fede8f5c2e6115946b711f4a0074b029/pycrate_mobile/NASLTE.py#L151

A fix would be to check if typ is also equal to 77 in the code line above and replace the elif statement by an if statement as an EMMCPServiceRequest contains both an ESMContainer and a NASContainer.

Thank you in advance.

p1-bmu commented 1 year ago

Thanks for reporting. This should be fixed after the 2 last commits.

Marc-Egli commented 1 year ago

Thank you !