pycrate-org / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats, especially telecom ones. Provides an ASN.1 compiler and a CSN.1 runtime.
https://github.com/pycrate-org/pycrate
GNU Lesser General Public License v2.1
32 stars 8 forks source link

RRCLTE ASN.1 endode and decode with requestedFreqBandsNR-MRDC-r15 #10

Closed cosmicDustOfLightLength closed 3 months ago

cosmicDustOfLightLength commented 3 months ago
from pycrate_asn1dir import RRCLTE
from binascii import unhexlify, hexlify

sch = RRCLTE.EUTRA_RRC_Definitions.DL_DCCH_Message

sch.from_uper(unhexlify('3829419fc0004080c1014181c2024284c909525581780cc0f70002000c0028009001a003c00b80190036008c013802f006200cc01b80390076010c025804d009e014402f806300ca01a40408083010a022c0468093012a025c04c809b013a027c05080a3014a029c05480ab016202cc05a80b7017202ec05e80bf0182030c06280c7019208041018205040e082410500000401003008014030070100240500b0180340801102404c0a01502c05c0c01903406c0e01d03c07c1002104408c1202504c09c140290540ac1602d05c0bc180310640d02004108410c2204508c11c248560ae02b0'))

# Convert  ASN.1 to text
asn1_text = sch.to_asn1()
print("before: "+ asn1_text)

#pack asn1_text to PDU
modified_sch = RRCLTE.EUTRA_RRC_Definitions.DL_DCCH_Message
modified_sch.from_asn1(asn1_text)
encoded_data = modified_sch.to_uper()

print("hexmod: ")
print(hexlify(encoded_data))

After decode HEX asn1_text have this bellow output:

before: {
  message c1 : ueCapabilityEnquiry : {
    rrc-TransactionIdentifier 0,
    criticalExtensions c1 : ueCapabilityEnquiry-r8 : {
      ue-CapabilityRequest {
        nr,
        eutra,
        eutra-nr
      },
      nonCriticalExtension {
        nonCriticalExtension {
          requestedFrequencyBands-r11 {
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            20,
            37,
            38,
            74,
            87
          },
          nonCriticalExtension {
            nonCriticalExtension {
              nonCriticalExtension {
                requestedFreqBandsNR-MRDC-r15 '0F70002000C0028009001A003C00B80190036008C013802F006200CC01B80390076010C025804D009E014402F806300CA01A40408083010A022C0468093012A025C04C809B013A027C05080A3014A029C05480AB016202CC05A80B7017202EC05E80BF0182030C06280C7019208041018205040E082410500000401003008014030070100240500B0180340801102404C0A01502C05C0C01903406C0E01D03C07C1002104408C1202504C09C140290540AC1602D05C0BC180310640D02004108410C2204508C11C248560AE0'H,
                nonCriticalExtension {
                  nonCriticalExtension {
                    nonCriticalExtension {
                      nonCriticalExtension {
                        rrc-SegAllowed-r16 enabled
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

How to decode "requestedFreqBandsNR-MRDC-r15" ? I want decode "requestedFreqBandsNR-MRDC-r15", edit and encode to HEX again

In Wireshark, all sections are decoded, combining with those contained in "requestedFreqBandsNR-MRDC-r15" The question is whether it is possible to decode this section with your program?

Thanks!

mitshell commented 3 months ago

Issue https://github.com/P1sec/pycrate/issues/206 and the following discussion in the old repository should help to understand and eventually solve this one.

cosmicDustOfLightLength commented 3 months ago

Thank it's work!