summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjosef <josef.gson@gmail.com>2015-12-08 09:36:50 +0100
committerjosef <josef.gson@gmail.com>2015-12-08 09:36:50 +0100
commit1707bbafaa6de30ddf19e94d5bc983ad0b3c7d5a (patch)
tree74899d1923dae04907750ad8a3e30fd1cf5fd5fb
parent1afee9c20c13ff5f317334d6649e84f4240d1926 (diff)
testing emailing
-rwxr-xr-xmonitor/josef_experimental.py37
-rwxr-xr-xmonitor/josef_monitor.py5
-rw-r--r--monitor/monitor_conf.py7
3 files changed, 42 insertions, 7 deletions
diff --git a/monitor/josef_experimental.py b/monitor/josef_experimental.py
index 49c9e09..c9a94e2 100755
--- a/monitor/josef_experimental.py
+++ b/monitor/josef_experimental.py
@@ -169,9 +169,21 @@ def parse_entry(e, idx, log):
+from subprocess import call
+def email(s):
+ for addr in EMAIL_ADDR:
+ command = 'echo "' + s + '" | mail -s "' + EMAIL_SUBJECT + '" ' + addr
+ command = 'echo "message content" | mail -s "' + EMAIL_SUBJECT + '" josef@nordu.net'
+ os.system("bash -c '" + command + "'")
+
+
+
if __name__ == '__main__':
- # prompt_confirm("you are about to remove file")
+ # Test email
+ if True:
+ email("this is an automated test")
+
# Find let's encrypt certs
if False:
@@ -204,7 +216,7 @@ if __name__ == '__main__':
print parse_entry(res,0,log)
# Data gathering for Niklas
- if True:
+ if False:
logs = [CTLOGS[9]] #,CTLOGS[4],CTLOGS[7],CTLOGS[8],CTLOGS[9]]
for log in logs:
filename = log["name"] + "_content.txt"
@@ -233,9 +245,24 @@ if __name__ == '__main__':
idx += len(entries)
-
-
-
+ # Test consistency
+ if False:
+ url = "https://ct.googleapis.com/aviator/"
+ sth1 = json.loads('{"sth": {"timestamp": 1447820379698, "sha256_root_hash": "adJNwPSYP0XOadNQEVF1nZSVZ+ojN9ORPXEdjRMhC8U=", "tree_size": 9867417, "tree_head_signature": "BAMARzBFAiEAwa1SAOMb5k/QQTDQvTPqDkGi43esqg04Em1MHJ6tpckCIBedSUATxgSB3AfIxq/UlP5KtlfuaMGRZYcbUIF0UWyC"}}')["sth"]
+ sth2 = json.loads('{"sth": {"tree_size":10068846,"timestamp":1448889471701,"sha256_root_hash":"1L+e36K1yiynAgaWG+olJ2mEmv2bEyZCzY7YYmJfFas=","tree_head_signature":"BAMASDBGAiEArW7hREfWjArGlUohSIMZvaHnm+jsD0NTCZmAoFYBFYMCIQCEtnV/iX7oDqMb2vr0eP3Ex8Q65rncqg5SGw0z7cefBA=="}}')["sth"]
+
+ # url = "https://gaol.ct.nordu.net/open/"
+ # sth2 = json.loads('{"sth": {"timestamp":1448893523957,"sha256_root_hash":"APf+TzOLNooNAF0Ka59C9n+dLRccMKZ/S5TNKULuolM=","tree_size":5,"tree_head_signature":"BAMARjBEAiAmmxUE3xC1HePGEZvUaubi0WlzwhW+SiTu5hvvxquLhQIgAoRms8ogotonyuoFHZaxWxJMkh9d9l+ZsJ/Jee2VTTo="}}')["sth"]
+ # sth1 = json.loads('{"sth": {"timestamp":1448639930117,"sha256_root_hash":"FliDqU/S5o+qMPS42nwYy9b1/kKEldeedad/5vDl+UA=","tree_size":2,"tree_head_signature":"BAMARzBFAiBEOSbEdnzBGeUV+AGzJUs/ekf5Sq/SRbrxxiDKN23yNAIhAOTrwhYFHg3a6iLrGoz0QoIjOW8PckRJ/1oayj3993Cl"}}')["sth"]
+
+ cons = get_consistency_proof(url, sth1["tree_size"], sth2["tree_size"])
+ decoded_consistency_proof = []
+ for item in cons:
+ decoded_consistency_proof.append(base64.b64decode(item))
+ res = verify_consistency_proof(decoded_consistency_proof, sth1["tree_size"], sth2["tree_size"], base64.b64decode(sth1["sha256_root_hash"]))
+ print sth1["sha256_root_hash"], sth2["sha256_root_hash"]
+ # print res
+ print base64.b64encode(res[0]), base64.b64encode(res[1])
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py
index 2a33ef0..e6d8962 100755
--- a/monitor/josef_monitor.py
+++ b/monitor/josef_monitor.py
@@ -294,8 +294,9 @@ class ctlog:
decoded_consistency_proof = []
for item in consistency_proof:
decoded_consistency_proof.append(base64.b64decode(item))
- res = verify_consistency_proof(decoded_consistency_proof, old["tree_size"], new["tree_size"], old["sha256_root_hash"])
-
+ # res = verify_consistency_proof(decoded_consistency_proof, old["tree_size"], new["tree_size"], old["sha256_root_hash"])
+ res = verify_consistency_proof(decoded_consistency_proof, old["tree_size"], new["tree_size"], base64.b64decode(old["sha256_root_hash"]))
+
if old["sha256_root_hash"] != str(base64.b64encode(res[0])):
self.log(ERROR_STR + "Verification of consistency for old hash failed! Old:" \
+ str(old) + " New:" + str(new) + " Proof:" + str(consistency_proof))
diff --git a/monitor/monitor_conf.py b/monitor/monitor_conf.py
index aed6f8b..f5c5f2d 100644
--- a/monitor/monitor_conf.py
+++ b/monitor/monitor_conf.py
@@ -35,6 +35,13 @@ MONITORED_ISSUERS = [
# Some strings
ERROR_STR = "ERROR: "
+EMAIL_SUBJECT = "CT TEST"
+
+# Email addresses for error messages
+EMAIL_ADDR = [
+# "josef@nordu.net",
+"josef.gson@gmail.com"
+]
# CT logs and associated keys
CTLOGS = [