How to use the boofuzz.helpers.str_to_bytes function in boofuzz

To help you get started, we’ve selected a few boofuzz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jtpereyda / boofuzz / boofuzz / blocks / size.py View on Github external
def render(self):
        """
        Render the sizer.

        :return: Rendered value.
        """
        if self._should_render_fuzz_value():
            self._rendered = self.bit_field.render()
        elif self._recursion_flag:
            self._rendered = self._get_dummy_value()
        else:
            self._rendered = self._render()

        return helpers.str_to_bytes(self._rendered)
github jtpereyda / boofuzz / boofuzz / blocks / request.py View on Github external
def render(self):
        # ensure there are no open blocks lingering.
        if self.block_stack:
            raise exception.SullyRuntimeError("UNCLOSED BLOCK: %s" % self.block_stack[-1].name)

        self._rendered = b""

        for item in self.stack:
            self._rendered += item.render()

        return helpers.str_to_bytes(self._rendered)
github jtpereyda / boofuzz / boofuzz / primitives / bytes.py View on Github external
def _render(self, value):
        """
        Render string value, properly padded.
        """

        value = helpers.str_to_bytes(value)

        # if size is set, then pad undersized values.
        if self.size is not None:
            value += self.padding * (self.size - len(value))

        return helpers.str_to_bytes(value)
github jtpereyda / boofuzz / boofuzz / blocks / request.py View on Github external
def original_value(self):
        # ensure there are no open blocks lingering.
        if self.block_stack:
            raise exception.SullyRuntimeError("UNCLOSED BLOCK: %s" % self.block_stack[-1].name)

        self._rendered = b""

        for item in self.stack:
            self._rendered += helpers.str_to_bytes(item.original_value)

        return self._rendered
github jtpereyda / boofuzz / boofuzz / primitives / string.py View on Github external
def _render(self, value):
        """
        Render string value, properly padded.
        """

        if isinstance(value, six.text_type):
            value = helpers.str_to_bytes(value)

        # pad undersized library items.
        if len(value) < self.size:
            value += self.padding * (self.size - len(value))
        return helpers.str_to_bytes(value)
github jtpereyda / boofuzz / boofuzz / blocks / size.py View on Github external
def _render(self):
        length = self._calculated_length()
        return helpers.str_to_bytes(self._length_to_bytes(length))
github jtpereyda / boofuzz / boofuzz / blocks / block.py View on Github external
#
        # otherwise, render and encode as usual.
        #

        for item in self.stack:
            self._rendered += item.render()

        # add the completed block to the request dictionary.
        self.request.closed_blocks[self.name] = self

        # if an encoder was attached to this block, call it.
        if self.encoder:
            self._rendered = self.encoder(self._rendered)

        return helpers.str_to_bytes(self._rendered)
github jtpereyda / boofuzz / boofuzz / primitives / base_primitive.py View on Github external
def _render(self, value):
        """
        Render an arbitrary value.

        Args:
            value: Value to render.

        Returns:
            bytes: Rendered value
        """
        if value is None:
            value = b""
        return helpers.str_to_bytes(value)
github jtpereyda / boofuzz / boofuzz / legos / ber.py View on Github external
def render(self):
        # let the parent do the initial render.
        blocks.Block.render(self)

        # TODO: What is this I don't even
        self._rendered = self.prefix + b"\x84" + self._rendered

        return helpers.str_to_bytes(self._rendered)