From 5372f8b07f08a629d3a8364e9c81fe29803da1f9 Mon Sep 17 00:00:00 2001 From: Christian Maier Date: Fri, 24 Apr 2026 17:00:52 +0200 Subject: [PATCH] =?UTF-8?q?gitignore=20hinzugef=C3=BCgt=20und=20inwx-proje?= =?UTF-8?q?ct=20nachgereicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + inwx-project/inwx_domain_list.py | 78 ++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100755 inwx-project/inwx_domain_list.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/inwx-project/inwx_domain_list.py b/inwx-project/inwx_domain_list.py new file mode 100755 index 0000000..7bd860e --- /dev/null +++ b/inwx-project/inwx_domain_list.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +import sys +import subprocess +from inwx.domrobot import ApiClient + +# --- Konfiguration --- +KP_DB_PATH = "/Users/maier/Nextcloud/Keepass/Keepass202503.kdbx" +KP_ENTRY_NAME = "inwx" +DOMAIN = "ma151.de" + +def get_inwx_data_from_keepass(): + """ + Fragt den gesamten Eintrag aus KeePassXC ab und parst die Felder. + Fragt das Master-Passwort nur einmal ab. + """ + try: + # Führt den Befehl einmal aus, um alle Daten zu erhalten + cmd = ["keepassxc-cli", "show", KP_DB_PATH, KP_ENTRY_NAME] + # Wir fangen stdout ab. Die Passwort-Abfrage erfolgt über stderr im Terminal. + result = subprocess.check_output(cmd, text=True) + + data = {} + for line in result.splitlines(): + if ":" in line: + key, value = line.split(":", 1) + data[key.strip()] = value.strip() + + return { + "user": data.get("UserName"), + "pass": data.get("Password"), + "totp": data.get("TOTP") + } + except subprocess.CalledProcessError: + return None + except Exception as e: + print(f"Fehler beim Parsen: {e}") + return None + +def main(): + print(f"--- KeePassXC Zugriff für {KP_ENTRY_NAME} ---") + + # Alle Daten in einem Rutsch holen + kp_data = get_inwx_data_from_keepass() + + if not kp_data or not all([kp_data["user"], kp_data["pass"], kp_data["totp"]]): + print("Fehler: Konnte Daten nicht vollständig aus KeePassXC lesen.") + print("Stelle sicher, dass Benutzername, Passwort und TOTP im Eintrag vorhanden sind.") + sys.exit(1) + + print("Daten geladen. Initialisiere INWX API...") + + # API Client initialisieren + api_client = ApiClient(api_url='https://api.inwx.de/jsonrpc/', lang='de') + + # Login mit den extrahierten Daten + login_res = api_client.login(kp_data["user"], kp_data["pass"], tan=kp_data["totp"]) + + if login_res['code'] != 1000: + print(f"Login fehlgeschlagen: {login_res['msg']} (Code: {login_res['code']})") + sys.exit(1) + + # Abfrage der Records + res = api_client.call('nameserver.info', {'domain': DOMAIN}) + + if res['code'] == 1000: + records = res['resData']['record'] + print(f"\nRecords für {DOMAIN}:") + print(f"{'TYP':<8} {'NAME':<35} {'CONTENT'}") + print("-" * 70) + for rec in records: + print(f"{rec['type']:<8} {rec['name']:<35} {rec['content']}") + else: + print(f"API Fehler: {res['msg']}") + + api_client.logout() + +if __name__ == "__main__": + main()