Exemplo n.º 1
0
def test_cert(tPass):
    sendQ.put([RM.AUTHENTICATE_USER,"*****@*****.**","12345"])
    if tPass=='True':
        cryptomot.create_self_signed_cert('test',"*****@*****.**")
        cert = open('ctest/motmot.crt').read()
        sendQ.put([RM.SIGN_CERT_REQUEST, cert])
    else:
        sendQ.put([RM.SIGN_CERT_REQUEST, "*****@*****.**"])
        sendQ.put([RM.SIGN_CERT_REQUEST, ";insert into users(userName,password) values ('owned','owned'); --"])
        sendQ.put([RM.SIGN_CERT_REQUEST, ])
        cert = open('cert/motmot.crt').read()
        sendQ.put([RM.SIGN_CERT_REQUEST, cert])
Exemplo n.º 2
0
    def __reader__(self):
        unpacker = msgpack.Unpacker()
        fd = self.socket.fileno()
        while True:
            gevent.socket.wait_read(fd)
            buf = self.socket.recv(4096)
            if not buf:
                return Connection.dead.push(self)
            unpacker.feed(buf)
            for val in unpacker:
                self.__recvqueue.put(val)

    def __writer__(self):
        packer = msgpack.Packer()
        fd = self.socket.fileno()
        for msg in self.__sendqueue:
            buf = packer.pack(msg)
            gevent.socket.wait_write(fd)
            self.socket.sendall(buf)

if __name__ == '__main__':
    cryptomot.create_self_signed_cert('cert', DOMAIN_NAME)
    gevent.spawn(rpc.new_connection_watcher, Connection.new)

    server = gevent.server.StreamServer(('127.0.0.1', 8888),
            Connection,
            keyfile='cert/motmot.key',
            certfile='cert/motmot.crt')
    server.serve_forever()