Esempio n. 1
0
def get_cert_validity():
    #	cert_exp=tools.runCmd("openssl x509 -in /etc/letsencrypt/live/dom.pbth.de/cert.pem -noout -dates | grep 'notAfter'")
    cert_exp = tools.runCmd(
        "openssl s_client -connect localhost:64738 -showcerts </dev/null 2>/dev/null|openssl x509 -dates -noout | grep 'notAfter' | cut -c10- "
    )
    start = cert_exp.find("=") + 1
    return cert_exp[start:]  #cut first part
Esempio n. 2
0
def read_Online_Users():
    global event_counter
    event_counter = 0  #reset event counter
    online_users = {}

    server_start_date = tools.runCmd(
        "sqlite3 /var/lib/mumble-server/mumble-server.sqlite 'SELECT msgtime FROM slog WHERE msg LIKE \"%Server listening on%\" ORDER BY msgtime desc LIMIT 1'"
    )

    if server_start_date == "":
        return "sql_no_time_error"

    query = "sqlite3 /var/lib/mumble-server/mumble-server.sqlite 'SELECT * FROM slog  WHERE msgtime >=Datetime(\"" + server_start_date + "\")' | grep 'Authenticated\\|Connection\\|Rejected'"

    p = subprocess.Popen(query,
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)

    for line in p.stdout.readlines():

        p.wait()
        sline = line.decode("utf-8")  # byte to str

        start = sline.find(":") + 1
        stop = sline.find(">")
        if start < 0 or stop < 0:
            continue

        substring = sline[start:stop]
        stop = substring.rfind('(')
        user = substring[:stop]

        last_event = sline[sline.rfind('|') + 1:].replace("\n", "")

        if time.localtime().tm_isdst:  # summertime :-)
            last_event = plus_x_hour(last_event, 2)
        else:
            last_event = plus_x_hour(last_event, 1)

        if user != "" and user != "PbtH_bot":  #user had a disconnect bevore authentication or is a bot
            online_users = update_user(online_users, user, last_event)
            event_counter = event_counter + 1  #update global event counter

    return online_users
Esempio n. 3
0
def getIP():
    return tools.runCmd(
        'ifconfig wlan0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')