import random from pprint import pprint import gradio as gr import easy_db def get_db_path(): return "device_data.db" def is_verifying_and_good_boot_state(dict_of_device_data_to_save): if dict_of_device_data_to_save["verify"] == "enforcing" and dict_of_device_data_to_save["boot_state"] == "green": return True return False def is_debug_enabled(dict_of_device_data_to_save): if dict_of_device_data_to_save["debug_enabled"] == False: return False else: return True def is_installer_google(dict_of_device_data_to_save): if dict_of_device_data_to_save["installer"] == True: return True else: return False def is_in_emulator(dict_of_device_data_to_save): if dict_of_device_data_to_save["emulator"] == True: return True else: return False def do_certs_match(previous_entries_for_device,dict_of_device_data_to_save): for entry in previous_entries_for_device: if entry["primary_certificate"] != dict_of_device_data_to_save["primary_certificate"]: return False return True def get_num_differences(previous_entries_for_device,dict_of_device_data_to_save): differences = [] for previous_entry in previous_entries_for_device: difference = 0 for key in list(dict_of_device_data_to_save.keys()): if dict_of_device_data_to_save[key] != previous_entry[key]: difference = difference + 1 differences.append(difference) if len(differences) != 0: max_difference = max(differences) else: max_difference = 0 return max_difference def process_request(id_textbox, installer_textbox,boot_state_textbox,verify_textbox,patch_level_textbox, oem_textbox,brand_textbox,model_textbox,unlocked_textbox,debug_enabled_textbox, primary_certificate_textbox,emulator_textbox,fingerprint_status_textbox,storage_encryption_status_textbox, market_apps_enabled_textbox,adb_enabled_textbox,lock_screen_timeout_textbox, lock_screen_type_textbox,notification_visibility_textbox, app_permissions_textbox): results = [] apps_and_permissions = app_permissions_textbox.split("&&") permissions_dict = {} # for app_and_permissions in apps_and_permissions: try: app, permissions = app_and_permissions.split("*******") permissions = permissions.split(" ") permissions_dict[app] = permissions except ValueError as e: print(e) pprint(permissions_dict) ''' is_malware_list = [] for permission in permissions_dict: detector = DroidDetective.APK_Analyser() is_malware = detector.identify(permissions_dict[permission], "DroidDetective/apk_malware.model")[0] if is_malware == 0: is_malware = False else: is_malware = True is_malware_list.append(is_malware) if True in is_malware_list: results.append(True) else: results.append(False)''' dict_of_device_data_to_save = {"id": id_textbox, "installer": installer_textbox, "boot_state": boot_state_textbox, "verify": verify_textbox, "patch_level": patch_level_textbox, "oem": oem_textbox, "brand": brand_textbox, "model": model_textbox, "unlocked": unlocked_textbox, "debug_enabled": debug_enabled_textbox, "primary_certificate": primary_certificate_textbox, "emulator": emulator_textbox, "fingerprint_status": fingerprint_status_textbox, "storage_encryption_status": storage_encryption_status_textbox, "market_apps_enabled": market_apps_enabled_textbox, "adb_enabled": adb_enabled_textbox, "lock_screen_timeout": lock_screen_timeout_textbox, "lock_screen_type": lock_screen_type_textbox, "notification_visibility": notification_visibility_textbox} db = easy_db.DataBase('device_data.db') results.append(not is_debug_enabled(dict_of_device_data_to_save)) results.append(not is_in_emulator(dict_of_device_data_to_save)) results.append(is_installer_google(dict_of_device_data_to_save)) results.append(is_verifying_and_good_boot_state(dict_of_device_data_to_save)) table_names = db.table_names() if 'devices' in table_names: previous_entries_for_device = db.pull_where('devices', 'id = "{}"'.format(id_textbox)) if previous_entries_for_device: max_difference = get_num_differences(previous_entries_for_device, dict_of_device_data_to_save) certs_match = do_certs_match(previous_entries_for_device, dict_of_device_data_to_save) results.append(certs_match) pprint(dict_of_device_data_to_save) db.append('devices', [dict_of_device_data_to_save]) print(results) negative_results = results.count(True) result = negative_results/ len(results) result = result * 100 history = [] history.append(["Integrity Check Complete", str(result)]) return history block = gr.Blocks(css=".container { max-width: 800px; margin: auto; } h1 { margin: 0px; padding: 5px 0; line-height: 50px; font-size: 60pt; }.close-heading {margin: 0px; padding: 0px;} .close-heading p { margin: 0px; padding: 0px;}", title="Boudica") db = easy_db.DataBase('device_data.db') html_data = '''

Runic Integrity πŸ—ΏπŸ›‘οΈ

Identify malicious changes to your device and apps

Download the Android App To Use Runic Integrity. ⬇ Runic Integrity is an Android application designed to assess the integrity of a device and report that back to applications on that device for safety checks.


''' with block: gr.HTML(value=html_data) with gr.Group(): with gr.Row().style(equal_height=True): download_db_file = gr.File(value="device_data.db", interactive=False, label="Device Database") with gr.Accordion("Open for More!", visible=False): chatbot = gr.Chatbot().style(color_map=("green", "pink")) # ID id_textbox = gr.Textbox(label="Android Secure ID") # Misc installer_textbox = gr.Textbox(label="Installer") debug_enabled_textbox = gr.Textbox(label="Debug Enabled") primary_certificate_textbox = gr.Textbox(label="primary_certificate") emulator_textbox = gr.Textbox(label="Emulator") # Device Data boot_state_textbox = gr.Textbox(label="Verify Boot State") verify_textbox = gr.Textbox(label="Verify Mode") patch_level_textbox = gr.Textbox(label="Security Patch Level") oem_textbox = gr.Textbox(label="OEM Unlock Supported") brand_textbox = gr.Textbox(label="Product Brand") model_textbox = gr.Textbox(label="Product Model") unlocked_textbox = gr.Textbox(label="OEM Unlock Status") # Settings fingerprint_status_textbox = gr.Textbox(label="Fingerprint Status") storage_encryption_status_textbox = gr.Textbox(label="Storage Encryption Status") market_apps_enabled_textbox = gr.Textbox(label="Market Apps Enabled") adb_enabled_textbox = gr.Textbox(label="ADB Enabled") lock_screen_timeout_textbox = gr.Textbox(label="Lock Screen Timeout") lock_screen_type_textbox = gr.Textbox(label="Lock Screen Type") notification_visibility_textbox = gr.Textbox(label="Notification Visibility") app_permissions_textbox = gr.Textbox(label="App Permissions") btn = gr.Button(label="Submit Data") btn.click(fn=process_request, inputs=[id_textbox, installer_textbox,boot_state_textbox,verify_textbox,patch_level_textbox, oem_textbox,brand_textbox,model_textbox,unlocked_textbox,debug_enabled_textbox, primary_certificate_textbox,emulator_textbox,fingerprint_status_textbox,storage_encryption_status_textbox, market_apps_enabled_textbox,adb_enabled_textbox,lock_screen_timeout_textbox, lock_screen_type_textbox,notification_visibility_textbox,app_permissions_textbox], outputs=[chatbot],api_name="submit") # Setup callback for when page loads (used to set a new Twitter auth target webspage) block.__enter__() block.set_event_trigger( event_name="load", fn=get_db_path, inputs=None, outputs=[download_db_file], no_target=True ) #block.attach_load_events() # Launcg the page block.launch(enable_queue = True)