Skip to content

Fix issue #129 by rewriting the ARC handler yara rule.#130

Merged
qkaiser merged 2 commits intomainfrom
fix-arc-handler-rule
Jan 5, 2022
Merged

Fix issue #129 by rewriting the ARC handler yara rule.#130
qkaiser merged 2 commits intomainfrom
fix-arc-handler-rule

Conversation

@qkaiser
Copy link
Copy Markdown
Contributor

@qkaiser qkaiser commented Dec 15, 2021

See #129

@qkaiser qkaiser added this to the v1.0 - extraction milestone Dec 15, 2021
@qkaiser qkaiser requested a review from kukovecz December 15, 2021 17:49
@qkaiser qkaiser self-assigned this Dec 15, 2021
@qkaiser qkaiser force-pushed the fix-arc-handler-rule branch 3 times, most recently from 4eae512 to da44f1b Compare December 17, 2021 10:46
@qkaiser
Copy link
Copy Markdown
Contributor Author

qkaiser commented Dec 17, 2021

I added two enhancements to ARC handler that will help with #129. Moved the size to an unsigned integer (should always be positive), and added a name validation function that verify if the file name is unicode encoded.

@vlaci vlaci force-pushed the fix-arc-handler-rule branch from da44f1b to 3ec5b99 Compare January 4, 2022 12:25
@vlaci
Copy link
Copy Markdown
Contributor

vlaci commented Jan 4, 2022

Hm, a file doesn't get extracted now :(

@vlaci
Copy link
Copy Markdown
Contributor

vlaci commented Jan 4, 2022

From the docstring of the yara rule:

        Then a null-byte or unitialized-byte terminated filename string of 13 bytes, the
        uninitialized byte is always set between 0xf0 and 0xff.

This matches with the output of the test:

struct heads:

  • archive_marker: 0x1a
  • header_type: 0x2
  • name: b'apple.txt\x00\x00\x00\xfd'
  • size: 0x6
  • date: 0x5379
  • time: 0x6cef
  • crc: 0x3038
  • length: 0x6

This will trip on the valid_name check.

@qkaiser qkaiser force-pushed the fix-arc-handler-rule branch from 3ec5b99 to 9097c90 Compare January 5, 2022 13:46
@qkaiser
Copy link
Copy Markdown
Contributor Author

qkaiser commented Jan 5, 2022

Fixed valid_name by moving to this:

# we don't care about the terminating byte (null or unitialized)
snull(name[:-1]).decode("utf-8")

@vlaci
Copy link
Copy Markdown
Contributor

vlaci commented Jan 5, 2022

Yaay, null bytes are valid unicode code points :D

@qkaiser qkaiser merged commit f41f8da into main Jan 5, 2022
@qkaiser qkaiser deleted the fix-arc-handler-rule branch January 5, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants