This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This solution contains two options for reading the records for updating: | |
// 1) file-mode: reading all records from external file | |
// 2) parameter-mode: reading all records from url parameter 'hosts' | |
// It is possible to use both option simultaneous. | |
// Fritz!Box update URL using hosts from external file: https://example.com/upd.php?zoneId={zoneId}&key=<pass>&file={filename}&ip=<ipaddr> | |
// If you want to read your records from a file, specify the file name as parameter. | |
// Therefore the file should be in the same directory as this php file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import hmac, base64, struct, hashlib, time | |
import json | |
# 2FA code generation from https://stackoverflow.com/questions/8529265/google-authenticator-implementation-in-python | |
def get_totp_token(secret): | |
key = base64.b32decode(secret, True) | |
msg = struct.pack(">Q", int(time.time())//30) | |
h = hmac.new(key, msg, hashlib.sha1).digest() | |
o = h[19] & 15 |