sigyllly commited on
Commit
7549384
·
verified ·
1 Parent(s): c0bbedf

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -6
main.py CHANGED
@@ -139,18 +139,25 @@ def generate_script():
139
  .replace('<<additional_obfuscated_code>>', generate_additional_obfuscated_code()) \
140
  .replace('<<obfuscated_methods>>', generate_obfuscated_methods())
141
 
142
- # Save the modified C# script to a file
143
- script_path = 'polymorphic_program.cs'
144
- with open(script_path, 'w') as file:
145
- file.write(modified_cs)
 
 
 
146
 
147
  # Step 10: Compile the C# script using csc
148
- compile_command = f'csc /target:winexe /platform:x64 /out:run.exe {script_path} /win32icon:app.ico /win32manifest:app.manifest'
149
- subprocess.run(compile_command, shell=False, check=False)
 
 
 
150
 
151
  # Provide a link to download the compiled executable
152
  return send_file('run.exe', as_attachment=True)
153
 
 
154
  # Start the Flask app
155
  if __name__ == '__main__':
156
  app.run(host='0.0.0.0', port=7860)
 
139
  .replace('<<additional_obfuscated_code>>', generate_additional_obfuscated_code()) \
140
  .replace('<<obfuscated_methods>>', generate_obfuscated_methods())
141
 
142
+ # Use an absolute path to prevent permission errors
143
+ script_path = os.path.join('/app/uploads', 'polymorphic_program.cs')
144
+ try:
145
+ with open(script_path, 'w') as file:
146
+ file.write(modified_cs)
147
+ except PermissionError:
148
+ return "Permission denied. Could not write the script file.", 500
149
 
150
  # Step 10: Compile the C# script using csc
151
+ try:
152
+ compile_command = ['csc', '/target:winexe', '/platform:x64', '/out:run.exe', script_path, '/win32icon:app.ico', '/win32manifest:app.manifest']
153
+ subprocess.run(compile_command, shell=False, check=True)
154
+ except subprocess.CalledProcessError as e:
155
+ return f"Compilation failed: {e}", 500
156
 
157
  # Provide a link to download the compiled executable
158
  return send_file('run.exe', as_attachment=True)
159
 
160
+
161
  # Start the Flask app
162
  if __name__ == '__main__':
163
  app.run(host='0.0.0.0', port=7860)