rumpeltux / onlineticket

Parser for online-tickets according to ETF-918.3
GNU General Public License v3.0
69 stars 10 forks source link

Ticket nicht dekodierbar #13

Closed jkampich1411 closed 6 months ago

jkampich1411 commented 1 year ago

Ich kann mein Ticket nicht dekodieren.

Ich hoffe es liegt nicht daran, dass:

Ich werde mein Ticket hier nicht öffentlich hochladen, da ich es noch ein paar Monate benutzen muss und nicht gerne modifiziert, etc, hätte, aber werde es über andere Kommunikationswege gerne an Maintainer oder Contributer bereitstellen!

Error log:

Couldn't decode ('data_length', 4, <class 'int'>) b'x\x9cuR' <class '__main__.OT'>

header: b'#UT'
version:        b'01'
carrier:        b'3306'
key_id: b'00008'
signature:      (81490986904044751270006267834755119286057096127, 491087473488507954577434382750464621430406442811)
Traceback (most recent call last):
  File "onlineticket.py", line 543, in <module>
    ot = OT(binary_ticket)
  File "onlineticket.py", line 85, in __init__
    self.header = self.dict_read(self.generic)
  File "onlineticket.py", line 117, in dict_read
    dat = val[3](self, res)
  File "onlineticket.py", line 463, in signature_decode
    decoded = asn1.decode(self.read(50))[0]
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 1289, in __call__
    value, substrate = concreteDecoder.valueDecoder(
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 501, in valueDecoder
    asn1Object, trailing = self._decodeComponents(
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 451, in _decodeComponents
    component, substrate = decodeFun(substrate, **options)
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 1164, in __call__
    raise error.SubstrateUnderrunError(
pyasn1.error.SubstrateUnderrunError: 53<20 at <TagSet object at 0x7f244ce72d30 tags 192:0:2>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "onlineticket.py", line 547, in <module>
    ot = OT(fixed)
  File "onlineticket.py", line 85, in __init__
    self.header = self.dict_read(self.generic)
  File "onlineticket.py", line 110, in dict_read
    dat = val[2](dat)
ValueError: invalid literal for int() with base 10: b'x\x9cuR'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "onlineticket.py", line 550, in <module>
    (repr(ot), repr(fixed), ticket, e, f))
NameError: name 'ot' is not defined
danielmarschall commented 1 year ago

Ich habe das selbe Problem. Ich habe aber eine Liste an Tickets, die in der Vergangenheit funktioniert haben. Die funktionieren auch nicht, d.h. es ist ein Bug und kein Problem mit neueren Tickets. Ich kenne mich leider nicht gut genug aus, was man hier machen muss.

danielmarschall commented 1 year ago
    generic = [
        ('header', 3),
        ('version', 2),
        ('carrier', 4),
        ('key_id', 5),
        ('signature', 0, None, signature_decode),
        ('data_length', 4, int),
        ('signature_validity', 0, None, signature_validity),

Scheinbar weis das Programm nicht, wo "data_length" ist, wenn es nicht weiß, wann die Signatur zu Ende ist? Ich habe jetzt PyASN1 und PyCryptoDome installiert ( aptitude install python3-pycryptodome python3-pyasn1 )

Jetzt sieht die Meldung ganz anders aus:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 1347, in __call__
    lastTag = tagCache[firstOctet]
              ~~~~~~~~^^^^^^^^^^^^
KeyError: '0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 544, in <module>
    ot = OT(binary_ticket)
         ^^^^^^^^^^^^^^^^^
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 86, in __init__
    self.header = self.dict_read(self.generic)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 118, in dict_read
    dat = val[3](self, res)
          ^^^^^^^^^^^^^^^^^
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 464, in signature_decode
    decoded = asn1.decode(self.read(50))[0]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pyasn1/codec/ber/decoder.py", line 1351, in __call__
    tagClass = integerTag & 0xC0
               ~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for &: 'str' and 'int'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 547, in <module>
    fixed = fix_zxing(binary_ticket)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 525, in fix_zxing
    data = data.decode('utf-8').encode('latin1')
           ^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/daten/homes/daniel-marschall/test/bahn/./onlineticket.py", line 551, in <module>
    (repr(ot), repr(fixed), ticket, e, f))
          ^^
NameError: name 'ot' is not defined. Did you mean: 'os'?
danielmarschall commented 11 months ago

Außerdem scheint es ein großes Problem zu sein, dass scheinbar nun Version 2 verwendet wird (Die Auftragsnummern sind nun auch Zahlen und keine Buchstaben mehr) und unbekannt ist, was die Unterschiede zwischen Version 1 und 2 sind. Aber als erstes muss man herausfinden, wieso sich die alten Tickets (die immer funktioniert haben) nicht mehr funktionieren

arnebr commented 9 months ago

Hallo Daniel, guck dir gerne mal meinen Fix hier an justusjonas74/uic-918-3#6#

danielmarschall commented 9 months ago

Hallo Arne,

ich bin etwas verwirrt. Was ist der Fix? Das ist ja ein NPM JavaScript Projekt (ich kenne mich mit npm überhaupt nicht aus). Was ist der Fix zum Python Script?

Ich glaube übrigens, dass es hier nicht nur ein Problem mit den neuen Codes gibt, sondern auch irgendwas ist mit dem Python-Script kaputt gegangen, denn bei mir funktioniert es gar nicht mehr (siehe oben), auch nicht mit über 10 Jahre alten Bahn-Codes , die immer funktionierten.

arnebr commented 9 months ago

Hallo Daniel, Der Fix im Node-Projekt ist die neue Ticket-Version II, die Logik ist dort erklärt. Ich habe leider keine Python Erfahrung, sonst hätte ich es portiert.

Vg Arne