def testTypes(self): s = Session() with open(TEST_CASE, "rb") as fd: digest, d, dx = s.addDEX(TEST_CASE, fd.read()) for method in d.get_methods(): key = method.get_class_name() + " " + method.get_name( ) + " " + method.get_descriptor() if key not in VALUES: continue print("METHOD", method.get_class_name(), method.get_name(), method.get_descriptor()) code = method.get_code() bc = code.get_bc() idx = 0 for i in bc.get_instructions(): if "const" in i.get_name(): i.show(0) formatted_operands = i.get_formatted_operands() print(formatted_operands) if not formatted_operands: VALUES[key].pop(0) else: for f in formatted_operands: self.assertAlmostEqual(f, VALUES[key].pop(0), places=4) idx += i.get_length()
def testTypes(self): s = Session() with open(TEST_CASE, "rb") as fd: digest, d, dx = s.addDEX(TEST_CASE, fd.read()) for method in d.get_methods(): key = method.get_class_name() + " " + method.get_name( ) + " " + method.get_descriptor() if key not in VALUES: continue print("METHOD", method.get_class_name(), method.get_name( ), method.get_descriptor()) code = method.get_code() bc = code.get_bc() idx = 0 for i in bc.get_instructions(): if "const" in i.get_name(): i.show(0) formatted_operands = i.get_formatted_operands() print(formatted_operands) if not formatted_operands: VALUES[key].pop(0) else: for f in formatted_operands: self.assertAlmostEqual(f, VALUES[key].pop(0), places=4) idx += i.get_length()
def testTypes(self): s = Session() with open(TEST_CASE, "rb") as fd: digest, d, dx = s.addDEX(TEST_CASE, fd.read()) for method in filter(lambda x: x.full_name in VALUES, d.get_methods()): print("METHOD", method.full_name) for i in filter(lambda x: 'const' in x.get_name(), method.get_instructions()): i.show(0) # ins should only have one literal self.assertEquals(len(i.get_literals()), 1) fmt, value = VALUES[method.full_name].pop(0) converted = format_value(i.get_literals()[0], i, fmt) print(i.get_literals(), fmt, value, converted) self.assertEqual(converted, value) print()
#!/usr/bin/env python from __future__ import print_function import sys, hashlib PATH_INSTALL = "./" sys.path.append(PATH_INSTALL) from androguard.session import Session from androguard.core.bytecodes import dvm TEST = 'examples/android/TestsAndroguard/bin/classes.dex' s = Session() with open(TEST, "r") as fd: digest, d, dx = s.addDEX(TEST, fd.read()) # CFG for method in d.get_methods(): g = dx.get_method(method) # Display only methods with exceptions if method.get_code() == None: continue if method.get_code().tries_size <= 0: continue print(method.get_class_name(), method.get_name(), method.get_descriptor( ), method.get_code().get_length(), method.get_code().registers_size)
-606384730, -123456790519087104, -606384730, 3.5 ], } def _test(got, expected): if got == expected: prefix = ' OK ' else: prefix = ' X ' print('%s got: %s expected: %s' % (prefix, repr(got), repr(expected))) s = Session() with open(TEST_CASE, "rb") as fd: digest, d, dx = s.addDEX(TEST_CASE, fd.read()) for method in d.get_methods(): key = method.get_class_name() + " " + method.get_name( ) + " " + method.get_descriptor() if key not in VALUES: continue print("METHOD", method.get_class_name(), method.get_name(), method.get_descriptor()) code = method.get_code() bc = code.get_bc() idx = 0
-606384730, -123456790519087104, -606384730, 3.5 ], } def test(got, expected): if got == expected: prefix = ' OK ' else: prefix = ' X ' print('%s got: %s expected: %s' % (prefix, repr(got), repr(expected))) s = Session() with open(TEST_CASE, "r") as fd: digest, d, dx = s.addDEX(TEST_CASE, fd.read()) for method in d.get_methods(): key = method.get_class_name() + " " + method.get_name( ) + " " + method.get_descriptor() if key not in VALUES: continue print("METHOD", method.get_class_name(), method.get_name( ), method.get_descriptor()) code = method.get_code() bc = code.get_bc() idx = 0
#!/usr/bin/env python import sys PATH_INSTALL = "./" sys.path.append(PATH_INSTALL) from androguard.session import Session TEST = 'examples/android/TestsAndroguard/bin/classes.dex' s = Session() with open(TEST, "r") as fd: digest, d, dx = s.addDEX(TEST, fd.read()) for method in d.get_methods(): print method.get_class_name(), method.get_name(), method.get_descriptor() code = method.get_code() if code != None: bc = code.get_bc() idx = 0 for i in bc.get_instructions(): print "\t", "%x" % idx, i.get_name(), i.get_output() idx += i.get_length() for method in d.get_methods(): print method.get_class_name(), method.get_name(), method.get_descriptor() idx = 0 for i in method.get_instructions(): print "\t", "%x" % idx, i.get_name(), i.get_output()