Пример #1
0
    def handlePutFile(self, line):
        print "Encrypting file..."
        s = line.split()
        file = open(s[2], 'r')
        enc_file = open("enc_fileout", 'w')
        crd = self.client_id.encryptFileSym(file, enc_file)

        args = ("putfile", str(self.ccid), os.path.basename(s[2]))
        salt = self.processCookie("/files")

        dataq = []
        dataq.append(self.client_id.genHashArgs(args, salt))
        dataq.append(self.client_id.encryptData(crd[0],
                                                self.client_id.pub_key))
        dataq.append(self.client_id.encryptData(crd[1]))
        agent = CookieAgent(Agent(reactor), self.cookie_jar)
        #print crd[1]
        # print "debugging:key, iv putfile"
        # print dataq[1]
        # print len(dataq[1])
        # print dataq[2]
        # print len(dataq[2])
        print "Uploading file..."
        enc_file = open("enc_fileout", 'r')
        body = _FileProducer(enc_file, dataq)
        headers = http_headers.Headers()
        d = agent.request(
            'PUT', 'http://localhost:8000/files/?method=putfile&ccid=' +
            self.ccid + "&name=" + os.path.basename(s[2]), headers, body)
        d.addCallback(self.printPutReply_cb)

        return NOT_DONE_YET
Пример #2
0
            def updateShared_cb(iv):
                print "Updating file..."

                args = ("updateshared", str(self.ccid), os.path.basename(s[3]),
                        s[2])
                salt = self.processCookie("/shares")

                dataq = []
                dataq.append(self.client_id.genHashArgs(args, salt))
                dataq.append(iv)
                # print "debugging:ticket, iv updatefile"
                # print dataq[0]
                # print dataq[1]
                # print len(dataq[1])
                print "Uploading file..."
                agent = CookieAgent(Agent(reactor), self.cookie_jar)
                enc_file = open("enc_fileout", 'r')
                body = _FileProducer(enc_file, dataq)
                headers = http_headers.Headers()
                d = agent.request(
                    'POST',
                    'http://localhost:8000/shares/?method=updateshared&ccid=' +
                    self.ccid + "&name=" + os.path.basename(s[3]) +
                    "&fileid=" + s[2], headers, body)
                d.addCallback(self.printPutReply_cb)

                return NOT_DONE_YET
Пример #3
0
        def putFile_cb(ticket):
            print "Encrypting file..."
            s = line.split()
            file = open(s[2], 'r')
            enc_file = open("enc_fileout", 'w')
            crd = self.client_id.encryptFileSym(file, enc_file)
            agent = Agent(reactor)
            dataq = []
            dataq.append(ticket)
            dataq.append( self.client_id.encryptData(crd[0], self.client_id.pub_key))
            dataq.append( self.client_id.encryptData(crd[1]) )
            #print crd[1]
            # print "debugging:key, iv putfile"
            # print dataq[1]
            # print len(dataq[1])
            # print dataq[2]
            # print len(dataq[2])
            print "Uploading file..."
            enc_file = open("enc_fileout", 'r')
            body = _FileProducer(enc_file ,dataq)
            headers = http_headers.Headers()
            d = agent.request(
                'PUT',
                'http://localhost:8000/files/?method=putfile&ccid='
                + self.ccid + "&name=" + os.path.basename(s[2]),
                headers,
                body)
            d.addCallback(self.printPutReply_cb)

            return NOT_DONE_YET
Пример #4
0
        def updateFile_cb(ticket, iv):
            #data = (key,)
            print "Updating file..."
            s = line.split()
            agent = Agent(reactor)
            dataq = []
            dataq.append(ticket)
            dataq.append( iv )
            # print "debugging:ticket, iv updatefile"
            # print dataq[0]
            # print dataq[1]
            # print len(dataq[1])
            print "Uploading file..."
            enc_file = open("enc_fileout", 'r')
            body = _FileProducer(enc_file ,dataq)
            headers = http_headers.Headers()
            d = agent.request(
                'POST',
                'http://localhost:8000/files/?method=updatefile&ccid='
                + self.ccid + "&name=" + os.path.basename(s[3]) + "&fileid=" + s[2] ,
                headers,
                body)
            d.addCallback(self.printPutReply_cb)

            return NOT_DONE_YET
Пример #5
0
            def updateShared_cb(iv):
                print "Updating file..."

                args = ("updateshared", str(self.ccid), os.path.basename(s[3]), s[2])
                salt = self.processCookie("/shares")

                dataq = []
                dataq.append( self.client_id.genHashArgs(args, salt))
                dataq.append( iv )
                # print "debugging:ticket, iv updatefile"
                # print dataq[0]
                # print dataq[1]
                # print len(dataq[1])
                print "Uploading file..."
                agent = CookieAgent(Agent(reactor), self.cookie_jar)
                enc_file = open("enc_fileout", 'r')
                body = _FileProducer(enc_file ,dataq)
                headers = http_headers.Headers()
                d = agent.request(
                    'POST',
                    'http://localhost:8000/shares/?method=updateshared&ccid='
                    + self.ccid + "&name=" + os.path.basename(s[3]) + "&fileid=" + s[2] ,
                    headers,
                    body)
                d.addCallback(self.printPutReply_cb)

                return NOT_DONE_YET
Пример #6
0
    def handlePutFile(self, line):
        print "Encrypting file..."
        s = line.split()
        file = open(s[2], 'r')
        enc_file = open("enc_fileout", 'w')
        crd = self.client_id.encryptFileSym(file, enc_file)

        args = ("putfile", str(self.ccid), os.path.basename(s[2]))
        salt = self.processCookie("/files")

        dataq = []
        dataq.append( self.client_id.genHashArgs(args, salt))
        dataq.append( self.client_id.encryptData(crd[0], self.client_id.pub_key))
        dataq.append( self.client_id.encryptData(crd[1]) )
        agent = CookieAgent(Agent(reactor), self.cookie_jar)
        #print crd[1]
        # print "debugging:key, iv putfile"
        # print dataq[1]
        # print len(dataq[1])
        # print dataq[2]
        # print len(dataq[2])
        print "Uploading file..."
        enc_file = open("enc_fileout", 'r')
        body = _FileProducer(enc_file ,dataq)
        headers = http_headers.Headers()
        d = agent.request(
            'PUT',
            'http://localhost:8000/files/?method=putfile&ccid='
            + self.ccid + "&name=" + os.path.basename(s[2]),
            headers,
            body)
        d.addCallback(self.printPutReply_cb)

        return NOT_DONE_YET
Пример #7
0
 def startSession_cb((signedNonce, nonceid)):
     agent = CookieAgent(Agent(reactor), self.cookie_jar)
     dataq = []
     dataq.append(signedNonce)
     body = _FileProducer(
         StringIO(self.client_id.encryptData(self.client_id.password)),
         dataq)
     headers = http_headers.Headers()
     d = agent.request(
         'PUT',
         'http://localhost:8000/session/?method=startsession&ccid=' +
         self.ccid + '&nonceid=' + str(nonceid), headers, body)
     d.addCallback(procResponse_cb)
     return NOT_DONE_YET
Пример #8
0
        def updateSharePerm(ticket):
            s = line.split()
            agent = Agent(reactor)
            body = _FileProducer(StringIO(ticket))
            headers = http_headers.Headers()
            d = agent.request(
                'POST',
                'http://localhost:8000/shares/?method=updateshareperm&ccid='
                + self.ccid + "&rccid=" + s[3] + "&fileid=" + s[2] + "&writeable=" + s[4] ,
                headers,
                body)
            d.addCallback(self.printPutReply_cb)

            return NOT_DONE_YET
Пример #9
0
        def startSession_cb((signedNonce, nonceid)):
            agent = CookieAgent(Agent(reactor), self.cookie_jar)
            dataq = []
            dataq.append(signedNonce)
            body = _FileProducer(StringIO(self.client_id.encryptData(self.client_id.password)) ,dataq)
            headers = http_headers.Headers()
	    d = agent.request(
                'PUT',
                'http://localhost:8000/session/?method=startsession&ccid='
                + self.ccid + '&nonceid=' + str(nonceid),
                headers,
                body)
            d.addCallback(procResponse_cb)
            return NOT_DONE_YET
Пример #10
0
                def shareFile_cb(ticket):
                    agent = Agent(reactor)
                    dataq = []
                    dataq.append(ticket)
                    dataq.append(enc_sym_key)
                    print "Uploading symkey..."
                    body = _FileProducer(StringIO("") ,dataq)
                    headers = http_headers.Headers()
                    d = agent.request(
                        'PUT',
                        'http://localhost:8000/shares/?method=sharefile&ccid='
                        + self.ccid + "&rccid=" + s[3] + "&fileid=" + s[2],
                        headers,
                        body)
                    d.addCallback(self.printPutReply_cb)

                    return d
Пример #11
0
                def shareFile_cb():
                    args = ("delete", str(self.ccid), s[3], s[2])
                    salt = self.processCookie("/shares")

                    dataq = []
                    dataq.append(self.client_id.genHashArgs(args, salt))
                    dataq.append(enc_sym_key)
                    print "Uploading symkey..."

                    agent = CookieAgent(Agent(reactor), self.cookie_jar)
                    body = _FileProducer(StringIO(""), dataq)
                    headers = http_headers.Headers()
                    d = agent.request(
                        'PUT',
                        'http://localhost:8000/shares/?method=sharefile&ccid='
                        + self.ccid + "&rccid=" + s[3] + "&fileid=" + s[2],
                        headers, body)
                    d.addCallback(self.printPutReply_cb)

                    return d
Пример #12
0
                def shareFile_cb():
                    args = ("delete", str(self.ccid), s[3], s[2])
                    salt = self.processCookie("/shares")

                    dataq = []
                    dataq.append(self.client_id.genHashArgs(args, salt))
                    dataq.append(enc_sym_key)
                    print "Uploading symkey..."

                    agent = CookieAgent(Agent(reactor), self.cookie_jar)
                    body = _FileProducer(StringIO("") ,dataq)
                    headers = http_headers.Headers()
                    d = agent.request(
                        'PUT',
                        'http://localhost:8000/shares/?method=sharefile&ccid='
                        + self.ccid + "&rccid=" + s[3] + "&fileid=" + s[2],
                        headers,
                        body)
                    d.addCallback(self.printPutReply_cb)

                    return d
Пример #13
0
#         print "RESUME"
#         self._paused = False
#         if self._deferred is not None:
#             self._scheduleSomeProducing()

#     def stopProducing(self):
#         print "STOP"
#         if self._delayedProduce is not None:
#             self._delayedProduce.cancel()
#         self._deferred = None

if __name__ == "__main__":
    ticket = "I AM A VERYVERY LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG STRING"

    def cb(ignored):
        print "FINISHED"
        file.read(20)
        reactor.stop()

    file = open('recfile.exe', 'rb')
    producer = _FileProducer(file, ticket)
    headers = http_headers.Headers()

    agent = client.Agent(reactor)
    df = agent.request(
        "PUT",
        "http://localhost:8000/files/?method=putfile&ccid=111222333&name=file.txt&iv=12345&key=54321",
        headers, producer)
    df.addCallback(cb)
    reactor.run()
Пример #14
0
#         print "RESUME"
#         self._paused = False
#         if self._deferred is not None:
#             self._scheduleSomeProducing()

#     def stopProducing(self):
#         print "STOP"
#         if self._delayedProduce is not None:
#             self._delayedProduce.cancel()
#         self._deferred = None

if __name__ == "__main__":
    ticket = "I AM A VERYVERY LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG STRING"

    def cb(ignored):
        print "FINISHED"
        file.read(20)
        reactor.stop()

    file = open('recfile.exe', 'rb')
    producer = _FileProducer(file, ticket)
    headers = http_headers.Headers()

    agent = client.Agent(reactor)
    df = agent.request(
        "PUT",
        "http://localhost:8000/files/?method=putfile&ccid=111222333&name=file.txt&iv=12345&key=54321",
        headers, producer)
    df.addCallback(cb)
    reactor.run()