File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -247,26 +247,31 @@ impl StringPool {
247247 self . strings . get ( idx as usize )
248248 }
249249
250+ /// Get string from string pool
251+ ///
252+ /// Some malware defines its own strings in the manifest in a peculiar way, therefore,
253+ /// for correct unpacking, we must first look at the system attributes.
254+ ///
255+ /// Examples:
256+ /// - 58442d3e3a49eb41986b1099e298c78afe6726edb93b75d0b8b7b38ecd41a4a0
257+ /// - 4057a9b12248b345e5c8dccf473e3df44e3663b342d48f4a63c8694e9d07c153
250258 #[ inline]
251259 pub fn get_with_resources < ' a > (
252260 & ' a self ,
253261 idx : u32 ,
254262 xml_resource : & ' a XMLResourceMap ,
255263 is_attribute_name : bool ,
256264 ) -> Option < & ' a str > {
257- self . strings
258- . get ( idx as usize )
259- . map ( |x| x. as_str ( ) )
260- . filter ( |s| !s. is_empty ( ) )
261- . or_else ( || {
262- xml_resource. get_attr ( idx) . map ( |x| {
263- // need remove prefix if looked up in system attributes
264- if is_attribute_name {
265- x. strip_prefix ( "android:attr/" ) . unwrap_or ( x)
266- } else {
267- x
268- }
269- } )
265+ xml_resource
266+ . get_attr ( idx)
267+ . map ( |x| {
268+ // need remove prefix if looked up in system attributes
269+ if is_attribute_name {
270+ x. strip_prefix ( "android:attr/" ) . unwrap_or ( x)
271+ } else {
272+ x
273+ }
270274 } )
275+ . or_else ( || self . strings . get ( idx as usize ) . map ( |x| x. as_str ( ) ) )
271276 }
272277}
You can’t perform that action at this time.
0 commit comments