Example #1
0
def keyring():
    
    keym = KeyManager()
    
    keys = keym.export_keyring()

    response = make_response(keys)
    response.headers['Content-Type'] = 'application/pkix-cert'

    return response
Example #2
0
def keyring():

    keym = KeyManager()

    keys = keym.export_keyring()

    response = make_response(keys)
    response.headers['Content-Type'] = 'application/pkix-cert'

    return response
Example #3
0
def pks_add():
    if 'keytext' not in request.form or request.form['keytext'] is None:
        return abort(500)

    key = str(request.form['keytext'])
    keym = KeyManager()
    try:
        added = keym.add(key)
        return render_template("add_key.html", added=added), 200
    except PgpKeyError:
        return abort(400)
Example #4
0
def pks_add():
    if 'keytext' not in request.form or request.form['keytext'] is None:
        return abort(500)

    key = str(request.form['keytext'])
    keym = KeyManager()
    try:
        added = keym.add(key)
        return render_template("add_key.html", added = added), 200
    except PgpKeyError:
        return abort(400)
Example #5
0
def pks_lookup():
    op = ''

    if 'op' not in request.args:
        return abort(500)
    else:
        op = request.args.get('op')

    search = None
    if 'search' not in request.args:
        return abort(500)
    search = request.args.get('search')

    options = None
    if 'options' in request.args:
        options = request.args.get('options')

    try:
        search = str(search)
    except UnicodeError:
        return abort(400)

    fingerprint = request.args.get(
        'fingerprint') == 'on' if 'fingerprint' in request.args else False
    exact = request.args.get(
        'exact') == 'on' if 'exact' in request.args else False
    m = KeyManager()
    if op == 'index':
        return lookup_index(m, search, fingerprint, options)
    elif op == 'vindex':
        return lookup_vindex(m, search, fingerprint, options)
    elif op == 'get':
        return lookup_get(m, search, options)
    else:
        return abort(500)
Example #6
0
    def __init__(self):
        is_debug = False
        for arg in sys.argv:
            if arg == '-d':
                is_debug = True
        with open("config", 'r', encoding='utf-8') as config:
            self.name = config.read().split('\n')[3][5:]
            if len(self.name) == 0:
                raise Exception('name is zero word')
        logger = Logger(is_debug, './logs/')
        self.log = logger.log
        try:
            os.remove('ERROR.txt')
        except:
            pass
        shits = list(self.base_cmds.keys())
        for shit in shits:
            self.cmds[f"{self.name} {shit}"] = self.base_cmds[shit]

        self.log(f'App {self.name} is launching')
        self.keys = KeyManager('./../../resources/data.json', logger.log)
        self.api = ApiManager(self.keys, logger.log)
        self.sender = Sender('./../../resources/', self.keys, self.api,
                             logger.log)
        self.log('Base services are loaded')
        self.user_id = self.keys.admin_id

        BOT_PORT = self.keys.bot_port
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.bot_port = BOT_PORT
        while True:
            counter = 0
            try:
                counter += 1
                app_port = random.randint(5000, 5999)
                self.sock.bind(('127.0.0.1', app_port))
                break
            except OSError:
                if counter > 1000:
                    self.log(
                        '!!ERROR!!\nMore than 1000 attempts to bind socket have been missed'
                    )
                    os._exit(1)

        self.app_port = app_port
        self.log(f'Binded {str(self.name)} with port = {app_port}')
        with open('config', 'w', encoding='utf-8') as config:
            config.write(f"""port={self.app_port}
commands={str({key:self.cmds[key].__name__ for key in self.cmds})}
prefixes={str({key:self.prefixes[key].__name__ for key in self.prefixes})}
name={self.name}
launch_time={time.time()}
date={time.ctime()}""")

        self.thread = None
Example #7
0
    def __init_base_services(self, is_debug):
        logger = Logger(is_debug, './../logs/')
        self.log = logger.log
        self.log('Program is launching')
        self.keys = KeyManager('./../resources/data.json', logger.log)
        self.api = ApiManager(self.keys, logger.log)
        self.sender = Sender('./../resources/', self.keys, self.api,
                             logger.log)
        self.start_time = datetime.datetime.utcnow()
        self.BOT_PORT = self.keys.bot_port

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.bind(('localhost', self.BOT_PORT))
        self.__thread_listening_port = threading.Thread(
            target=self.__listen_port, daemon=True)
        self.__is_listen_port_sleeping = False
        self.__is_listen_port_listening = False
        self.__go_on_sleep = False
        self.__thread_listening_port.start()

        self.log('Base services are loaded')
Example #8
0
"""


import datetime
import asyncio
import logging
import traceback
import googlemaps
import time
import unicodedata
import dateutil.parser as dt

from log import log, perf
from keys import KeyManager

km = KeyManager()

def collectData(user_data):
    all_data = {}
    log("Starting Collection")
    try:
        event_loop = asyncio.get_event_loop()
        place_data = event_loop.run_until_complete(collectUserData(user_data))
        distance_data = event_loop.run_until_complete(collectMapData(place_data))

        all_data["user_data"] = user_data
        all_data["place_data"] = place_data
        all_data["distance_data"] = distance_data
    except Exception as e:
        log(traceback.format_exc())
    finally:
Example #9
0
host = sys.argv[1]
port = sys.argv[2] if len(sys.argv) > 2 else '11371'

sys.stderr.write("host: %s\n" % host)
sys.stderr.write("port: %s\n" % port)

total = 0
for d in dom:
    response = requests.get(
        "http://%s:%s/pks/lookup?search=%s&options=mr&op=index" %
        (host, port, d))

    if response.status_code != 200:
        continue

    keym = KeyManager()

    sub_total = 0
    for key_id in [
            id_re.match(x).group(1) for x in response.text.split('\n')
            if id_re.match(x) is not None
    ]:
        cert_response = requests.get(
            "http://%s:%s/pks/lookup?search=0x%s&op=get" %
            (host, port, key_id))

        if cert_response.status_code != 200:
            continue

        cert_response_text = cert_response.text.split("\n")
Example #10
0
    sys.exit()

host = sys.argv[1]
port = sys.argv[2] if len(sys.argv) > 2 else "11371"

sys.stderr.write("host: %s\n" % host)
sys.stderr.write("port: %s\n" % port)

total = 0
for d in dom:
    response = requests.get("http://%s:%s/pks/lookup?search=%s&options=mr&op=index" % (host, port, d))

    if response.status_code != 200:
        continue

    keym = KeyManager()

    sub_total = 0
    for key_id in [id_re.match(x).group(1) for x in response.text.split("\n") if id_re.match(x) is not None]:
        cert_response = requests.get("http://%s:%s/pks/lookup?search=0x%s&op=get" % (host, port, key_id))

        if cert_response.status_code != 200:
            continue

        cert_response_text = cert_response.text.split("\n")

        cert_start = [
            x
            for x in range(0, len(cert_response_text))
            if cert_response_text[x].startswith("-----BEGIN PGP PUBLIC KEY BLOCK-----")
        ][0]