<s> import sys , os <EOL> sys . path . append ( "<STR_LIT>" ) <EOL> PATH_INSTALL = "<STR_LIT>" <EOL> sys . path . append ( PATH_INSTALL ) <EOL> from optparse import OptionParser <EOL> from elsim . elsim_db import * <EOL> from elsim . elsim_dalvik import LIST_EXTERNAL_LIBS <EOL> from elsim . similarity . similarity import * <EOL> from androguard . core import androconf <EOL> from androguard . core . bytecodes import apk , dvm <EOL> from androguard . core . analysis import analysis <EOL> from androguard . util import read <EOL> DEFAULT_SIGNATURE = analysis . SIGNATURE_SEQUENCE_BB <EOL> option_0 = { '<STR_LIT:name>' : ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:1> } <EOL> option_1 = { '<STR_LIT:name>' : ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:1> } <EOL> option_2 = { '<STR_LIT:name>' : ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:action>' : '<STR_LIT:count>' } <EOL> option_3 = { '<STR_LIT:name>' : ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:1> } <EOL> option_4 = { '<STR_LIT:name>' : ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:action>' : '<STR_LIT:count>' } <EOL> options = [ option_0 , option_1 , option_2 , option_3 , option_4 ] <EOL> def check_one_file ( d1 , dx1 ) : <EOL> print "<STR_LIT>" <EOL> e = ElsimDB ( options . database ) <EOL> print e . percentages ( d1 , dx1 ) <EOL> def check_one_directory ( directory ) : <EOL> for root , dirs , files in os . walk ( directory , followlinks = True ) : <EOL> if files != [ ] : <EOL> for f in files : <EOL> real_filename = root <EOL> if real_filename [ - <NUM_LIT:1> ] != "<STR_LIT:/>" : <EOL> real_filename += "<STR_LIT:/>" <EOL> real_filename += f <EOL> print "<STR_LIT>" % real_filename <EOL> ret_type = androconf . is_android ( real_filename ) <EOL> if ret_type == "<STR_LIT>" : <EOL> a = apk . APK ( real_filename ) <EOL> d1 = dvm . DalvikVMFormat ( a . get_dex ( ) ) <EOL> elif ret_type == "<STR_LIT>" : <EOL> d1 = dvm . DalvikVMFormat ( read ( real_filename ) ) <EOL> dx1 = analysis . VMAnalysis ( d1 ) <EOL> check_one_file ( d1 , dx1 ) <EOL> def main ( options , arguments ) : <EOL> if options . input != None and options . database != None : <EOL> ret_type = androconf . is_android ( options . input ) <EOL> if ret_type == "<STR_LIT>" : <EOL> a = apk . APK ( options . input ) <EOL> d1 = dvm . DalvikVMFormat ( a . get_dex ( ) ) <EOL> elif ret_type == "<STR_LIT>" : <EOL> d1 = dvm . DalvikVMFormat ( read ( options . input ) ) <EOL> dx1 = analysis . VMAnalysis ( d1 ) <EOL> check_one_file ( d1 , dx1 ) <EOL> elif options . directory != None and options . database != None : <EOL> check_one_directory ( options . directory ) <EOL> elif options . database != None and options . listdatabase != None : <EOL> db = DBFormat ( options . database ) <EOL> db . show ( ) <EOL> elif options . version != None : <EOL> print "<STR_LIT>" % androconf . ANDROGUARD_VERSION <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> parser = OptionParser ( ) <EOL> for option in options : <EOL> param = option [ '<STR_LIT:name>' ] <EOL> del option [ '<STR_LIT:name>' ] <EOL> parser . add_option ( * param , ** option ) <EOL> options , arguments = parser . parse_args ( ) <EOL> sys . argv [ : ] = arguments <EOL> main ( options , arguments ) </s>
