def _do_edit(system, form): edit = SystemEdit(system=system, date=datetime.datetime.now(), confirmed=False, name=form.cleaned_data['name'], owner_email=form.cleaned_data['owner_email'], operating_system=form.cleaned_data['operating_system'], graphics=form.cleaned_data['graphics'], processor=form.cleaned_data['processor'], notes=form.cleaned_data['notes'], secret_key=util.random_key()) edit.save() confirm_link = "confirm_edit?edit=%d&auth=%s" % (edit.id, edit.make_auth("confirm")) util.send_email( 'mails/confirm_edit.txt', { 'settings': settings, 'system': system, 'edit': edit, 'confirm_link': confirm_link }, system.owner_email) return edit
def test_Set02_Challenge12(self): """ Byte-at-a-time ECB decryption (Simple) """ unknown_string = binascii.a2b_base64( b'''Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg YnkK''') key = util.random_key(16) aes_128_ecb = lambda s: util.aes_128_ecb(s, key) block_size = util.detect_block_size(aes_128_ecb) is_ecb = util.confirm_ECB(aes_128_ecb, block_size) res = util.find_every_byte(aes_128_ecb, block_size, unknown_string) self.assertTrue(block_size == 16 and is_ecb and res == unknown_string)
def _do_register(form): edit = SystemEdit(date=datetime.datetime.now(), confirmed=False, name=form.cleaned_data['name'], owner_email=form.cleaned_data['owner_email'], operating_system=form.cleaned_data['operating_system'], graphics=form.cleaned_data['graphics'], processor=form.cleaned_data['processor'], notes=form.cleaned_data['notes'], secret_key=util.random_key()) edit.save() activation_link = "activate?edit=%d&auth=%s" % (edit.id, edit.make_auth("activate")) util.send_email('mails/activate.txt', { 'settings': settings, 'system': edit, 'activation_link': activation_link }, edit.owner_email) return edit
def test_Set2_Challenge14(self): """Byte-at-a-time ECB decryption (Harder)""" random_bytes = os.urandom(random.randint(0, 10)) unknown_string = binascii.a2b_base64( b'''Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg YnkK''') target_bytes = b'my plain text' _input = random_bytes + unknown_string + target_bytes key = util.random_key(16) aes_128_ecb = lambda s: util.aes_128_ecb(s, key) block_size = util.detect_block_size(aes_128_ecb) result = util.find_every_byte(aes_128_ecb, block_size, _input) self.assertTrue(target_bytes in result)
def _do_edit(system, form): edit = SystemEdit(system=system, date=datetime.datetime.now(), confirmed=False, name=form.cleaned_data['name'], owner_email=form.cleaned_data['owner_email'], operating_system=form.cleaned_data['operating_system'], graphics=form.cleaned_data['graphics'], processor=form.cleaned_data['processor'], notes=form.cleaned_data['notes'], secret_key=util.random_key()) edit.save() confirm_link = "confirm_edit?edit=%d&auth=%s" % (edit.id, edit.make_auth("confirm")) util.send_email('mails/confirm_edit.txt', { 'settings': settings, 'system': system, 'edit': edit, 'confirm_link': confirm_link }, system.owner_email) return edit
from flask import Flask, render_template, url_for, request, jsonify, escape, session, redirect, make_response from util import json_response, hash_password, verify_password from flask_cors import CORS import data_handler import util app = Flask(__name__) # CORS(app) # cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) app.secret_key = util.random_key() @app.route("/get-boards") @json_response def get_boards(): """ All the boards """ return data_handler.get_boards() # @app.route("/get-cards/<int:board_id>") # @json_response # def get_cards_for_board(board_id: int): # """ # All cards that belongs to a board # :param board_id: id of the parent board # """ # return data_handler.get_cards_for_board(board_id) #
import os, sys, json _PATH = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) sys.path.append(_PATH) from web3 import Web3 from util import random_key, create_keyfile_json # w3 = Web3(Web3.IPCProvider("./blockchain/geth.ipc")) w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545')) account_list = [] password = ["coinbase", "n1", "n2"] for i in range(len(password)): privKey = random_key() byte_privKey = bytearray.fromhex(privKey) keyFile = create_keyfile_json(byte_privKey, password[i].encode()) with open(_PATH + "/keyFile/" + password[i] + ".json", 'w', encoding='utf-8') as make_file: json.dump(keyFile, make_file, indent="\t") print(password[i] + " : ") print("privKey : ", privKey) print("address : ", '0x' + keyFile['address']) print("checksum address : ", Web3.toChecksumAddress('0x' + keyFile['address'])) print("password : ", password[i]) print()