siberider / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

Code error in latest repo #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In ./elsim/elsim/elsim_dalvik.py

class Method :
    def __init__(self, vm, vmx, m) :
        self.m = m
        self.vm = vm
        self.vmx = vmx
        self.mx = vmx.get_method( m )

        self.sort_h = []

        self.hash = {}
        self.sha256 = None

def add_attribute(self, func_meth, func_checksum_bb) :
        bb = {}
        bbhash = {}

        fm = func_meth( self.m, self.sim )

**self.sim has not been initialized.**

Fix?

def __init__(self, vm, vmx, m, sim) :
        self.m = m
        self.vm = vm
        self.vmx = vmx
        self.mx = vmx.get_method( m )
        self.sim = sim

        self.sort_h = []

        self.hash = {}
        self.sha256 = None

Original issue reported on code.google.com by V.E.O.T...@gmail.com on 19 Oct 2012 at 11:20

GoogleCodeExporter commented 9 years ago
class CheckSumMeth :
    def __init__(self, m1, sim) :
        self.m1 = m1
        self.sim = sim
        self.buff = ""
        self.entropy = 0.0
        self.signature = None

        code = m1.m.get_code()

This is called in androguard/elsim/elsim/elsim_dalvik.py add_attribute:
  fm = func_meth( self.m, self.sim )
will raise exception.

is it code = m1.get_code() ?

Original comment by V.E.O.T...@gmail.com on 19 Oct 2012 at 11:37

GoogleCodeExporter commented 9 years ago
class CheckSumBB :
    def __init__(self, basic_block, sim) :
        self.basic_block = basic_block
        self.buff = ""
        for i in self.basic_block.bb.get_instructions() :
            self.buff += dvm.clean_name_instruction( i )
            self.buff += dvm.static_operand_instruction( i )

        #self.hash = hashlib.sha256( self.buff + "%d%d" % (len(basic_block.childs), len(basic_block.fathers)) ).hexdigest()
        self.hash = hashlib.sha256( self.buff ).hexdigest()

    def get_buff(self) :
        return self.buff

    def get_hash(self) :
        return self.hash

def filter_checksum_bb_basic( basic_block, sim ) :
    return CheckSumBB( basic_block, sim )

filter_checksum_bb_basic is called in androguard/elsim/elsim/elsim_dalvik.py 
add_attribute:
  bb[ i.name ] = func_checksum_bb( i )

Arguments number seems incorrect?
and sim is never used in CheckSumBB, why not:

def filter_checksum_bb_basic( basic_block) :
    return CheckSumBB( basic_block)

class CheckSumBB :
    def __init__(self, basic_block) :

Original comment by V.E.O.T...@gmail.com on 19 Oct 2012 at 11:43

GoogleCodeExporter commented 9 years ago

Original comment by anthony....@gmail.com on 16 Nov 2012 at 6:49