commit e7f9bc9f5652e46371f126070e27d804b7e01fce
parent ec8c054d5887498c14d66caa2f01e454e3ba61bb
Author: parazyd <parazyd@dyne.org>
Date: Fri, 8 Dec 2017 03:36:18 +0100
Remove obsolete Python code
Diffstat:
3 files changed, 0 insertions(+), 97 deletions(-)
diff --git a/python/creds.py b/python/creds.py
@@ -1 +0,0 @@
-tor_auth_pass = 'foobar'
diff --git a/python/crypto.py b/python/crypto.py
@@ -1,27 +0,0 @@
-# See LICENSE file for copyright and license details
-
-from base64 import b64decode, b64encode
-from Crypto.PublicKey import RSA
-from Crypto.Signature import PKCS1_v1_5
-from Crypto.Hash import SHA512
-
-
-def make_sign(privkey, message):
- rsakey = RSA.importKey(privkey)
- signer = PKCS1_v1_5.new(rsakey)
- digest = SHA512.new()
-
- digest.update(message.encode('utf-8'))
- sign = signer.sign(digest)
- return b64encode(sign) # .decode('utf-8')
-
-
-def verify_sign(pubkey, message, signature):
- rsakey = RSA.importKey(pubkey)
- signer = PKCS1_v1_5.new(rsakey)
- digest = SHA512.new()
-
- digest.update(message.encode('utf-8'))
- if signer.verify(digest, b64decode(signature)):
- return True
- return False
diff --git a/python/dir.py b/python/dir.py
@@ -1,69 +0,0 @@
-#!/usr/bin/env python3
-# See LICENSE file for copyright and license details.
-
-from os.path import isfile
-from time import time
-import simplejson as json
-from flask import Flask, request
-from stem.control import Controller
-
-from creds import tor_auth_pass
-from crypto import verify_sign
-
-
-APP = Flask(__name__)
-
-
-def parseapi(query):
- mtype = query.get('type')
- maddr = query.get('address')
- mmesg = query.get('message')
- msign = query.get('signature')
-
- nodedata = {
- 'type': mtype,
- 'address': maddr,
- 'message': mmesg,
- 'signature': msign,
- 'firstseen': int(time()),
- 'lastseen': int(time()),
- }
-
- # It's already there.
- for i in dirdata:
- if i['address'] == maddr:
- return False
-
- with Controller.from_port() as controller:
- controller.authenticate(password=tor_auth_pass)
- desc = controller.get_hidden_service_descriptor(maddr)
- pkey = desc.permanent_key
- nodedata['publickey'] = pkey
-
- if verify_sign(pkey, mmesg, msign):
- dirdata.append(nodedata)
- with open('decode-dir.json', 'w') as dirf:
- dirf.write(json.dumps(dirdata, indent=2))
-
-
-@APP.route('/')
-def main():
- return 'Main page\n'
-
-
-@APP.route('/post', methods=['POST'])
-def post():
- if request.get_json():
- for i in request.get_json():
- parseapi(i)
- print(i)
- return ''
-
-
-if __name__ == '__main__':
- if not isfile('decode-dir.json'):
- with open('decode-dir.json', 'w') as f:
- f.write('[]')
- with open('decode-dir.json', 'r') as f:
- dirdata = json.loads(f.read())
- APP.run(host='127.0.0.1', port=49371, threaded=True, debug=True)