diff --git a/bin/submit_paste.py b/bin/submit_paste.py index 5efc6615..32367dd1 100755 --- a/bin/submit_paste.py +++ b/bin/submit_paste.py @@ -201,10 +201,14 @@ if __name__ == "__main__": filename = file_full_path.split('/')[-1] if not '.' in filename: # read file - with open(file_full_path,'r') as f: - content = f.read() + try: + with open(file_full_path,'r') as f: + content = f.read() + except: + abord_file_submission(uuid, "file error") + continue r_serv_log_submit.set(uuid + ':nb_total', 1) - create_paste(uuid, content.encode(), ltags, ltagsgalaxies, uuid) + create_paste(uuid, content, ltags, ltagsgalaxies, uuid) remove_submit_uuid(uuid) else: diff --git a/var/www/modules/PasteSubmit/Flask_PasteSubmit.py b/var/www/modules/PasteSubmit/Flask_PasteSubmit.py index ae530aeb..6ae9e891 100644 --- a/var/www/modules/PasteSubmit/Flask_PasteSubmit.py +++ b/var/www/modules/PasteSubmit/Flask_PasteSubmit.py @@ -179,7 +179,7 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub eventUuid = event['Event']['uuid'] eventid = event['Event']['id'] - r_serv_metadata.set('misp_events:path', eventid) + r_serv_metadata.set('misp_events:'+path, eventid) # add tags for tag in l_tags: @@ -192,8 +192,6 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub leak_obj.add_attribute('origin', value=source, type='text') leak_obj.add_attribute('last-seen', value=date_to_str(paste.p_date), type='datetime') leak_obj.add_attribute('raw-data', value=source, data=pseudofile, type="attachment") - # FIXME TODO: delete this - leak_obj.add_attribute('type', value='Onion', type='text') if p_duplicate_number > 0: leak_obj.add_attribute('duplicate', value=p_duplicate, type='text') @@ -206,6 +204,7 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub print ("Template for type {} not found! Valid types are: {%s}".format(obj_name, valid_types)) r = pymisp.add_object(eventid, templateID, leak_obj) if 'errors' in r: + print(r) return False else: event_url = misp_event_url + eventid @@ -251,7 +250,7 @@ def hive_create_case(hive_tlp, threat_level, hive_description, hive_case_title, if res.status_code != 201: print('ko: {}/{}'.format(res.status_code, res.text)) - r_serv_metadata.set('hive_cases:path', id) + r_serv_metadata.set('hive_cases:'+path, id) return hive_case_url.replace('id_here', id) else: @@ -286,7 +285,8 @@ def submit(): if ltags or ltagsgalaxies: if not addTagsVerification(ltags, ltagsgalaxies): - return 'INVALID TAGS' + content = {'INVALID TAGS'} + return content, status.HTTP_400_BAD_REQUEST # add submitted tags if(ltags != ''): @@ -329,10 +329,11 @@ def submit(): UUID = UUID) else: - print('wrong file type') + content = {'wrong file type'} + return content, status.HTTP_400_BAD_REQUEST - if paste_content != '': + elif paste_content != '': if sys.getsizeof(paste_content) < 900000: # get id @@ -348,9 +349,11 @@ def submit(): UUID = UUID) else: - return 'size error' + content = {'size error'} + return content, status.HTTP_400_BAD_REQUEST - return 'submit' + content = {'submit aborded'} + return content, status.HTTP_400_BAD_REQUEST return PasteSubmit_page() @@ -440,8 +443,8 @@ def create_misp_event(): if event != False: return redirect(event) else: - return 'error' - return 'error' + return 'error1' + return 'error0' @PasteSubmit.route("/PasteSubmit/create_hive_case", methods=['POST']) def create_hive_case(): diff --git a/var/www/static/image/misp-logo.png b/var/www/static/image/misp-logo.png new file mode 100644 index 00000000..5f2d4dd5 Binary files /dev/null and b/var/www/static/image/misp-logo.png differ diff --git a/var/www/static/image/thehive-logo.png b/var/www/static/image/thehive-logo.png new file mode 100644 index 00000000..5390d16f Binary files /dev/null and b/var/www/static/image/thehive-logo.png differ diff --git a/var/www/static/image/thehive_icon.png b/var/www/static/image/thehive_icon.png new file mode 100644 index 00000000..dee6b296 Binary files /dev/null and b/var/www/static/image/thehive_icon.png differ