jtpereyda / boofuzz

A fork and successor of the Sulley Fuzzing Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Aligned" definition function's implementation is incorrect,modify the encode method

WhereIsOops opened this issue · comments

Proposal

def encode(self, value, mutation_context): child_data = self.get_child_data(mutation_context=mutation_context)
"Aligned" can't get child data using 'get_child_data' because of it has no stack menber.I suggest taking a approach like "Size" function to get the data associated with the request parameter.

Use-Case

My modified code is as follows:
def encode(self, value, mutation_context): if self.request is not None and self.block_name is not None: target_block = self.request.resolve_name(self.context_path,self.block_name) child_data = target_block.render(mutation_context=mutation_context) padding_length = self._modulus - (len(child_data) % self._modulus) a, b = divmod(padding_length, len(self._pattern)) # remove return child_data return self._pattern * a + self._pattern[:b] else: return

Anything else?

No response

Let me add a little more,
def encode(self, value, mutation_context): if self.request is not None and self.block_name is not None: target_block = self.request.resolve_name(self.context_path,self.block_name) child_data = target_block.render(mutation_context=mutation_context) remainder = len(child_data) % self._modulus if remainder != 0: padding_length = self._modulus - (len(child_data) % self._modulus) a, b = divmod(padding_length, len(self._pattern)) return self._pattern * a + self._pattern[:b] else: return b"" else: return
When modal, we should add a judgment that the calculation result is 0 ,which means that the data is already aligned at this time.

@WhereIsOops could you please re-format your Comments to use proper code tags? This would be the correct markdown syntax to use:

```python
def encode(self, value, mutation_context):
    # rest...
```
Thank you!

@WhereIsOops could you please re-format your Comments to use proper code tags? This would be the correct markdown syntax to use:

def encode(self, value, mutation_context):
    # rest...

Thank you!

def encode(self, value, mutation_context):
  if self.request is not None and self.block_name is not None:
      target_block = self.request.resolve_name(self.context_path,self.block_name)
      child_data = target_block.render(mutation_context=mutation_context)
      remainder = len(child_data) % self._modulus
      if remainder != 0:
          padding_length = self._modulus - (len(child_data) % self._modulus)
          a, b = divmod(padding_length, len(self._pattern))
          return self._pattern * a + self._pattern[:b]
      else:
          return b""
  else:
      return

The alignment primitive is not a request class object and does not have the children parameter during initialization. Therefore, its stack is empty. Therefore, the get_child_data method cannot be used.