HEX
Server: Apache/2.4.63 (Unix)
System: Linux Synopilou92 4.4.302+ #72806 SMP Mon Jul 21 23:16:00 CST 2025 x86_64
User: pilou92 (1026)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /volume1/@appstore/HyperBackup/bin/backupconf.py
#!/usr/bin/env python
import sys
import json
import re
from collections import OrderedDict

conf_file = "/var/packages/HyperBackup/etc/synobackup.conf"

sensitive_key = ['remote_pass', 'remote_secret', 'remote_access_token', 'remote_refresh_token']

with open(conf_file) as conf:
    session = None
    total_dict = OrderedDict()
    sess_dict = OrderedDict()
    for line in conf.readlines():
        line = line.rstrip()
        if re.match('\[.*\]', line):
            if session:
                total_dict[session] = sess_dict.copy()
                sess_dict.clear()
            session = line.strip('[]')
        else:
            try:
                key, value = line.split('=', 1)
            except ValueError:
                continue
            if key and value and key not in sensitive_key:
                sess_dict[key] = json.loads(value)
    if session:
        total_dict[session] = sess_dict.copy()
    print json.dumps(total_dict)