def process_client_telemetry(hostname): print("telemetry: " + (hostname)) if not request.json: return ("Waiting for json", 400) mydata = request.json t = Telemetry() #t.ts = mydata.get("ts") t.domain = mydata.get("domain") t.ip = mydata.get("ip") t.hostname = hostname t.filepath = mydata.get("filepath") t.hash = mydata.get("hash") db_session.add(t) exist_hash = Analysis.query.filter(Analysis.hash == mydata.get("hash")) if exist_hash.first() is None: a = Analysis() a.hash = mydata.get("hash") a.filepath = mydata.get("filepath") a.system = "vt" a.status = "new" db_session.add(a) db_session.commit() return ("Got telemetry", 200)
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'