コード例 #1
0
def process_client_file(hostname, hash):
    f = request.files['file']
    f.save(os.path.join(UPLOADED_PATH, secure_filename(f.filename)))
    command_entry = Commands.query.filter(Commands.hash == hash)
    if command_entry.first() is not None:
        #command_entry.status = "done"
        db_session.delete(command_entry.first())

        fin = open(UPLOADED_PATH + "/" + f.filename, 'rb')
        files = {'file': fin}
        r = requests.post(
            "http://sandbox.etp-research.info:8090/tasks/create/submit",
            files=files)
        print r
        task_ids = r.json()["task_ids"]
        print task_ids[0]
        #command_entry.result = "http://sandbox.etp-research.info:8000/analysis/"+task_ids[0]+"/summary"

        a = Analysis()
        a.hash = hash
        a.filepath = f.filename
        a.system = "cuckoo"
        a.status = "done"
        a.link = "http://sandbox.etp-research.info:8000/analysis/" + str(
            task_ids[0]) + "/summary"
        db_session.add(a)

        db_session.commit()

    return 'file uploaded successfully'