Skip to content

Fix inconsistent comparison of sets in encode when using regular expression#2122

Closed
p0ise wants to merge 1 commit intoGallopsled:devfrom
p0ise:fix-encoder
Closed

Fix inconsistent comparison of sets in encode when using regular expression#2122
p0ise wants to merge 1 commit intoGallopsled:devfrom
p0ise:fix-encoder

Conversation

@p0ise
Copy link
Copy Markdown
Contributor

@p0ise p0ise commented Oct 23, 2022

In this code:

67    if expr:
68        for char in all_chars:
69            if re.search(expr, char):
70                avoid.add(char)

which make avoid something like {'a', 'b'}.

But set() of bytes would be {some ints}.

This will invalidate the following conditions because they can never intersect:

79        if encoder.blacklist & avoid:
...
87        if avoid & set(v):

@p0ise p0ise changed the title Fix inconsistent comparison of sets in encode Fix inconsistent comparison of sets in encode when using regular expression Oct 23, 2022
@Arusekk
Copy link
Copy Markdown
Member

Arusekk commented Oct 23, 2022

Thank you! Current implementation of shellcode encoders is a mess in general, so I will take a look at it later.

@Arusekk Arusekk self-requested a review December 28, 2022 23:47
@peace-maker
Copy link
Copy Markdown
Member

Similar changes to the types in #1583 look like they are more thorough in ensuring the avoid bytes/set is applied correctly.

To reduce the amount of stalled ancient PRs, I'll close this and look into cherry picking the Python 3 bytes related fixes in the other PR without touching too much of the logic due to the lack of tests.

Thank you for your contribution nonetheless! :D

@peace-maker peace-maker closed this Apr 7, 2026
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.

3 participants