mirror of
https://github.com/wavestone-cdt/EDRSandblast.git
synced 2026-06-11 09:51:18 +00:00
Rather use r2 to get file version than pefile
This commit is contained in:
@@ -8,7 +8,6 @@ from gzip import decompress
|
|||||||
from json import loads, dumps
|
from json import loads, dumps
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import pefile
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import threading
|
import threading
|
||||||
CSVLock = threading.Lock()
|
CSVLock = threading.Lock()
|
||||||
@@ -105,11 +104,15 @@ def get_field_offset(symbols_info, field_name):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_file_version(path):
|
def get_file_version(path):
|
||||||
pe = pefile.PE(path)
|
# dump version number using r2
|
||||||
info = pe.VS_FIXEDFILEINFO[0]
|
r = run(["r2", "-c", "iV", "-qq", path], capture_output=True)
|
||||||
ms = info.FileVersionMS
|
for line in r.stdout.decode().splitlines():
|
||||||
ls = info.FileVersionLS
|
line = line.strip()
|
||||||
return (ms >> 16, ms & 0xffff, ls >> 16, ls & 0xffff)
|
if line.startswith("FileVersion:"):
|
||||||
|
return [int(frag) for frag in line.split(" ")[-1].split(".")]
|
||||||
|
|
||||||
|
print(f'[!] ERROR : failed to extract version from {path}.')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
def extractOffsets(input_file, output_file, mode):
|
def extractOffsets(input_file, output_file, mode):
|
||||||
if os.path.isfile(input_file):
|
if os.path.isfile(input_file):
|
||||||
@@ -131,17 +134,6 @@ def extractOffsets(input_file, output_file, mode):
|
|||||||
if mode != imageType:
|
if mode != imageType:
|
||||||
print(f"[*] Skipping {input_file} since we are in {mode} mode")
|
print(f"[*] Skipping {input_file} since we are in {mode} mode")
|
||||||
return
|
return
|
||||||
# dump version number
|
|
||||||
"""
|
|
||||||
r = run(["r2", "-c", "iV", "-qq", input_file], capture_output=True)
|
|
||||||
for line in r.stdout.decode().splitlines():
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith("FileVersion:"):
|
|
||||||
full_version = [int(frag) for frag in line.split(" ")[-1].split(".")]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
assert(False)
|
|
||||||
"""
|
|
||||||
if os.path.sep not in input_file:
|
if os.path.sep not in input_file:
|
||||||
input_file = "." + os.path.sep + input_file
|
input_file = "." + os.path.sep + input_file
|
||||||
full_version = get_file_version(input_file)
|
full_version = get_file_version(input_file)
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
requests
|
requests
|
||||||
pefile
|
|
||||||
|
|||||||
Reference in New Issue
Block a user