Пример #1
0
 def __init__(self, name):
     vm = androguard.AndroguardS(name)
     self.vm = vm.get_vm()
     self.bca = analysis.VMAnalysis(self.vm)
     ldict = [(dvclass.get_name(), DvClass(dvclass, self.bca))
              for dvclass in self.vm.get_classes()]
     self.classes = dict(ldict)
     Util.merge_inner(self.classes)
Пример #2
0
def main(options, arguments):
    if options.version != None:
        print "Andromarks version %s" % androconf.ANDROGUARD_VERSION

    elif options.directory != None and options.xml != None:
        for root, dirs, files in os.walk(options.directory):
            if files != []:
                for file in files:
                    if ".class" in file:
                        print "FILE", file
                        _b = androguard.AndroguardS(root + "/" + file)
                        for class_name in _b.get_classes_names():
                            androguard.WMCheck(_b, class_name, options.xml)
Пример #3
0
    def add(self, filename):
        _a = androguard.AndroguardS(filename)
        _x = analysis.VM_BCA(_a.get_vm())

        raw = _a.get_orig_raw()
        if self._session.query(Raw).filter_by(
                hash=hashlib.sha512(raw).hexdigest()).count() > 0:
            return

        a_raw = Raw(raw)
        self._session.add(a_raw)
        # commit to have the id of the apk raw
        self._session.commit()
Пример #4
0
#!/usr/bin/env python

import sys
PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL + "./")

import androguard

TEST = [ './examples/java/Hello.class' ]

_a = androguard.AndroguardS( TEST[0] )
_a.show()


for field in _a.gets("fields") :
    print field.get_name(), field.get_descriptor()

for method in _a.get("method", "test") :
    print method.get_name(), method.get_descriptor()

method, _ =_a.get_method_descriptor("Hello", "test", "([B)[B")
print method.get_name()

for method in _a.gets("methods") :
    print method.get_name()
Пример #5
0
import androguard, analysis
from analysis import *

TEST_CASE = "examples/android/TestsAndroguard/bin/classes.dex"


def test(got, expected):
    if got == expected:
        prefix = ' OK '
    else:
        prefix = '  X '
    print '%s got: %s expected: %s' % (prefix, repr(got), repr(expected))


a = androguard.AndroguardS(TEST_CASE)
x = analysis.VMAnalysis(a.get_vm(), code_analysis=True)

for method in a.get_methods():
    print method.get_class_name(), method.get_name(), method.get_descriptor()
    print "-> : \t", x.get_method_signature(
        method, predef_sign=SIGNATURE_L0_0).get_string()
    print "-> : \t", x.get_method_signature(
        method, predef_sign=SIGNATURE_L0_1).get_string()
    print "-> : \t", x.get_method_signature(
        method, predef_sign=SIGNATURE_L0_2).get_string()
    print "-> : \t", x.get_method_signature(method, "L4", {
        "L4": {
            "arguments": ["Landroid"]
        }
    }).get_string()
Пример #6
0
#!/usr/bin/env python

import sys
PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL + "./")

import androguard

#TEST_ORIG = './examples/android/Test/bin/classes/org/t0t0/android/Test1.class'
TEST_ORIG = './examples/java/test/orig/Test1.class'
TEST_MODIF_OUTPUT = './examples/java/test/new/'

TEST_JAVA_STEAL = './examples/java/test/orig/Test1.class'
TEST_ANDRO_STEAL = './examples/android/Test/bin/classes.dex'

_a = androguard.AndroguardS( TEST_ORIG )

#wm = androguard.WM( _a, "Test1", TEST_MODIF_OUTPUT, [ androguard.WM_L5 ], "./wm.xml" )
wm = androguard.WM( _a, "Test1", TEST_MODIF_OUTPUT, [ androguard.WM_L2 ], "./wm.xml")

#_b = androguard.AndroguardS( TEST_JAVA_STEAL )
#androguard.WMCheck( _b, "org.t0t0.android.Test1", "./wm.xml" )
Пример #7
0
import sys, hashlib

PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL + "./")

import androguard, analysis

#TEST  = 'examples/java/test/orig/Test1.class'
#TEST  = 'examples/java/Demo1/orig/DES.class'
#TEST  = 'examples/java/Demo1/orig/Util.class'
#TEST = 'examples/android/Test/bin/classes.dex'
TEST = 'examples/android/TestsAndroguard/bin/classes.dex'
#TEST = 'examples/android/TC/bin/classes.dex'
#TEST = 'examples/android/Hello_Kitty/classes.dex'

a = androguard.AndroguardS(TEST)
x = analysis.VMAnalysis(a.get_vm())

# CFG
for method in a.get_methods():
    g = x.hmethods[method]

    print method.get_class_name(), method.get_name(), method.get_descriptor(
    ), method.get_code().get_length(), method.get_code(
    ).registers_size.get_value()

    idx = 0
    for i in g.basic_blocks.get():
        print "\t %s %x %x" % (i.name, i.start, i.end), i.ins[-1].get_name(
        ), '[ CHILDS = ', ', '.join(
            "%x-%x-%s" % (j[0], j[1], j[2].get_name())
Пример #8
0
import random, string

import sys

PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL + "./")

import androguard

TEST = './examples/java/test/orig/Test1.class'
TEST_OUTPUT = './examples/java/test/new/Test1.class'

TEST2 = './examples/java/Hello.class'

_a = androguard.AndroguardS(TEST)
_b = androguard.AndroguardS(TEST2)

_a.show()

#nb = 0
#for field in _a.gets( "fields" ) :
#   field.set_name( random.choice( string.letters ) + ''.join([ random.choice(string.letters + string.digits) for i in range(10 - 1) ] ) )
#   nb += 1

#for string in _a.gets( "strings" ) :
#   print string

#for method in _a.get("method", "rc4") :
#   if method.with_descriptor( "([B)[B" ) :
#      code = method.get_code()
Пример #9
0
        if key not in values:
            continue

        print "CHECKING ...", 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():
            #            print "\t", "%x(%d)" % (idx, idx), i.get_name(), i.get_operands()
            if idx in values[key]:
                elem = values[key][idx]

                val1 = i.get_name() + "%s" % i.get_operands()
                val2 = elem[0] + "%s" % elem[1]

                test(val1, val2)

                del values[key][idx]

            idx += i.get_length()


for i in TESTS_CASES:
    a = androguard.AndroguardS(i)
    check(a, VALUES[i])

    x = analysis.VMAnalysis(a.get_vm())
    print x