Exemple #1
0
def main():
	generated_key = key_exchange()
	key = format_key(generated_key)
	enc_pass = encrypt(password, key)
	send(enc_pass)
	enc = read()
	flag = decrypt(enc, key)
Exemple #2
0
def user1():
    with sock(HOST, PORT) as s:
        force_login(s, 'a')
        sleep(0.5)
        send(s, "challenge", {'other_username': '******'})
        sleep(0.5) # wait to accept
        recv(s) # recieve begin_match
def key_exchange():
    secret = randint(2**1000, 2**1001)
    gx = int_from_bytes(read())
    gy = pow(dh_g, secret, dh_mod)
    send(int_to_bytes(gy))
    key = pow(gx, secret, dh_mod)
    return key
Exemple #4
0
def send():
    data = request.json or request.form
    c = clients[data['token']]
    msg = data['msg']
    to = data['to']
    lib.send(c, to, msg)
    data = {'status': 'ok'}
    return jsonify(data)
Exemple #5
0
 def get(self, token):
     if not token.lower().startswith('p_'):
         raise tornado.web.HTTPError(404)
     obj = lib.lookup_token(token)
     if not obj or not obj.active:
         raise tornado.web.HTTPError(404)
     
     msg = self.render_string(obj.format, post_json=None)
     lib.send(obj.jid, msg)
Exemple #6
0
 def post(self, token):
     if not token.lower().startswith('p_'):
         raise tornado.web.HTTPError(404,log_message='Not a post token')
     obj = lib.lookup_token(token)
     if not obj or not obj.active:
         raise tornado.web.HTTPError(404,log_message='Not active or instantiated token')
     
     msg = self.render_string(obj.format, json_decode = tornado.escape.json_decode)
     lib.send(obj.jid, msg)
def main():
    generated_key = key_exchange()
    key = format_key(generated_key)
    enc_pass = read()
    dec_pass = decrypt(enc_pass, key)
    if dec_pass != password:
        print("wrong password, terminating")
        return
    enc = encrypt(flag, key)
    send(enc)
Exemple #8
0
    def post(self, token):
        obj = lib.lookup_token(token, self.current_user)
        if not obj:
            raise tornado.web.HTTPError(404)
        if self.get_argument('action.update_alias', None):
            alias = self.get_argument('alias')
            if obj.alias != alias and alias:
                obj.alias = alias
                obj.put()
                lib.send(obj, '/alias %s' % alias)

        elif self.get_argument('action.partychat_migration', None):
            obj.jid = obj.jid.replace('at.partych.at', 'im.partych.at')
            obj.put()
        
        elif self.get_argument('action.new_post_hook', None):
            t = model.PostHook(
                token=lib.get_new_token('post'),
                jid=obj
            )
            t.put()
        elif self.get_argument('action.update_post_hook', None):
            hook_token = self.get_argument('token')
            if hook_token.lower().startswith('p_'):
                t = lib.lookup_token(hook_token, self.current_user)
                if t:
                    t.format = self.get_argument('format')
                    t.put()
        elif self.get_argument('action.new_receive_hook', None):
            t = model.ReceiveHook(
                token=lib.get_new_token('receive'),
                jid=obj)
            t.put()
        elif self.get_argument('action.update_receive_hook', None):
            hook_token = self.get_argument('token')
            if hook_token.lower().startswith('r_'):
                t = lib.lookup_token(hook_token, self.current_user)
                if t:
                    t.endpoint = self.get_argument('endpoint')
                    t.command = self.get_argument('command') or '*'
                    t.put()
        elif self.get_argument('action.activate', None):
            hook_token = self.get_argument('action.activate')
            t = lib.lookup_token(hook_token, self.current_user)
            if t:
                t.active = True
                t.put()
        elif self.get_argument('action.deactivate', None):
            hook_token = self.get_argument('action.deactivate')
            t = lib.lookup_token(hook_token, self.current_user)
            if t:
                t.active = False
                t.put()
        self.redirect('/edit/' + obj.token)
def user1():
    with sock(HOST, PORT) as s:
        force_login(s, 'a')
        sleep(0.2) # wait for the other user to conect
        send(s, "challenge", {'other_username': '******'})
        recv(s) # recive fail response
        send(s, "challenge", {'other_username': '******'})
        recv(s) # challenge refused
        send(s, "challenge", {'other_username': '******'})
        recv(s) # match_begin
Exemple #10
0
def user2():
    with sock(HOST, PORT) as s:
        force_login(s, 'b')
        r = recv(s) # recieve challenge

        send(s, 'accept_challenge', {'id': 10000}) # accept fake challenge
        recv(s) # recive fail response

        send(s, 'refuse_challenge', {'id': r[1]['challenge_id']}) # refuse real challenge

        r = recv(s) # recieve challenge
        send(s, 'accept_challenge', {'id': r[1]['challenge_id']}) # refuse real challenge

        recv(s) # match_begin
Exemple #11
0
import lib as protocol
#import random

if __name__ == "__main__":
    n = 22
    g = 42
    # x = random.random()
    # initKey = (g**x) % n
    proto_handler = protocol.socket()
    protocol.connect_to(proto_handler, 'localhost', 50)
    value = protocol.receive(proto_handler)
    # computedKey = (float(protocol.receive(proto_handler))**x) % n
    print(value)

    value = 'Message №2'
    protocol.send(proto_handler, value)
    val_new = protocol.receive(proto_handler)
    protocol.send(proto_handler, val_new + 'Last message')
    print(val_new)
Exemple #12
0
def user2():
    with sock(HOST, PORT) as s:
        force_login(s, 'b')
        r = recv(s) # recieve challenge
        send(s, 'accept_challenge', {'id': r[1]['challenge_id']})
        recv(s) # recieve begin_match
Exemple #13
0
import lib as protocol

if __name__ == "__main__":
    n = 22
    g = 42
    # x = random.random()
    # initKey = (g**x) % n

    server_handler = protocol.server_socket("localhost", 50)

    # listening for connections
    protocol.receive(server_handler)
    # computedKey = (float(protocol.receive(proto_handler))**x) % n

    value = 'Message №1'
    print(value)

    protocol.send(server_handler, value)
    value = protocol.receive(server_handler)
    print(value)

    value = 'Message №3'
    protocol.send(server_handler, value)
    val_new = protocol.receive(server_handler)
    print(val_new)