Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,8 +16,7 @@ This tool allows you to analyze various file types:
|
|
16 |
- View information about .dll files
|
17 |
""")
|
18 |
|
19 |
-
#
|
20 |
-
MAX_FILE_SIZE = 10 * 1024 * 1024
|
21 |
|
22 |
def unpack_exe(file_path, output_dir):
|
23 |
"""Extract information from an EXE file using pefile"""
|
@@ -166,61 +165,58 @@ def process_zip_file(file_path, temp_dir):
|
|
166 |
uploaded_file = st.file_uploader("Upload a file (.zip, .exe, or .dll)", type=["zip", "exe", "dll"])
|
167 |
|
168 |
if uploaded_file is not None:
|
169 |
-
#
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
with
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
|
187 |
-
result
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
st.subheader("Detected Executable Files")
|
198 |
-
for file_path, file_info in result['nested_files'].items():
|
199 |
-
with st.expander(f"{file_path} ({file_info['type'].upper()})"):
|
200 |
-
st.json(file_info['info'])
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
os.makedirs(output_dir, exist_ok=True)
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
dll_info = analyze_dll(file_path)
|
224 |
-
st.json(dll_info)
|
225 |
-
except Exception as e:
|
226 |
-
st.error(f"Error analyzing DLL file: {str(e)}")
|
|
|
16 |
- View information about .dll files
|
17 |
""")
|
18 |
|
19 |
+
# No size limit
|
|
|
20 |
|
21 |
def unpack_exe(file_path, output_dir):
|
22 |
"""Extract information from an EXE file using pefile"""
|
|
|
165 |
uploaded_file = st.file_uploader("Upload a file (.zip, .exe, or .dll)", type=["zip", "exe", "dll"])
|
166 |
|
167 |
if uploaded_file is not None:
|
168 |
+
# Process file without size check
|
169 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
170 |
+
# Save the uploaded file to the temporary directory
|
171 |
+
file_path = os.path.join(temp_dir, uploaded_file.name)
|
172 |
+
with open(file_path, "wb") as f:
|
173 |
+
f.write(uploaded_file.getbuffer())
|
174 |
+
|
175 |
+
st.success(f"File uploaded: {uploaded_file.name}")
|
176 |
+
|
177 |
+
# Process based on file type
|
178 |
+
if uploaded_file.name.lower().endswith('.zip'):
|
179 |
+
st.subheader("ZIP File Contents")
|
180 |
+
output_dir = os.path.join(temp_dir, "extracted")
|
181 |
+
os.makedirs(output_dir, exist_ok=True)
|
182 |
|
183 |
+
result = process_zip_file(file_path, output_dir)
|
184 |
|
185 |
+
if 'error' in result:
|
186 |
+
st.error(f"Error processing ZIP file: {result['error']}")
|
187 |
+
else:
|
188 |
+
with st.expander("ZIP Contents", expanded=True):
|
189 |
+
st.write(f"Total files: {len(result['file_list'])}")
|
190 |
+
st.json(result['file_list'])
|
191 |
|
192 |
+
if result['nested_files']:
|
193 |
+
st.subheader("Detected Executable Files")
|
194 |
+
for file_path, file_info in result['nested_files'].items():
|
195 |
+
with st.expander(f"{file_path} ({file_info['type'].upper()})"):
|
196 |
+
st.json(file_info['info'])
|
197 |
+
|
198 |
+
elif uploaded_file.name.lower().endswith('.exe'):
|
199 |
+
st.subheader("EXE File Analysis")
|
200 |
+
output_dir = os.path.join(temp_dir, "exe_unpacked")
|
201 |
+
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
|
|
|
|
|
202 |
|
203 |
+
try:
|
204 |
+
exe_info = unpack_exe(file_path, output_dir)
|
205 |
+
st.json(exe_info)
|
|
|
206 |
|
207 |
+
# Check if resources were extracted
|
208 |
+
resource_dir = os.path.join(output_dir, "resources")
|
209 |
+
if os.path.exists(resource_dir) and os.listdir(resource_dir):
|
210 |
+
st.subheader("Extracted Resources")
|
211 |
+
for resource_file in os.listdir(resource_dir):
|
212 |
+
st.text(f"Resource: {resource_file}")
|
213 |
+
except Exception as e:
|
214 |
+
st.error(f"Error analyzing EXE file: {str(e)}")
|
215 |
+
|
216 |
+
elif uploaded_file.name.lower().endswith('.dll'):
|
217 |
+
st.subheader("DLL File Information")
|
218 |
+
try:
|
219 |
+
dll_info = analyze_dll(file_path)
|
220 |
+
st.json(dll_info)
|
221 |
+
except Exception as e:
|
222 |
+
st.error(f"Error analyzing DLL file: {str(e)}")
|
|
|
|
|
|
|
|