예제 #1
0
def s_size (block_name, length=4, endian="<", format="binary", inclusive=False, signed=False, math=None, fuzzable=False, name=None):
    '''
    Create a sizer block bound to the block with the specified name. You *can not* create a sizer for any
    currently open blocks.

    @see: Aliases: s_sizer()

    @type  block_name: String
    @param block_name: Name of block to apply sizer to
    @type  length:     Integer
    @param length:     (Optional, def=4) Length of sizer
    @type  endian:     Character
    @param endian:     (Optional, def=LITTLE_ENDIAN) Endianess of the bit field (LITTLE_ENDIAN: <, BIG_ENDIAN: >)
    @type  format:     String
    @param format:     (Optional, def=binary) Output format, "binary" or "ascii"
    @type  inclusive:  Boolean
    @param inclusive:  (Optional, def=False) Should the sizer count its own length?
    @type  signed:     Boolean
    @param signed:     (Optional, def=False) Make size signed vs. unsigned (applicable only with format="ascii")
    @type  math:       Function
    @param math:       (Optional, def=None) Apply the mathematical operations defined in this function to the size
    @type  fuzzable:   Boolean
    @param fuzzable:   (Optional, def=False) Enable/disable fuzzing of this sizer
    @type  name:       String
    @param name:       Name of this sizer field
    '''

    # you can't add a size for a block currently in the stack.
    if block_name in blocks.CURRENT.block_stack:
        raise sex.error("CAN NOT ADD A SIZE FOR A BLOCK CURRENTLY IN THE STACK")

    size = blocks.size(block_name, blocks.CURRENT, length, endian, format, inclusive, signed, math, fuzzable, name)
    blocks.CURRENT.push(size)
예제 #2
0
def s_size (block_name, offset=0, length=4, endian="<", format="binary", inclusive=False, signed=False, math=None, fuzzable=False, name=None):
    '''
    Create a sizer block bound to the block with the specified name. You *can not* create a sizer for any
    currently open blocks.

    @see: Aliases: s_sizer()

    @type  block_name: String
    @param block_name: Name of block to apply sizer to
    @type  offset:     Integer
    @param offset:     (Optional, def=0) Offset to calculated size of block
    @type  length:     Integer
    @param length:     (Optional, def=4) Length of sizer
    @type  endian:     Character
    @param endian:     (Optional, def=LITTLE_ENDIAN) Endianess of the bit field (LITTLE_ENDIAN: <, BIG_ENDIAN: >)
    @type  format:     String
    @param format:     (Optional, def=binary) Output format, "binary" or "ascii"
    @type  inclusive:  Boolean
    @param inclusive:  (Optional, def=False) Should the sizer count its own length?
    @type  signed:     Boolean
    @param signed:     (Optional, def=False) Make size signed vs. unsigned (applicable only with format="ascii")
    @type  math:       Function
    @param math:       (Optional, def=None) Apply the mathematical operations defined in this function to the size
    @type  fuzzable:   Boolean
    @param fuzzable:   (Optional, def=False) Enable/disable fuzzing of this sizer
    @type  name:       String
    @param name:       Name of this sizer field
    '''

    # you can't add a size for a block currently in the stack.
    if block_name in blocks.CURRENT.block_stack:
        raise sex.SullyRuntimeError("CAN NOT ADD A SIZE FOR A BLOCK CURRENTLY IN THE STACK")

    size = blocks.size(block_name, blocks.CURRENT, offset, length, endian, format, inclusive, signed, math, fuzzable, name)
    blocks.CURRENT.push(size)
예제 #3
0
    def __init__ (self, name, request, value, options={}):
        blocks.block.__init__(self, name, request, None, None, None, None)

        self.value   = value
        self.options = options
        self.prefix  = options.get("prefix", "\x04")

        if not self.value:
            raise sex.error("MISSING LEGO.ber_string DEFAULT VALUE")

        str_block = blocks.block(name + "_STR", request)
        str_block.push(primitives.string(self.value))

        self.push(blocks.size(name + "_STR", request, endian=">", fuzzable=True))
        self.push(str_block)
예제 #4
0
    def __init__ (self, name, request, value, options={}):
        blocks.block.__init__(self, name, request, None, None, None, None)

        self.value   = value
        self.options = options
        self.prefix  = options.get("prefix", "\x04")

        if not self.value:
            raise sex.SullyRuntimeError("MISSING LEGO.ber_string DEFAULT VALUE")

        str_block = blocks.block(name + "_STR", request)
        str_block.push(primitives.string(self.value))

        self.push(blocks.size(name + "_STR", request, endian=">", fuzzable=True))
        self.push(str_block)