HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //var/packages/HyperBackup/target/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)