How to use the bytecode.SVs function in bytecode

To help you get started, we’ve selected a few bytecode 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 androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, class_manager, buff) :
        self.__CM = class_manager
        tag = SV( '>B', buff.read_b(1) ).get_value()

        if tag not in VERIFICATION_TYPE_INFO :
            bytecode.Exit( "tag not in VERIFICATION_TYPE_INFO" )

        format = VERIFICATION_TYPE_INFO[ tag ][1]
        self.format = SVs( format, VERIFICATION_TYPE_INFO[ tag ][2], buff.read( calcsize( format ) ) )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, class_manager, buff) :
        self.__CM = class_manager
        self.__raw_buff = buff.read( calcsize( ATTRIBUTE_INFO[0] ) )

        self.format = SVs( ATTRIBUTE_INFO[0], ATTRIBUTE_INFO[1], self.__raw_buff )
        self.__name = self.__CM.get_string( self.format.get_value().attribute_name_index )

        try :
            self._info = ATTRIBUTE_INFO_DESCR[ self.__name ](self.__CM, buff)
        except KeyError, ke :
            bytecode.Exit( "AttributeInfo %s doesn't exit" % self.__name )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
self.__tag = SV( '>B', buff.read_b(1) )

        self.__bytes = None
        self.__extra = 0

        tag_value = self.__tag.get_value()
        format = CONSTANT_INFO[ tag_value ][1]

        self.__name = CONSTANT_INFO[ tag_value ][0]

        self.format = SVs( format, CONSTANT_INFO[ tag_value ][2], buff.read( calcsize( format ) ) )

        # Utf8 value ?
        if tag_value == 1 :
            self.__extra = self.format.get_value().length
            self.__bytes = SVs( ">%ss" % self.format.get_value().length, namedtuple( CONSTANT_INFO[ tag_value ][0] + "_next", "bytes" ), buff.read( self.format.get_value().length ) )
github androguard / androguard / core / bytecodes / dvm.py View on Github external
def __init__(self, buff, cm) :
        self.__CM = cm
        self.__offset = self.__CM.add_offset( buff.get_idx(), self )

        self.format = SVs( FIELD_ID_ITEM[0], FIELD_ID_ITEM[1], buff.read( calcsize(FIELD_ID_ITEM[0]) ) )
        self._class = None
        self._type = None
        self._name = None
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, buff) :
        self.__tag = SV( '>B', buff.read_b(1) )

        self.__bytes = None
        self.__extra = 0

        tag_value = self.__tag.get_value()
        format = CONSTANT_INFO[ tag_value ][1]

        self.__name = CONSTANT_INFO[ tag_value ][0]

        self.format = SVs( format, CONSTANT_INFO[ tag_value ][2], buff.read( calcsize( format ) ) )

        # Utf8 value ?
        if tag_value == 1 :
            self.__extra = self.format.get_value().length
            self.__bytes = SVs( ">%ss" % self.format.get_value().length, namedtuple( CONSTANT_INFO[ tag_value ][0] + "_next", "bytes" ), buff.read( self.format.get_value().length ) )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def set_bytes(self, name) :
        self.format.set_value( { "length" : len(name) } )
        self.__extra = self.format.get_value().length
        self.__bytes = SVs( ">%ss" % self.format.get_value().length, namedtuple( CONSTANT_INFO[ self.__tag.get_value() ][0] + "_next", "bytes" ), name )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, class_manager, buff) :
        self.__CM = class_manager

        super(CodeAttribute, self).__init__()
        # u2 attribute_name_index;
        # u4 attribute_length;

        # u2 max_stack;
        # u2 max_locals;
        # u4 code_length;
        # u1 code[code_length];
        self.low_struct = SVs( CODE_LOW_STRUCT[0], CODE_LOW_STRUCT[1], buff.read( calcsize(CODE_LOW_STRUCT[0]) ) )

        self.__code = JavaCode( class_manager, buff.read( self.low_struct.get_value().code_length ) )

        # u2 exception_table_length;
        self.exception_table_length = SV( '>H', buff.read(2) )

        # {                u2 start_pc;
        #                  u2 end_pc;
        #                  u2  handler_pc;
        #                  u2  catch_type;
        # }        exception_table[exception_table_length];
        self.__exception_table = []
        for i in range(0, self.exception_table_length.get_value()) :
            et = SVs( EXCEPTION_TABLE[0], EXCEPTION_TABLE[1], buff.read( calcsize(EXCEPTION_TABLE[0]) ) )
            self.__exception_table.append( et )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, class_manager, buff) :
        self.__raw_buff = buff.read( calcsize( FIELD_INFO[0] ) )
        self.format = SVs( FIELD_INFO[0], FIELD_INFO[1], self.__raw_buff )

        self.__CM = class_manager
        self.__attributes = []

        for i in range(0, self.format.get_value().attributes_count) :
            ai = AttributeInfo( self.__CM, buff )
            self.__attributes.append( ai )
github androguard / androguard / core / bytecodes / jvm.py View on Github external
def __init__(self, class_manager, buff) :
        INNER_CLASSES_FORMAT = [ ">HHHH", "inner_class_info_index outer_class_info_index inner_name_index inner_class_access_flags" ]

        self.__CM = class_manager

        self.__raw_buff = buff.read( calcsize( INNER_CLASSES_FORMAT[0] ) )

        self.format = SVs( INNER_CLASSES_FORMAT[0], namedtuple( "InnerClassesFormat", INNER_CLASSES_FORMAT[1] ), self.__raw_buff )
github androguard / androguard / core / bytecodes / dvm.py View on Github external
def __init__(self, buff) :
        self.format = SVs( SPARSE_SWITCH[0], SPARSE_SWITCH[1], buff[ 0 : calcsize(SPARSE_SWITCH[0]) ] )
        self.keys = []
        self.targets = []

        idx = calcsize(SPARSE_SWITCH[0])
        for i in range(0, self.format.get_value().size) :
            self.keys.append( unpack('=L', buff[idx:idx+4])[0] )
            idx += 4

        for i in range(0, self.format.get_value().size) :
            self.targets.append( unpack('=L', buff[idx:idx+4])[0] )
            idx += 4