Пример #1
0
import logging
import sys

from flask import Flask, request, session, render_template, redirect
from markupsafe import escape
from mdf0_config import get_config
from mdf0_util import (get_sql_conn, get_topic_stats, get_topic_id,
                       get_message_info, get_next_message_id,
                       get_first_unseen_message, new_topic, add_reply,
                       set_seen, topic_tree)
from mdf0_user import login, register, get_user_info, create_temp_user
from kill_util import recursive_kill, kill_message, kill_user, unkill_message, unkill_user, get_user_kills, get_message_kills
from secret import get_secret_key

app = Flask(__name__)
app.secret_key = get_secret_key()

config = get_config('/home/gweinberg/projects/mdf0/etc/test.conf')
#logging.basicConfig(format='%(asctime)s %(message)s')
#logging.basicConfig(filename=config.get('logging', 'file'), level=logging.INFO)
conn = get_sql_conn(config)


def obtain_user_info():
    """Get the user_info, creating a new temp user if necessary."""
    user_id = session.get('user_id')
    if user_id:
        try:
            user_id = int(user_id)
        except Exception:
            user_id = None
from hashlib import sha256
import random
from secret import get_secret_key

SECRET_KEY = get_secret_key()


def make_password(plaintext, app_name):
    salt = get_hexdigest(SECRET_KEY, app_name)[:20]
    hsh = get_hexdigest(salt, plaintext)
    return ''.join((salt, hsh))


def get_hexdigest(salt, plaintext):
    return sha256((salt + plaintext).encode('utf-8')).hexdigest()


def password(plaintext, app_name, length):
    raw_hex = make_password(plaintext, app_name)
    ALPHABET = ('abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTYVWXYZ',
                '0123456789', '(,._-*~"<>/|!@#$%^&)+=')

    num = int(raw_hex, 16)

    chars = []

    while len(chars) < length:
        n = random.randint(0, len(ALPHABET) - 1)
        alpha = ALPHABET[n]
        n = random.randint(0, len(alpha) - 1)
        chars.append(alpha[n])
Пример #3
0
from getpass import getpass

from secret import get_secret_key
from menu import menu, create, find, find_accounts
# menu
# 1. create new password for a site
# 2. find password for a site
# 3. Find all sites connected to an email

secret = get_secret_key()

passw = getpass(
    prompt=
    'Please provide the master password to start using kallemanager3000: ')

if passw == secret:
    print('You\'re in')

else:
    print('no luck')
    exit()

choice = menu()
while choice != 'Q':
    if choice == '1':
        create()
    if choice == '2':
        find_accounts()
    if choice == '3':
        find()
    else: