Gira hat es ja seit 10 Monaten nicht geschafft ein Update für den GPA zur Verfügung zu stellen, welcher mit ETS6 kompatibel ist. Das Problem tritt auf, wenn man einen Passwortschutz in ETS aktiviert hat (bei Secure KNX notwendig). ETS6 hat aus mir unbekannten Gründen die Daten anders verschlüsselt als in der Vergangenheit. Somit muß man die Datenpunkte manuell nachführen, was extrem nervig ist.
Ich habe hier eine Lösung in Form eines Python Scripts, welches den Passwortschutz (ETS5 und ETS6) aus einem knxproj einfach entfernt. Dieses knxproj kann man dann problemlos in GPA importieren.
Einige Anmerkungen:
Ich habe hier eine Lösung in Form eines Python Scripts, welches den Passwortschutz (ETS5 und ETS6) aus einem knxproj einfach entfernt. Dieses knxproj kann man dann problemlos in GPA importieren.
Einige Anmerkungen:
- Das knxproj ohne Passwort nicht in ETS6 importieren. Ich habe keine Ahnung, wie sich das verhält.
- Der Filename ist der originale Filename plus " NOPW". Das originale Projekt wird nicht verändert!
- Man muß je nach Installation von Python3 ggf. mit pip einige Dinge nachinstallierten.
- Der Script funktioniert auf meinem Macintosh, sollte aber auch problemlos auf UNIX funktionieren. Windows? Keine Ahnung.
- Das ETS6 Projekt ist ein ZIP File, welches man auch manuell auspacken kann. In der oberen Ebene findet sich ein P-xxxx.ZIP, welches das eigentliche Projekt enthält. Es ist mit einem Passwort geschützt. Mit ETS5 war das Passwort einfach das gewählte Passwort. Seit ETS6 ist es der Hash des Passworts als Base64 Text. encryptedPassword ist das Passwort. Man kann den Script auch vereinfachen und nur das encryptedPassword ausgeben und dann das P-xxxx.ZIP mit diesem Passwort selbst auspacken. Dann mit ZIP manuell ohne Passwort wieder einpacken und danach den KNXPROJ als ganzes ebenfalls. Sprich: mit Ausnahme der Berechnung des Passworts kann man alles manuell machen.
Code:
# This Python script removes the password from an ETS5/ETS6 project. # This is especially useful, because ETS6 files can not be read by # the Gira Project Assistant 4.7. By removing the password, it "just works". import os import io import zipfile import base64 from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC import pyzipper import sys filename = 'PROJEKT.knxproj' password = 'PASSWORT' encryptedPassword = base64.b64encode( PBKDF2HMAC( algorithm=hashes.SHA256(), length=32, salt=b"21.project.ets.knx.org", iterations=65536, ).derive(password.encode("utf-16-le")) ) path = os.path.dirname(filename) name,ext = os.path.splitext(os.path.basename(filename)) if ext != '.knxproj': print('Not an ETS file!') sys.exit(-1) destFilename = os.path.join(path,name + ' NOPW' + ext) # write a new knxproj file with zipfile.ZipFile(destFilename, 'w') as wzip: # read the old knxproj file with zipfile.ZipFile(filename, 'r') as zip: for info in zip.infolist(): _,extension = os.path.splitext(info.filename) # the ZIP file with the P- prefix is the encrypted one, this needs to be decrypted if extension == '.zip' and info.filename.startswith('P-'): # decrypt all files within the encrypted ZIP into a bytes strem enczip_buffer = io.BytesIO() with zipfile.ZipFile(enczip_buffer, 'a', zipfile.ZIP_DEFLATED, False) as wrzip_file: with pyzipper.AESZipFile(io.BytesIO(zip.read(info.filename)), 'r', encryption=pyzipper.WZ_AES) as ezip: for info2 in ezip.infolist(): try: # ETS5 uses the password directly to encrypt the ZIP wrzip_file.writestr(info2.filename, ezip.read(info2.filename, pwd=password)) except: # ETS6 uses an encrypted password try: wrzip_file.writestr(info2.filename, ezip.read(info2.filename, pwd=encryptedPassword)) except: # no password wrzip_file.writestr(info2.filename, ezip.read(info2.filename)) # ...and write the new unencrypted ZIP bytes stream into the new knxproj file enczip_buffer.seek(0) wzip.writestr(info, enczip_buffer.read()) else: # all other files are just moved over to the new knxproj file wzip.writestr(info, zip.read(info.filename))
Kommentar