ex 7 completed
This commit is contained in:
72
mobiotsec7justlisten/justlisten/justlisten_checker.py
Executable file
72
mobiotsec7justlisten/justlisten/justlisten_checker.py
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# ~/Android/Sdk/tools/bin/avdmanager list avd
|
||||
# ~/Android/Sdk/tools/avdmanager create avd --force --name mobiotsec --abi google_apis/x86 --package 'system-images;android-26;google_apis;x86'
|
||||
# ~/Android/Sdk/emulator/emulator -avd mobiotsec -no-audio -no-boot-anim -accel on -gpu swiftshader_indirect &
|
||||
|
||||
# TODO check if the emulator is already running
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import subprocess as subp
|
||||
from androguard.core.bytecodes.apk import APK
|
||||
|
||||
def parse_logs():
|
||||
with open('./justlisten_logs.txt') as f:
|
||||
print(f.read())
|
||||
|
||||
def print_logs():
|
||||
f = open("justlisten_logs.txt", "w")
|
||||
subp.call(["adb", "logcat", "-c"])
|
||||
try:
|
||||
subp.call(["adb", "logcat", "-s", "MOBIOTSEC"], stdout=f, timeout=3)
|
||||
except subp.TimeoutExpired:
|
||||
parse_logs()
|
||||
|
||||
def launch_app(apk):
|
||||
print("Lauching the app")
|
||||
mainactivity = "{}/{}".format(apk.get_package(), apk.get_main_activity())
|
||||
os.system("adb shell am start -n {act}".format(act=mainactivity))
|
||||
|
||||
def uninstall(apk):
|
||||
if (os.system("adb shell pm list packages | grep {package}".format(package=apk.get_package())) == 0):
|
||||
print("Uninstalling the app")
|
||||
subp.call(["adb", "uninstall", apk.get_package()], stdout=subp.DEVNULL)
|
||||
|
||||
def install(apk):
|
||||
print("Installing the app")
|
||||
while True:
|
||||
try:
|
||||
os.system("adb install -g {apk}".format(apk=apk.get_filename()))
|
||||
break
|
||||
except subp.CalledProcessError as err:
|
||||
print('[!] install failed')
|
||||
print(err)
|
||||
print('[!] retrying')
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("victimapp_apk_path", help="path to the victim app apk file")
|
||||
parser.add_argument("malapp_apk_path", help="path to the malicious app apk file")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
def main(args):
|
||||
print("Lauching the emulator")
|
||||
os.system("~/Android/Sdk/emulator/emulator -avd mobiotsec -no-audio -no-boot-anim -accel on -gpu swiftshader_indirect &")
|
||||
time.sleep(3)
|
||||
victimApk = APK(args.victimapp_apk_path)
|
||||
malApk = APK(args.malapp_apk_path)
|
||||
uninstall(victimApk)
|
||||
install(victimApk)
|
||||
uninstall(malApk)
|
||||
install(malApk)
|
||||
launch_app(malApk)
|
||||
time.sleep(2)
|
||||
launch_app(victimApk)
|
||||
print_logs()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(parse_args())
|
||||
8
mobiotsec7justlisten/justlisten/justlisten_logs.txt
Normal file
8
mobiotsec7justlisten/justlisten/justlisten_logs.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
--------- beginning of main
|
||||
--------- beginning of system
|
||||
03-25 09:22:06.739 8435 8435 E MOBIOTSEC: Hello and welcome!
|
||||
03-25 09:22:09.018 8474 8474 E MOBIOTSEC: victimapp:: onCreate
|
||||
03-25 09:22:09.018 8474 8474 E MOBIOTSEC: victimapp:: setting the flag
|
||||
03-25 09:22:09.022 8435 8435 E MOBIOTSEC: YESS: victim.app.FLAG_ANNOUNCEMENT
|
||||
03-25 09:22:09.022 8435 8435 E MOBIOTSEC: FLAG{carpe_diem}
|
||||
03-25 09:22:09.022 8474 8474 E MOBIOTSEC: victimapp:: broadcasting the flag
|
||||
BIN
mobiotsec7justlisten/justlisten/victim.apk
Normal file
BIN
mobiotsec7justlisten/justlisten/victim.apk
Normal file
Binary file not shown.
Reference in New Issue
Block a user