diff --git a/app/templates/file_info.html b/app/templates/file_info.html index de44b88..99c459f 100644 --- a/app/templates/file_info.html +++ b/app/templates/file_info.html @@ -115,6 +115,13 @@ File is not detected by AV. {% endfor %} + +{% if current_user.is_authenticated %} +Download with all matches overwritten +
+{% endif %} +
+ {% endif %} {% if outcome.fileStructure != '' %} diff --git a/app/templates/includes/file_conclusion.html b/app/templates/includes/file_conclusion.html index 2cc7b4c..b2bb4ef 100644 --- a/app/templates/includes/file_conclusion.html +++ b/app/templates/includes/file_conclusion.html @@ -5,7 +5,11 @@ {% elif outcome.verification.matchConclusions.verifyStatus[index]|string == "VerifyStatus.IRRELEVANT" %} Probably not relevant. Check verifier {% elif outcome.verification.matchConclusions.verifyStatus[index]|string == "VerifyStatus.DOMINANT" %} -Dominant. Modify this to make file undetected +Dominant. Modify this to make file undetected + {% if current_user.is_authenticated %} + (Download) + {% endif %} + {% else %} {% endif %} diff --git a/app/templates/includes/verifystatus.html b/app/templates/includes/verifystatus.html index 4d43d43..a4d8fa5 100644 --- a/app/templates/includes/verifystatus.html +++ b/app/templates/includes/verifystatus.html @@ -11,7 +11,9 @@ {% endif %} - + {% endfor %} {% endif %} \ No newline at end of file diff --git a/app/views.py b/app/views.py index 572b5d9..445389f 100644 --- a/app/views.py +++ b/app/views.py @@ -106,6 +106,68 @@ def fileDownloadOutflank(filename): attachment_filename=filename ) +@views.route("/file//downloadPatchMatch/") +@login_required +def fileDownloadPatchMatch(filename, id): + id = int(id) + if filename != secure_filename(filename): + flash('Invalid filename') + return redirect('index.html') + filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], filename) + + outcome, logData, errStr = getFileData(filepath) + if errStr is not None or outcome is None or logData is None: + return "Error: " + errStr + + if not os.path.isfile(filepath): + return "Error: File not found: " + filepath + with open(filepath, 'rb') as file: + fileData: bytearray = bytearray(file.read()) + + match: Match = outcome.matches[id] + len = match.size + offset = match.fileOffset + data = b"\x00" * len + fileData[offset:offset+len] = data + + return send_file( + io.BytesIO(fileData), + mimetype='application/octet-stream', + as_attachment=True, + attachment_filename=filename + ) + +@views.route("/file//downloadPatchMatch/") +@login_required +def fileDownloadPatchFull(filename): + if filename != secure_filename(filename): + flash('Invalid filename') + return redirect('index.html') + filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], filename) + + outcome, logData, errStr = getFileData(filepath) + if errStr is not None or outcome is None or logData is None: + return "Error: " + errStr + + if not os.path.isfile(filepath): + return "Error: File not found: " + filepath + with open(filepath, 'rb') as file: + fileData: bytearray = bytearray(file.read()) + + for match in outcome.matches: + print("Patch: {} {} {}".format(match.idx, match.fileOffset, match.size)) + len = match.size + offset = match.fileOffset + data = b"\x00" * len + fileData[offset:offset+len] = data + + return send_file( + io.BytesIO(fileData), + mimetype='application/octet-stream', + as_attachment=True, + attachment_filename=filename + ) + ### Examples related