Coder Social home page Coder Social logo

h2so4t / ares Goto Github PK

View Code? Open in Web Editor NEW
64.0 6.0 19.0 20.57 MB

Black-box tool that uses Deep Reinforcement Learning to test and explore Android applications

License: GNU Affero General Public License v3.0

Python 100.00%
android android-testing appium-android black-box-testing appium deep-learning reinforcement-learning deep-reinforcement-learning pytorch applesilicon

ares's People

Contributors

claudiugeorgiu avatar h2so4t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ares's Issues

Evaluate a trained model

Hello!
I have a question.

During the implementation of ARES, did you ever think of trying to implement a way to evaluate an already trained model, and not just continue with the training?
Since in your paper I don't see it mentioned as a limitation.
Besides, at this moment I am trying to implement it, but I have been stuck because of a limitation that may be Stable Baselines3 has to change the action space each time you try to predict an action.

Like this

env.action_space.high[0] = env.env.ACTION_SPACE
logger.info("Loading policy...")
model = SAC.load(os.path.splitext(file_path)[0], env)

obs = env.reset()
for i in range(10):
    action, _states = model.predict(obs)
    obs, rewards, dones, info = env.step(action)

As you can see, the predict method only receives the observation, not the environment, so modifying the action space is useless.

I just wanted to know if maybe you who developed this tool have any idea or clarification that you can give me, I would appreciate it. πŸ˜‰

Some questions about running

Hi, thanks for your good job.
I use the instruction:
"python parallel_exec.py --instr_jacoco --real_device --udids "e62b6cf8" --list_device "qualcomm1" --appium_ports "4270" --android_ports "5554" --path "D:\apk/" --timer 70 --rotation --internet --platform_version 12.0 --iterations 2 --algo SAC --timesteps 5000 --trials_per_app 1"
But it come into errors about
"ERROR: The process "node.exe" not found.
Traceback (most recent call last):
File "parallel_exec.py", line 132, in
main()
File "parallel_exec.py", line 126, in main
processes.append(subprocess.Popen(cmd))
File "D:\Python3\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "D:\Python3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified "
Do you konw why is that ? Thanks a lot.

Adb error - failed to access

Hello, I am a Macbook pro owner with an Apple Silicon processor. I have tried to test ARES with various apks using Android Studio and an emulator with Android 9 API 28, but the tool fails to create files with Coverage information as the folder is empty.
When running the tool, I get the following error:
Broadcasting: Intent { act=intent.END_COVERAGE flg=0x400000 pkg=com.shazam.android } Broadcast completed: result=0 adb: error: failed to access 'path/to/ARES/rl_interaction/coverage/shazam-13-27-0-230420/SAC/0/18.ec': No such file or directory
The command I use to launch the tool is as follows:
python3 parallel_exec.py --instr_jacoco --list_devices "emulator-5554" --appium_ports "4270" --android_ports "5554" --path "apps" --timer 60 --internet --emu headless --platform_version 9.0 --iterations 1 --algo SAC --timesteps 1000 --trials_per_app 1 --save_policy

I would appreciate it if you could help me.

Thank you vary much.

Quick question about SACExploration.py

The ML model checks the dimension only at the beginning, and then it will never use the action_space variable anymore. This means that the output of the ML model is always in the range 0:30.
But if you have 3 buttons in Activity Something.Main, it is not useful to generate a value greater than 2 (i.e., 0, 1, 2).
So I'm just using the action_space variable to save the actual action space dimension.

Originally posted by @H2SO4T in #8 (comment)

ARES seems blocked

Hi @H2SO4T ,
First of all thanks for the very interesting and useful project.

However, after your update, it stopped working on some applications.

My setup is based on python3.9 and a Macbook PRO M1 Max with 32GB of RAM.

I have tested the tool with different applications and it works perfectly.
However, with some apps, it gets stuck and doesn't seem to find and perform the actions to do.

Can I upload one of the apps that give me this kind of problem?

about the observation

It seems that you use activity index as the obervation code, I think there are other imformation we need to feed to the agent. That will get a better result.
The amount of information is too little, simple Q learning feels like enough.

Crash after the error "type numpy.ndarray doesn't define __round__ method"

Hi, I use the default settings to test the APK
org.woheller69.spritpreise_18.apk.zip

The script I used is:

python3 parallel_exec.py --list_device AVDName --appium_ports APPIUMNAME --android_ports ANDROIDPORT --path APPDIR --timer 70 --platform_version 8.1 --algo SAC --timesteps 5000 --trials_per_app 3

The test performs well at the beginning. However, the test speed rush up and suddenly output the error

type numpy.ndarray doesn't define __round__ method
OK: killing emulator, bye bye

Then the emulator restarts again.

Would you please kindly check what's wrong with it?

Thank you very much!

Problem when running ARES

Hello,

I tried to test ARES with Ubuntu 20.04 and an emulator with Android 10.0 API 29 but failed. When running the tool, I get the following error:
Broadcasting: Intent { act=intent.END_COVERAGE flg=0x400000 pkg=com.shazam.android } Broadcast completed: result=0 adb: error: failed to access 'path/to/ARES/rl_interaction/coverage/shazam-13-27-0-230420/SAC/0/18.ec': No such file or directory

node: no process found
INFO | Android emulator version 32.1.11.0 (build_id 9536276) (CL:N/A)
INFO | Found systemPath /home/zhliao/Android/Sdk/system-images/android-29/google_apis/x86/
INFO | Crashreporting disabled, not reporting crashes.
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | Please update the emulator to one that supports the feature(s): Vulkan
WARNING | cannot add library /home/zhliao/Android/Sdk/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO | added library /home/zhliao/Android/Sdk/emulator/lib64/vulkan/libvulkan.so
INFO | Setting display: 0 configuration to: 1080x2400, dpi: 420x420
INFO | Cold boot: requested by the user
cmd: Can't find service: settings
cmd: Can't find service: settings
cmd: Can't find service: settings
2023-05-17 03:28:26.181 | INFO | main:main:122 - now testing: com.willianveiga.countdowntimer_4

2023-05-17 03:28:26.197 | INFO | main:main:137 - app: com.willianveiga.countdowntimer_4, test 0 of 1 starting
Performing Streamed Install
adb: failed to install ./apks/com.willianveiga.countdowntimer_4.apk: cmd: Can't find service: package
2023-05-17 03:28:26.400 | DEBUG | rl_interaction.RL_application_env:init:129 - ./apks/com.willianveiga.countdowntimer_4.apk START
2023-05-17 03:28:27.386 | ERROR | main:main:213 - Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/home/zhliao/Android/Sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy'' exited with code 20'; Command output: cmd: Can't find service: settings
cmd: Can't find service: settings
cmd: Can't find service: settings

The command I use to launch the tool is as follows:
python3 parallel_exec.py --instr_jacoco --list_devices "Pixel_6_API_29" --appium_ports "4273" --android_ports "5554" --path "./apks" --timer 60 --rotation --internet --emu headless --platform_version 10.0 --iterations 3 --algo SAC --timesteps 4000 --trials_per_app 3

I use Appium 1.22.3 with Appium-Python-Client 1.0.2, as this post suggested.

Thank you very much for your time.

Some quetions about app experiment

Hi, thanks for your good job.
I have questions about the 'Experimental Results: Study 2' in your paper.
The results are obtained during training or testing? Is it necessary to load the pretrained model to test after training the model?
The results are obtained using one hour or 4000 steps ? And how many steps is runing within one hour in your experiment if the results is obtained using one hour.

I'm trying to use SAC of ARES to test apps(Markor and MicroMathematics).
The first item of action_number is tent always to be zero or one after 1125 steps(generate 45 converage files) .
I use the instruction:
python3 parallel_exec.py --instr_jacoco --list_devices "gtestapi27" --appium_ports "4270" --android_ports "5554" --path "apps" --timer 60 --rotation --internet --emu normal --platform_version 8.1 --iterations 10 --algo SAC --timesteps 5000 --trials_per_app 3
Do you konw why is that ? Thanks a lot.

Cannot start the 'com.android.insecurebankv2' application

android version: 8.1
error happend when I run with the cmd: python test_application.py --instr_emma --appium_port "4723" --android_port "62002" --timer 10 --rotation --internet --emu normal --platform_version "8.1" --iterations 2 --algo random --timesteps 50 --trials_per_app 3 --apps "D:\code\pycharm\gym\test\test_resources\InsecureBankv2.apk" --save_policy

image-20221018212644209

Some questions about RL_application_env.py

Hi, I find self.check_activity() will change the size of self.action_space = spaces.Box() in RL_application_env.py init(). Will it cause wrong action_space size init in the model?

where can I get your app benchmark ?

hi, itβ€˜s quiet a good job! can you share your app benchmark ?
I also try to build app by cosmo, but it didn't work for some android source code.
Github project VinylMusicPlayer is buided success after cosmo, but it didn't generate converge files after using "adb shell am broadcast -p com.poupa.vinylmusicplayer -a intent.END_COVERAGE". Do you know why is that?
Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.