Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self):
"""
We overload and extend the render routine in order to properly insert substring lengths.
"""
# let the parent do the initial render.
blocks.Block.render(self)
new_str = six.binary_type(b"")
# replace dots (.) with the substring length.
for part in self._rendered.split("."):
new_str += str(len(part)) + part
# be sure to null terminate too.
self._rendered = new_str + six.binary_type(b"\x00")
return helpers.str_to_bytes(self._rendered)
# let the parent do the initial render.
blocks.Block.render(self)
new_str = six.binary_type(b"")
# replace dots (.) with the substring length.
for part in self._rendered.split("."):
new_str += str(len(part)) + part
# be sure to null terminate too.
self._rendered = new_str + six.binary_type(b"\x00")
return helpers.str_to_bytes(self._rendered)
class Tag(blocks.Block):
def __init__(self, name, request, value, options=None):
if not options:
options = {}
super(Tag, self).__init__(name, request)
self.value = value
self.options = options
if not self.value:
raise exception.SullyRuntimeError("MISSING LEGO.tag DEFAULT VALUE")
#
# [delim][string][delim]
self.push(primitives.Delim("<"))
def render(self):
# let the parent do the initial render.
blocks.Block.render(self)
self._rendered = b"\x02\x04" + self._rendered
return helpers.str_to_bytes(self._rendered)
# format accordingly.
length = len(self._rendered)
self._rendered = (
b""
+ struct.pack("
# MSRPC NDR TYPES
import struct
from .. import blocks, exception, helpers, primitives
from ..helpers import calculate_four_byte_padding
class NdrConformantArray(blocks.Block):
"""
Note: this is not for fuzzing the RPC protocol but rather just representing an NDR string for fuzzing the actual
client.
"""
def __init__(self, name, request, value, options=None):
if not options:
options = {}
super(NdrConformantArray).__init__(name, request)
self.value = value
self.options = options
if not self.value:
raise exception.SullyRuntimeError("MISSING LEGO.ndr_conformant_array DEFAULT VALUE")
:param name: Name of block being opened
:type group: str
:param group: (Optional, def=None) Name of group to associate this block with
:type encoder: Function Pointer
:param encoder: (Optional, def=None) Optional pointer to a function to pass rendered data to prior to return
:type dep: str
:param dep: (Optional, def=None) Optional primitive whose specific value this block is dependant on
:type dep_value: Mixed
:param dep_value: (Optional, def=None) Value that field "dep" must contain for block to be rendered
:type dep_values: List of Mixed Types
:param dep_values: (Optional, def=[]) Values that field "dep" may contain for block to be rendered
:type dep_compare: str
:param dep_compare: (Optional, def="==") Comparison method to use on dependency (==, !=, >, >=, <, <=)
"""
class ScopedBlock(Block):
def __init__(self, block):
self.block = block
def __enter__(self):
"""
Setup before entering the "with" statement body
"""
return self.block
def __exit__(self, type, value, traceback):
"""
Cleanup after executing the "with" statement body
"""
# Automagically close the block when exiting the "with" statement
s_block_end()