Skip to content

Commit

Permalink
Merge pull request #43 from CybercentreCanada/bugfix/charcode_hex
Browse files Browse the repository at this point in the history
Hex should only accept a-f not a-z
  • Loading branch information
cccs-jh authored Feb 10, 2023
2 parents 37cbd35 + dd7fad7 commit 3802624
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ def charcode(text: bytes) -> Optional[bytes]:
@staticmethod
def charcode_hex(text: bytes) -> Optional[bytes]:
""" Replace hex character codes with the corresponding characters """
output = regex.sub(rb'(?i)(?:\\x|0x|%)([a-z0-9]{2})', lambda m: binascii.unhexlify(m.group(1)), text)
output = regex.sub(rb'(?i)(?:\\x|0x|%)([a-f0-9]{2})', lambda m: binascii.unhexlify(m.group(1)), text)
return output if output != text else None

@staticmethod
def charcode_unicode(text: bytes) -> Optional[bytes]:
""" Replace unicode character codes with the corresponding utf-8 byte sequence"""
output = regex.sub(rb'(?i)(?:\\u|%u)([a-z0-9]{4})', DeobfuScripter.codepoint_sub, text)
output = regex.sub(rb'(?i)(?:\\u|%u)([a-f0-9]{4})', DeobfuScripter.codepoint_sub, text)
return output if output != text else None

@staticmethod
Expand Down

0 comments on commit 3802624

Please sign in to comment.