IOsipov / androguard

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

Running more apk analysis #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Running apk analysis iterating on apks got from a directory doen't work 
properly.
After some iterations, the script freezes and doesn't go on....
If I restart the script, it begins from the file on which the analysis was 
blocked! So I think it's not a problem related to the file, but to the sw.
Below the source code extracted from my script
def analyze(infile) :
    score = 0
    permissions = {}
    data = []
    risk_detailed = {}
    if androconf.is_android(infile) == "APK" :
        try:   
            allstrings, score, risk_detailed, list_details_permissions = AnalyzeAPK(infile)
            if (str(list_details_permissions).find('_SMS') != -1 or 
                str(list_details_permissions).find('CALL') != -1) :
                for cur in allstrings :
                    if re.search('^\d{4,20}$', cur) :
                        data.append(cur)
            if str(list_details_permissions).find('INTERNET') != -1 :
                for cur in allstrings :
                    if re.search('^http://', cur) :
                        data.append(cur)
            for i in list_details_permissions :
                permission = i
                if permission.find(".") != -1 :
                    permission = permission.split(".")[-1]
                    risk_type = GENERAL_PERMISSIONS_RISK[ list_details_permissions[ i ][0]]
                    permissions[permission] = RISK_VALUES [ risk_type ]
        except Exception, e:
            print "Exception reason " + str(e)
    return score, permissions, data, risk_detailed
........ other function containg the itertions .......
        for row in rows :
            try:
                filename = row[0]
                filename = download_path + "/" + filename
                appid = row[1]
                flag = 1
                print 'analyze: ', filename, '\n'
                total_risk, permissions, data, risk_detailed=analyze(filename)

Original issue reported on code.google.com by liadalex82@gmail.com on 2 Dec 2011 at 4:43

GoogleCodeExporter commented 9 years ago
The script restart on the blocked filed ?? How is it possible ?

What is the content of the AnalyzeAPK function ?

Original comment by anthony....@gmail.com on 4 Dec 2011 at 11:24

GoogleCodeExporter commented 9 years ago

Original comment by anthony....@gmail.com on 6 Dec 2011 at 8:18

GoogleCodeExporter commented 9 years ago
yes. the script restart on the blocked files.
It seems a problem related to memory usage....
The content of AnalyzeAPK is:
def AnalyzeAPK(filename, raw=False) :
    from dvm import DalvikVMFormat 
    from apk import APK
    import risk
    a = APK(filename, raw)
    if a.is_valid_APK() != True :
        print "Not valid APK ", filename
        del a
        return False, None, None, None, None
    strings = DalvikVMFormat( a.get_dex() ).get_strings()
    ri = risk.RiskIndicator() 
    score, risk_detailed = ri.with_apk(a)
    perms = a.get_details_permissions()
    del a
    del ri
    return True, strings, score, risk_detailed, perms

Original comment by liadalex82@gmail.com on 7 Dec 2011 at 10:10

GoogleCodeExporter commented 9 years ago
The script causes an out of memory, so the OS kills the python process!
Probably a memory leak occurs.
Cheers

Original comment by liadalex82@gmail.com on 7 Dec 2011 at 11:05