Search code examples
phpsms-gatewaygammu

gammu check balance using getussd is encrypted


i am in a developing message broadcast message.
i have a problem while to check balance. and the response is like :

Service reply        : "00500075006C007300610020003000200073002F006400200031004A
0075006E00310033002E0020004700610075006C002000420075006C0061006E0061006E00200031
002E003500470042002C005200700034003900720062002F0062006C006E002E0020004E00470045
0042005500540026004D0055005200410048000A00310020004D00610075000A003200200049006E
007400650072006E00650074002F00420042000A003300200050006B007400200053007500700065
0072002000480065006D00610074000A003400200050006B00740020004E0065006C0070006F006E
000A0035002000500072006F006D006F004B006F006E00740065006E000A00360020006D00500075
006C00730061000A00370020004D00790049006E0066006F000A"

how to read(decrypt) it?


Solution

  • Just had the same problem. Apparently these messages can be PDU-encoded like SMS (texts).

    But this kind of jumps right into ones eyes - it's four byte hex values (maybe Unicode? Then maybe reading into ByteArray and decoding to String may do the trick).

    Here's a quick Python 3 script:

    reply = "00500075006C007300610020003000200073002F006400200031004A" \
    "0075006E00310033002E0020004700610075006C002000420075006C0061006E0061006E00200031" \
    "002E003500470042002C005200700034003900720062002F0062006C006E002E0020004E00470045" \
    "0042005500540026004D0055005200410048000A00310020004D00610075000A003200200049006E" \
    "007400650072006E00650074002F00420042000A003300200050006B007400200053007500700065" \
    "0072002000480065006D00610074000A003400200050006B00740020004E0065006C0070006F006E" \
    "000A0035002000500072006F006D006F004B006F006E00740065006E000A00360020006D00500075" \
    "006C00730061000A00370020004D00790049006E0066006F000A"
    
    def chunks(l, n):
      """ Yield successive n-sized chunks from l.
          http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
      """
      for i in range(0, len(l), n):
        yield l[i:i+n]
    
    for chunk in list(chunks(reply, 4)):
      print( chr( int( chunk[2:],16) ), end="" )
    

    And the output:

    Pulsa 0 s/d 1Jun13. Gaul Bulanan 1.5GB,Rp49rb/bln. NGEBUT&MURAH
    1 Mau
    2 Internet/BB
    3 Pkt Super Hemat
    4 Pkt Nelpon
    5 PromoKonten
    6 mPulsa
    7 MyInfo