gitignore hinzugefügt und inwx-project nachgereicht
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
Executable
+78
@@ -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()
|
||||||
Reference in New Issue
Block a user