File size: 11,415 Bytes
d80b843 1a05524 d80b843 19dedaa d80b843 3b11311 d3ab062 a2f1f08 d3ab062 19dedaa 45a945d d3ab062 d5a6471 02b2981 d5a6471 02b2981 3883dc0 81ddf66 3b2cbfc 81ddf66 22b8111 02b2981 19dedaa f2e0930 d3ab062 6d1a1a4 d3ab062 22b8111 7ccf7d9 1a05524 19dedaa 5f9a720 e009f41 d3ab062 19dedaa ac518ae 19dedaa 3b11311 19dedaa 3b11311 d3ab062 184902f d3ab062 19dedaa d3ab062 45a945d d3ab062 19dedaa 45a945d 19dedaa 3b11311 19dedaa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | 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 = '''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body,h1,h2,h3,h4,h5 {font-family: "Poppins", sans-serif}
body {font-size: 16px;}
img {margin-bottom: -8px;}
.mySlides {display: none;}
</style>
</head>
<body class="w3-content w3-black" style="max-width:1500px;">
<!-- The App Section -->
<div class="w3-padding-large w3-white">
<div class="w3-row-padding-large">
<div class="w3-col">
<h1 class="w3-jumbo"><b>Runic Integrity 🗿🛡️</b></h1>
<h1 class="w3-xxxlarge w3-text-blue"><b>Identify malicious changes to your device and apps</b></h1>
<p><span class="w3-xlarge">Download the Android App To Use Runic Integrity. ⬇ </span> 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.</p>
<a href="#"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
<i class=""></i> Find Out More! 💬
</button></a>
<a href="https://ko-fi.com/jamesstevenson"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
<i class=""></i> Support The Creator! ❤
</button></a>
<a href="https://twitter.com/_JamesStevenson"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
<i class=""></i> Follow The Creator! 🐦
</button></a>
</div>
</div>
</div>
<!-- Modal -->
<script>
// Slideshow
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
<br>
</body>
</html>
'''
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) |