File tree Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 7
7
8
8
cur_dir_path = Path (__file__ ).parent
9
9
10
- def test_upx_packer ():
10
+
11
+ def test_exe_upx_packer ():
11
12
upxed_path = cur_dir_path / 'test_data' / 'Hello_upx.exe_'
12
13
file_analyzer = FileAnalyzer (upxed_path )
13
14
pe_analyzer = PeAnalyzer (file_analyzer )
14
15
matches = pe_analyzer .get_packer_result ()
15
16
assert matches == ['UPX 2.90 [LZMA] -> Markus Oberhumer, Laszlo Molnar & John Reiser' ]
16
17
17
18
19
+ def test_elf_upx_packer ():
20
+ upxed_path = cur_dir_path / 'test_data' / 'Hello64_elf_static_upx_'
21
+ file_analyzer = FileAnalyzer (upxed_path )
22
+ elf_analyzer = ElfAnalyzer (file_analyzer )
23
+ matches = elf_analyzer .get_packer_result ()
24
+ assert matches == ['UPX 3.96' ]
25
+
26
+
18
27
def test_pyinstaller_packer ():
19
28
pe_path = cur_dir_path / 'test_data' / 'pyinstaller_pack.exe_'
20
29
file_analyzer = FileAnalyzer (pe_path )
Original file line number Diff line number Diff line change @@ -184,9 +184,7 @@ def get_wide_strs(self):
184
184
def get_tool_recommendations (self ):
185
185
recommended_tool_names = []
186
186
187
- if 'UPX compressed' in self .file_type :
188
- recommended_tool_names .append ('UPX' )
189
- elif 'Mono/.Net assembly' in self .file_type :
187
+ if 'Mono/.Net assembly' in self .file_type :
190
188
recommended_tool_names .append ('dnSpy' )
191
189
elif 'APK(Android application package)' in self .file_type :
192
190
recommended_tool_names .append ('JADX' )
@@ -205,6 +203,8 @@ def get_tool_recommendations(self):
205
203
recommended_tool_names .extend (['Wireshark' , 'BruteShark' ])
206
204
207
205
for packer in self .packer_list :
206
+ if packer .startswith ('UPX ' ):
207
+ recommended_tool_names .append ('UPX' )
208
208
if packer .startswith ('PyInstaller,' ):
209
209
recommended_tool_names .append ('PyInstaller Extractor' )
210
210
Original file line number Diff line number Diff line change 1
1
# coding:utf8
2
2
3
+ import re
3
4
from xanalyzer .utils import log
4
5
5
6
@@ -18,7 +19,16 @@ def get_packer_result(self):
18
19
if b'E: neither argv[0] nor $_ works.' in file_content :
19
20
matches = ['Shc, Shell script compiler, https://github.com/neurobin/shc' ]
20
21
return matches
21
-
22
+
23
+ # Check UPX
24
+ if b'$Info: This file is packed with the UPX executable packer' in file_content :
25
+ upx_ver_s = re .search (rb'\$Id: (UPX .+?) Copyright' , file_content )
26
+ if upx_ver_s :
27
+ matches = [upx_ver_s .group (1 ).decode ()]
28
+ else :
29
+ matches = ['UPX unknown version' ]
30
+ return matches
31
+
22
32
return None
23
33
24
34
def packer_scan (self ):
You can’t perform that action at this time.
0 commit comments