sigyllly commited on
Commit
06b7dab
·
verified ·
1 Parent(s): 8412d29

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -18
main.py CHANGED
@@ -6,7 +6,7 @@ from flask import Flask, render_template_string, send_file
6
 
7
  app = Flask(__name__)
8
 
9
- # Define the base C# template without AssemblyCulture
10
  base_cs_template = """
11
  using System;
12
  using System.Diagnostics;
@@ -110,10 +110,6 @@ def index():
110
 
111
  @app.route('/generate', methods=['POST'])
112
  def generate_script():
113
- # Create uploads directory if it doesn't exist
114
- uploads_dir = 'uploads'
115
- os.makedirs(uploads_dir, exist_ok=True)
116
-
117
  # Step 7: Generate the randomized assembly information using meaningful words
118
  assembly_info = {
119
  'title': random.choice(titles),
@@ -143,25 +139,25 @@ def generate_script():
143
  .replace('<<additional_obfuscated_code>>', generate_additional_obfuscated_code()) \
144
  .replace('<<obfuscated_methods>>', generate_obfuscated_methods())
145
 
146
- # Save the modified C# script to a file in the uploads directory
147
- script_path = os.path.join(uploads_dir, 'polymorphic_program.cs')
148
  with open(script_path, 'w') as file:
149
  file.write(modified_cs)
150
 
151
- # Step 10: Compile the C# script using csc
152
- compile_command = f'csc /target:winexe /platform:x64 /out:run.exe {script_path} /win32icon:app.ico /win32manifest:app.manifest'
153
-
154
- # Run the compilation command and capture the output
155
- result = subprocess.run(compile_command, shell=True, capture_output=True, text=True)
156
-
157
  if result.returncode != 0:
158
- # Log the error to the console or handle it as needed
159
- print("Compilation failed:", result.stderr)
160
- return f"Error during compilation: {result.stderr}", 500
 
161
 
162
  # Provide a link to download the compiled executable
163
- return send_file('run.exe', as_attachment=True)
164
 
165
  # Start the Flask app
166
  if __name__ == '__main__':
167
- app.run(host='0.0.0.0', port=7860)
 
6
 
7
  app = Flask(__name__)
8
 
9
+ # Step 1: Define the base C# template without AssemblyCulture
10
  base_cs_template = """
11
  using System;
12
  using System.Diagnostics;
 
110
 
111
  @app.route('/generate', methods=['POST'])
112
  def generate_script():
 
 
 
 
113
  # Step 7: Generate the randomized assembly information using meaningful words
114
  assembly_info = {
115
  'title': random.choice(titles),
 
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 dotnet
148
+ compile_command = f'dotnet build {script_path} -o /app/out'
149
+ print(f"Running compile command: {compile_command}") # Debugging line
150
+ result = subprocess.run(compile_command, shell=True, check=False)
151
+
 
152
  if result.returncode != 0:
153
+ print("Compilation failed!") # Debugging line
154
+ return "Compilation failed!", 500
155
+
156
+ print("Compilation succeeded!") # Debugging line
157
 
158
  # Provide a link to download the compiled executable
159
+ return send_file('/app/out/polymorphic_program.dll', as_attachment=True)
160
 
161
  # Start the Flask app
162
  if __name__ == '__main__':
163
+ app.run(debug=True)