Skip to content

Commit

Permalink
upload win exe for symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Arcuri committed Feb 16, 2024
1 parent 29b3b31 commit 7f8b0e0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion orochi/templates/website/list_symbols.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<i class="fa fa-upload"></i> Symbols
</button>
<button type="button" class="btn btn-sm btn-secondary" id="upload-packages">
<i class="fa fa-upload"></i> Linux Package
<i class="fa fa-upload"></i> .deb .ddeb .rmp .exe
</button>
<button type="button" class="btn btn-sm btn-success" id="download-isf">
<i class="fa fa-download"></i> from ISF Server
Expand Down
32 changes: 32 additions & 0 deletions orochi/utils/download_symbols.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import binascii
import json
import lzma
import os
import subprocess
Expand All @@ -8,6 +10,9 @@
import rpmfile
from debian import debfile
from django.conf import settings
from pefile import PE
from volatility3.framework.contexts import Context
from volatility3.framework.symbols.windows.pdbconv import PdbReader, PdbRetreiver


class Downloader:
Expand All @@ -17,6 +22,7 @@ def __init__(self, file_list: List[str] = None, url_list: List[str] = None) -> N
self.down_path = f"{settings.VOLATILITY_SYMBOL_PATH}/added/"

def download_list(self):
"""Download and process files from web urls [Linux]"""
processed_files = {}
for url in self.url_list:
print(f" - Downloading {url}")
Expand All @@ -33,6 +39,7 @@ def download_list(self):
self.process(processed_files)

def process_list(self):
"""Download and process uploaded files"""
processed_files = {}
for filepath, filename in self.file_list:
print(f" - Processing {filename}")
Expand All @@ -43,9 +50,12 @@ def process_list(self):
processed_files[filename] = self.process_deb(archivedata)
elif filename.endswith(".ddeb"):
processed_files[filename] = self.process_ddeb(archivedata)
elif filename.endswith(".exe"):
self.process_exe(filepath)
self.process(processed_files)

def process(self, processed_files):
"""Process the files and remove the temporary files"""
self.process_files(processed_files)
for fname in processed_files.values():
if fname:
Expand Down Expand Up @@ -78,6 +88,28 @@ def process_files(self, named_files: Dict[str, str]):
with lzma.open(output_filename, "w") as f:
f.write(proc.stdout)

def process_exe(self, archivedata) -> Optional[str]:
"""Download json from pdb in exe [Windows]"""
pe = PE(archivedata)
debug = pe.DIRECTORY_ENTRY_DEBUG[0].entry
guid = "{0:08X}{1:04X}{2:04X}{3}{4}".format(
debug.Signature_Data1,
debug.Signature_Data2,
debug.Signature_Data3,
f"{debug.Signature_Data4:x}{debug.Signature_Data5:x}{binascii.hexlify(debug.Signature_Data6).decode('utf-8')}",
debug.Age,
).upper()
filename = PdbRetreiver().retreive_pdb(
guid, file_name="ntkrnlmp.pdb", progress_callback=None
)
ctxt = Context()
profile = PdbReader(ctxt, filename).get_json()

output_filename = f"{self.down_path}{guid}.json"
print(f" - Writing to {output_filename}")
with open(output_filename, "w") as f:
json.dump(profile, f, indent=4)

def process_rpm(self, archivedata) -> Optional[str]:
rpm = rpmfile.RPMFile(fileobj=archivedata)
member = None
Expand Down
2 changes: 2 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ beautifulsoup4==4.12.3
python-debian==0.1.49
# https://github.com/srossross/rpmfile
rpmfile==2.0.0
# https://github.com/erocarrera/pefile
pefile==2023.2.7

# misp export
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit 7f8b0e0

Please sign in to comment.