Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Now I build a Python script to execute automaticaly a dynamic analysis on apk and I block because I use this library and call objection. When I run my script, the objection command creates an inst...
#5: Post edited
Objection CLI - SVM Conception - Freezing prompt
Now I build a Python script to execute automaticaly a dynamic analysis on apk and I block because I use [this library](https://github.com/sensepost/objection and call objection).- When I run my script, the `objection` command creates an instruction on my script and I can't execude the remaining code because this CLI command waits for an instruction. But I should generate activity using monkey runner when this command is active.
- I tried with `subprocess.run`, `popen` and `thread` and I have the same result each time. Do you have a suggestion to solve this?
- That's what my console shows:
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
- My code:
- ```python
- import threading
- from numpy import string_
- import virtualbox
- from androguard.core.bytecodes import apk
- from linux_version.StaticForecasting import StaticForecasting
- from linux_version.TargetPoint import TargetPoint
- from objection import *
- import sys
- import subprocess
- import os
- analyse = StaticForecasting()
- class DynamicTestControler():
- vbox = virtualbox.VirtualBox()
- session = virtualbox.Session()
- statement = {"VMCloned" : False, "VMClonedRuning" : False, "VMClonedDeleted" : False}
- virtualMachine = {"Name" : 'Android-V9-V2'}
- classTargeted = []
- objectionParseReport = []
- objectionReport = []
- verif = {"InstallAPP" : False, "ConnectFrida" : False}
- def __init__(self) -> None:
- #Validation faites
- #Récupération des classes à interroger
- data = open("/opt/Plateforme/linux_version/analysetmp/classlist_targetable.txt" , "r")
- for i in data.readlines():
- self.classTargeted.append(i)
- pass
- def runVM(self):
- #Validation faites
- #Intégration avec la librairie virtualbox
- machine = self.vbox.find_machine(self.virtualMachine["Name"])
- progress = machine.launch_vm_process(self.session, "gui", [])
- progress.wait_for_completion()
- return print("L'instance a été démarrée")
- def stopVM(self):
- #Validation faites
- #Permet d'éteindre l'instance de virtual de box
- self.session.console.power_down()
- return print("L'instance a été arrêtée")
- def install_app(self, analysestat:StaticForecasting):
- #Validation faites
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd2 = ["adb", "install", analysestat.apkChemin]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- self.verif["InstallAPP"] = True
- pass
- def fridav2(self):
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["frida-ps" , "-U"]
- subprocess.run([cmd[0],cmd[1]],shell=False)
- self.verif["ConnectFrida"] = True
- pass
- def connect_frida(self):
- #Validation faites
- #Attention faire cette installation pour adb sudo apt-get install android-tools-adb android-tools-fastboot adb
- cmd1 = ["adb", "connect", "192.168.1.20"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["adb", "push", "/opt/Plateforme/linux_version/tools/fridaserver/frida_server", "/data/local/tmp"]
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3]])
- cmd2 = ["adb", 'shell', "chmod 755 /data/local/tmp/frida_server"]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- cmd3 = ["adb", "shell", "su root /data/local/tmp/frida_server &"]
- subprocess.run([cmd3[0],cmd3[1],cmd3[2]],shell=False)
- #cmd5 = ["frida", "-U", "-f", analysestat.apkNamePackage] #Facultatif car utilisation d'objection à conserver pour la thèse
- #subprocess.run([cmd5[0],cmd5[1],cmd5[2],cmd5[3]])
- self.verif["ConnectFrida"] = True
- pass
- def run_objection(self, analysestat:StaticForecasting,classetargeted):
- #Validation faites
- #Passage par le CLI
- #Initialiser la séquence d'écoute avec objection
- apk_packagename = analysestat.apkNamePackage
- #Récupération et clean du nom de classe
- tmp = classetargeted.replace("/",".")
- class_targeted = tmp[1:]
- nomficher = "/opt/Plateforme/linux_version/analysetmp/" + class_targeted + "_result.txt"
- self.objectionReport.append(nomficher)
- filetemp = open(nomficher, "w+")
- cmdobj = "'" + "android hooking watch class " + str(class_targeted) + " --dump-args --dump-backtrace --dump-return" + "'"
- tmpcpm = "objection --gadget " + apk_packagename + " explore --quiet --startup-command " + cmdobj #+ " &"
- cmd = ["su" ,"-c", tmpcpm]
- cmd2= ["objection", "--gadget", apk_packagename,"explore", "--startup-command", cmdobj]
- z = subprocess.Popen([cmd[0],cmd[1],cmd[2]],stdout=filetemp)
- filetemp.close()
- #subprocess.run(["rm opt/Plateforme/linux_version/driven/tmp"])
- return z.pid
- def run_monkeyrunner(self, analysestat:StaticForecasting):
- #Validation faites
- apk_packagename = analysestat.apkNamePackage
- cmd = ["adb", "shell", "monkey", "-p", apk_packagename, "-v", "500" ] #Pist add -pct-syskeys
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6]])
- return print("L'activité de test a été générée !")
- def convert_objection_report(self,fichier:str):
- #Validation Faites
- #Récupération des données
- fichierStockage = fichier.replace("_result.txt", "_converted.txt")
- self.objectionParseReport.append(fichierStockage)
- data = open(fichier, "r")
- contenu = data.readlines()
- data.close()
- data2 = open(fichierStockage, "w+")
- for i in contenu :
- if(i[0:9] == "(agent) ["):
- appeltmp = i[(i.find("d",0)+2):]
- tmp = i.split(" ")
- line_convert = tmp[0] + ";" + tmp[1] + ";" + appeltmp
- data2.write(line_convert)
- data2.close()
- pass
- pass
- ```
- Now I build a Python script to execute automaticaly a dynamic analysis on apk and I block because I use [this library](https://github.com/sensepost/objection) and call `objection`.
- When I run my script, the `objection` command creates an instruction on my script and I can't execude the remaining code because this CLI command waits for an instruction. But I should generate activity using monkey runner when this command is active.
- I tried with `subprocess.run`, `popen` and `thread` and I have the same result each time. Do you have a suggestion to solve this?
- That's what my console shows:
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
- My code:
- ```python
- import threading
- from numpy import string_
- import virtualbox
- from androguard.core.bytecodes import apk
- from linux_version.StaticForecasting import StaticForecasting
- from linux_version.TargetPoint import TargetPoint
- from objection import *
- import sys
- import subprocess
- import os
- analyse = StaticForecasting()
- class DynamicTestControler():
- vbox = virtualbox.VirtualBox()
- session = virtualbox.Session()
- statement = {"VMCloned" : False, "VMClonedRuning" : False, "VMClonedDeleted" : False}
- virtualMachine = {"Name" : 'Android-V9-V2'}
- classTargeted = []
- objectionParseReport = []
- objectionReport = []
- verif = {"InstallAPP" : False, "ConnectFrida" : False}
- def __init__(self) -> None:
- #Validation faites
- #Récupération des classes à interroger
- data = open("/opt/Plateforme/linux_version/analysetmp/classlist_targetable.txt" , "r")
- for i in data.readlines():
- self.classTargeted.append(i)
- pass
- def runVM(self):
- #Validation faites
- #Intégration avec la librairie virtualbox
- machine = self.vbox.find_machine(self.virtualMachine["Name"])
- progress = machine.launch_vm_process(self.session, "gui", [])
- progress.wait_for_completion()
- return print("L'instance a été démarrée")
- def stopVM(self):
- #Validation faites
- #Permet d'éteindre l'instance de virtual de box
- self.session.console.power_down()
- return print("L'instance a été arrêtée")
- def install_app(self, analysestat:StaticForecasting):
- #Validation faites
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd2 = ["adb", "install", analysestat.apkChemin]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- self.verif["InstallAPP"] = True
- pass
- def fridav2(self):
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["frida-ps" , "-U"]
- subprocess.run([cmd[0],cmd[1]],shell=False)
- self.verif["ConnectFrida"] = True
- pass
- def connect_frida(self):
- #Validation faites
- #Attention faire cette installation pour adb sudo apt-get install android-tools-adb android-tools-fastboot adb
- cmd1 = ["adb", "connect", "192.168.1.20"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["adb", "push", "/opt/Plateforme/linux_version/tools/fridaserver/frida_server", "/data/local/tmp"]
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3]])
- cmd2 = ["adb", 'shell', "chmod 755 /data/local/tmp/frida_server"]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- cmd3 = ["adb", "shell", "su root /data/local/tmp/frida_server &"]
- subprocess.run([cmd3[0],cmd3[1],cmd3[2]],shell=False)
- #cmd5 = ["frida", "-U", "-f", analysestat.apkNamePackage] #Facultatif car utilisation d'objection à conserver pour la thèse
- #subprocess.run([cmd5[0],cmd5[1],cmd5[2],cmd5[3]])
- self.verif["ConnectFrida"] = True
- pass
- def run_objection(self, analysestat:StaticForecasting,classetargeted):
- #Validation faites
- #Passage par le CLI
- #Initialiser la séquence d'écoute avec objection
- apk_packagename = analysestat.apkNamePackage
- #Récupération et clean du nom de classe
- tmp = classetargeted.replace("/",".")
- class_targeted = tmp[1:]
- nomficher = "/opt/Plateforme/linux_version/analysetmp/" + class_targeted + "_result.txt"
- self.objectionReport.append(nomficher)
- filetemp = open(nomficher, "w+")
- cmdobj = "'" + "android hooking watch class " + str(class_targeted) + " --dump-args --dump-backtrace --dump-return" + "'"
- tmpcpm = "objection --gadget " + apk_packagename + " explore --quiet --startup-command " + cmdobj #+ " &"
- cmd = ["su" ,"-c", tmpcpm]
- cmd2= ["objection", "--gadget", apk_packagename,"explore", "--startup-command", cmdobj]
- z = subprocess.Popen([cmd[0],cmd[1],cmd[2]],stdout=filetemp)
- filetemp.close()
- #subprocess.run(["rm opt/Plateforme/linux_version/driven/tmp"])
- return z.pid
- def run_monkeyrunner(self, analysestat:StaticForecasting):
- #Validation faites
- apk_packagename = analysestat.apkNamePackage
- cmd = ["adb", "shell", "monkey", "-p", apk_packagename, "-v", "500" ] #Pist add -pct-syskeys
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6]])
- return print("L'activité de test a été générée !")
- def convert_objection_report(self,fichier:str):
- #Validation Faites
- #Récupération des données
- fichierStockage = fichier.replace("_result.txt", "_converted.txt")
- self.objectionParseReport.append(fichierStockage)
- data = open(fichier, "r")
- contenu = data.readlines()
- data.close()
- data2 = open(fichierStockage, "w+")
- for i in contenu :
- if(i[0:9] == "(agent) ["):
- appeltmp = i[(i.find("d",0)+2):]
- tmp = i.split(" ")
- line_convert = tmp[0] + ";" + tmp[1] + ";" + appeltmp
- data2.write(line_convert)
- data2.close()
- pass
- pass
- ```
#4: Post edited
Objection CLI - SVM Conception - Freezing prompt
Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection.When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active.I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ?You show the in this extract of prompt- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
Thanks for all,
- Now I build a Python script to execute automaticaly a dynamic analysis on apk and I block because I use [this library](https://github.com/sensepost/objection and call objection).
- When I run my script, the `objection` command creates an instruction on my script and I can't execude the remaining code because this CLI command waits for an instruction. But I should generate activity using monkey runner when this command is active.
- I tried with `subprocess.run`, `popen` and `thread` and I have the same result each time. Do you have a suggestion to solve this?
- That's what my console shows:
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
- My code:
- ```python
- import threading
- from numpy import string_
- import virtualbox
- from androguard.core.bytecodes import apk
- from linux_version.StaticForecasting import StaticForecasting
- from linux_version.TargetPoint import TargetPoint
- from objection import *
- import sys
- import subprocess
- import os
- analyse = StaticForecasting()
- class DynamicTestControler():
- vbox = virtualbox.VirtualBox()
- session = virtualbox.Session()
- statement = {"VMCloned" : False, "VMClonedRuning" : False, "VMClonedDeleted" : False}
- virtualMachine = {"Name" : 'Android-V9-V2'}
- classTargeted = []
- objectionParseReport = []
- objectionReport = []
- verif = {"InstallAPP" : False, "ConnectFrida" : False}
- def __init__(self) -> None:
- #Validation faites
- #Récupération des classes à interroger
- data = open("/opt/Plateforme/linux_version/analysetmp/classlist_targetable.txt" , "r")
- for i in data.readlines():
- self.classTargeted.append(i)
- pass
- def runVM(self):
- #Validation faites
- #Intégration avec la librairie virtualbox
- machine = self.vbox.find_machine(self.virtualMachine["Name"])
- progress = machine.launch_vm_process(self.session, "gui", [])
- progress.wait_for_completion()
- return print("L'instance a été démarrée")
- def stopVM(self):
- #Validation faites
- #Permet d'éteindre l'instance de virtual de box
- self.session.console.power_down()
- return print("L'instance a été arrêtée")
- def install_app(self, analysestat:StaticForecasting):
- #Validation faites
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd2 = ["adb", "install", analysestat.apkChemin]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- self.verif["InstallAPP"] = True
- pass
- def fridav2(self):
- cmd1 = ["adb", "connect", "192.168.56.101"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["frida-ps" , "-U"]
- subprocess.run([cmd[0],cmd[1]],shell=False)
- self.verif["ConnectFrida"] = True
- pass
- def connect_frida(self):
- #Validation faites
- #Attention faire cette installation pour adb sudo apt-get install android-tools-adb android-tools-fastboot adb
- cmd1 = ["adb", "connect", "192.168.1.20"]
- subprocess.run([cmd1[0],cmd1[1],cmd1[2]])
- cmd = ["adb", "push", "/opt/Plateforme/linux_version/tools/fridaserver/frida_server", "/data/local/tmp"]
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3]])
- cmd2 = ["adb", 'shell', "chmod 755 /data/local/tmp/frida_server"]
- subprocess.run([cmd2[0],cmd2[1],cmd2[2]])
- cmd3 = ["adb", "shell", "su root /data/local/tmp/frida_server &"]
- subprocess.run([cmd3[0],cmd3[1],cmd3[2]],shell=False)
- #cmd5 = ["frida", "-U", "-f", analysestat.apkNamePackage] #Facultatif car utilisation d'objection à conserver pour la thèse
- #subprocess.run([cmd5[0],cmd5[1],cmd5[2],cmd5[3]])
- self.verif["ConnectFrida"] = True
- pass
- def run_objection(self, analysestat:StaticForecasting,classetargeted):
- #Validation faites
- #Passage par le CLI
- #Initialiser la séquence d'écoute avec objection
- apk_packagename = analysestat.apkNamePackage
- #Récupération et clean du nom de classe
- tmp = classetargeted.replace("/",".")
- class_targeted = tmp[1:]
- nomficher = "/opt/Plateforme/linux_version/analysetmp/" + class_targeted + "_result.txt"
- self.objectionReport.append(nomficher)
- filetemp = open(nomficher, "w+")
- cmdobj = "'" + "android hooking watch class " + str(class_targeted) + " --dump-args --dump-backtrace --dump-return" + "'"
- tmpcpm = "objection --gadget " + apk_packagename + " explore --quiet --startup-command " + cmdobj #+ " &"
- cmd = ["su" ,"-c", tmpcpm]
- cmd2= ["objection", "--gadget", apk_packagename,"explore", "--startup-command", cmdobj]
- z = subprocess.Popen([cmd[0],cmd[1],cmd[2]],stdout=filetemp)
- filetemp.close()
- #subprocess.run(["rm opt/Plateforme/linux_version/driven/tmp"])
- return z.pid
- def run_monkeyrunner(self, analysestat:StaticForecasting):
- #Validation faites
- apk_packagename = analysestat.apkNamePackage
- cmd = ["adb", "shell", "monkey", "-p", apk_packagename, "-v", "500" ] #Pist add -pct-syskeys
- subprocess.run([cmd[0],cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6]])
- return print("L'activité de test a été générée !")
- def convert_objection_report(self,fichier:str):
- #Validation Faites
- #Récupération des données
- fichierStockage = fichier.replace("_result.txt", "_converted.txt")
- self.objectionParseReport.append(fichierStockage)
- data = open(fichier, "r")
- contenu = data.readlines()
- data.close()
- data2 = open(fichierStockage, "w+")
- for i in contenu :
- if(i[0:9] == "(agent) ["):
- appeltmp = i[(i.find("d",0)+2):]
- tmp = i.split(" ")
- line_convert = tmp[0] + ";" + tmp[1] + ";" + appeltmp
- data2.write(line_convert)
- data2.close()
- pass
- pass
- ```
#3: Post edited
Closed. This question needs details or clarity. It is not currently accepting answers.Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one.Closed 4 hours ago.(Private feedback for you)- Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection.
- When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active.
- I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ?
- You show the in this extract of prompt
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
996 ueventd1047 v86d1004 vndbinder1060 vold1377 webview_zygote1101 wificond1068 zygotealready connected to 192.168.56.101:5555 Success Mot de passe : ...apanactivator.android.jasensei on (Android-x86: 9) [usb] # bash arg: -p bash arg: com.japanactivator.android.jasensei bash arg: -v bash arg: 500- Thanks for all,
- Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection.
- When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active.
- I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ?
- You show the in this extract of prompt
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
- Thanks for all,
#2: Post edited
- Closed. This question needs details or clarity. It is not currently accepting answers.
- Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one.
- Closed 4 hours ago.
- (Private feedback for you)
- Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection.
- When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active.
- I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ?
- You show the in this extract of prompt
- 996 ueventd
- 1047 v86d
- 1004 vndbinder
- 1060 vold
- 1377 webview_zygote
- 1101 wificond
- 1068 zygote
- already connected to 192.168.56.101:5555 Success Mot de passe : ...apanactivator.android.jasensei on (Android-x86: 9) [usb] # bash arg: -p bash arg: com.japanactivator.android.jasensei bash arg: -v bash arg: 500
- Thanks for all,
- Closed. This question needs details or clarity. It is not currently accepting answers.
- Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one.
- Closed 4 hours ago.
- (Private feedback for you)
- Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection.
- When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active.
- I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ?
- You show the in this extract of prompt
- ![Console Extract](https://software.codidact.com/uploads/CeYXn8qZpByYEVd4U6zaVf3E)
- 996 ueventd
- 1047 v86d
- 1004 vndbinder
- 1060 vold
- 1377 webview_zygote
- 1101 wificond
- 1068 zygote
- already connected to 192.168.56.101:5555 Success Mot de passe : ...apanactivator.android.jasensei on (Android-x86: 9) [usb] # bash arg: -p bash arg: com.japanactivator.android.jasensei bash arg: -v bash arg: 500
- Thanks for all,
#1: Initial revision
Objection CLI - SVM Conception - Freezing prompt
Closed. This question needs details or clarity. It is not currently accepting answers. Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one. Closed 4 hours ago. (Private feedback for you) Now I build a python script to execute automaticaly a dynamic analysis on apk and I block because I use library available here https://github.com/sensepost/objection and call objection. When I run my script objection command create an instruction on my script and I can't execude the remaining code because this CLI command wait an instruction. But I should generate activity using monkey runner when this command is active. I try with some possibility (subprocess.run, popen or thread) and I have the same result each time. Do you have a suggestion to solve this ? You show the in this extract of prompt 996 ueventd 1047 v86d 1004 vndbinder 1060 vold 1377 webview_zygote 1101 wificond 1068 zygote already connected to 192.168.56.101:5555 Success Mot de passe : ...apanactivator.android.jasensei on (Android-x86: 9) [usb] # bash arg: -p bash arg: com.japanactivator.android.jasensei bash arg: -v bash arg: 500 Thanks for all,