Hi :), In the previous post, I discussed automation of decompiling apks. Now, let’s have a look on how to check the availability of some text or term in the decompiled files.
So let’s continue our python script
decompileApk.py
#---------------------------filter for any term------------------------------- #Create a new folder to include output files if not os.path.exists(walk_dir + "_Decompiled/Outputs"): os.makedirs(walk_dir + "_Decompiled/Outputs") primary_path = os.path.dirname(os.path.abspath("decompileApk.py")) root_output = '' # Create output file for each apk file for dirs in os.walk(walk_dir+ "_Decompiled").next()[1]: root_output = os.path.join(walk_dir+ "_Decompiled/Outputs", dirs+'_output_paypal.txt') with open(root_output, 'a') as f: f.close for root, subdirs, files in os.walk(walk_dir+ "_Decompiled"): # exclude the files with .py if 'Outputs' in subdirs: subdirs.remove('Outputs') files = [ fi for fi in files if not fi.endswith(".py") ] parent_directory = os.path.split(os.path.abspath(os.path.join(root, os.pardir)))[1] if os.path.exists('./Outputs/'+parent_directory+'_output_paypal.txt'): root_output = os.path.join(walk_dir+ "_Decompiled/Outputs", parent_directory+'_output_paypal.txt') with open(root_output, 'a') as f: for filename in files: file_path = os.path.join(root, filename) (out,err) = subprocess.Popen(['grep', '-rinIe', 'okhttp',file_path],stdout=f,stderr=f).communicate() print('--\nfile_path = ' + file_path) print out f.close;
Cheers ! 🙂