alexal1 / Insomniac

Instagram bot for automated Instagram interaction using Android device via ADB
https://insomniac-bot.com
MIT License
688 stars 159 forks source link

Add feature to log in #164

Open mv-debug opened 3 years ago

mv-debug commented 3 years ago

I use your code within a simulated android environment in docker. It could up automatically till the point of log in in the app. For CD purpose this feature will be nice to automatic log in(also handle multiple accounts in the app make sense). If you want I could create the Dockerfile for this feature.

markbookk commented 3 years ago

What simulated android environment do you have?

mv-debug commented 3 years ago

What simulated android environment do you have?

You can use different devices and different os versions. I used this docker image as a base image: https://github.com/budtmo/docker-android. It worked like a charm on an older laptop with 4 cores and 8gb ram with two android container (for two accounts).

markbookk commented 3 years ago

Thanks for this resource, it looks awesome! I will give it a try.

mv-debug commented 3 years ago

@alexal1 What do you think about the idea to deploy this framework in docker with a ready to go android setup?

mv-debug commented 3 years ago

Thanks for this resource, it looks awesome! I will give it a try.

Do give it a try?

markbookk commented 3 years ago

I just tried it and it looks like it is working but the emulator doesn't have Google Play Store... What did you use to download Instagram app? Also, do you have Discord? I am not sure if we should keep talking about this here as it not the main issue.

future2back commented 3 years ago

@mv-debug Could Could you give more information on how to make it work please?

@markbookk thanks for trying it, when its posible i will give a try! Sharing content here is a good way to everyone learn about it 👍

mv-debug commented 3 years ago

I just tried it and it looks like it is working but the emulator doesn't have Google Play Store... What did you use to download Instagram app? Also, do you have Discord? I am not sure if we should keep talking about this here as it not the main issue.

You could use adb to install an app. And you could download apps on some free platforms. Is it allowed to name it here, I will try: https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/

It is important to use the x86 architecture - if you use docker on amd64 or x86 processor.

I do not have discord, sorry.

mv-debug commented 3 years ago

@mv-debug Could Could you give more information on how to make it work please?

@markbookk thanks for trying it, when its posible i will give a try! Sharing content here is a good way to everyone learn about it +1

I could write down the steps here - if it okay for you.

mv-debug commented 3 years ago

How to:

  1. install docker and adb (https://docs.docker.com/get-docker/, https://developer.android.com/studio/command-line/adb)
  2. Run a container with e.g. docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1
  3. Download Instagram (https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/) app and install via adb install path_to_apk
  4. Log in manually and also search one time to access the permission pop up. These step have to be done manually and these have to be automated - if implemented the whole execution of the remote handling could be done in a cloud and in continuous deployment

I could also provide a video if you are interested.

markbookk commented 3 years ago

I just tried it and it looks like it is working but the emulator doesn't have Google Play Store... What did you use to download Instagram app? Also, do you have Discord? I am not sure if we should keep talking about this here as it not the main issue.

You could use adb to install an app. And you could download apps on some free platforms. Is it allowed to name it here, I will try: https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/

It is important to use the x86 architecture - if you use docker on amd64 or x86 processor.

I do not have discord, sorry.

Cool, thanks! I will give it a try and let you know if it worked. I totally forgot I could add the apps via adb.

future2back commented 3 years ago

@mv-debug thanks, What OS are you using to run it?

mv-debug commented 3 years ago

@mv-debug thanks, What OS are you using to run it?

Hey, I use linux only for development - it is the better platform. But it should also work on windows. If you have got a problem with mac os or windows see: https://github.com/budtmo/docker-android#quick-start

markbookk commented 3 years ago

@mv-debug thanks for the help! I used adb install and it worked.

@future2back I also use Linux (Ubuntu) and I can also vouch that it works good.

mv-debug commented 3 years ago

@mv-debug thanks for the help! I used adb install and it worked.

@future2back I also use Linux (Ubuntu) and I can also vouch that it works good.

I tested it also on a ubuntu machine with 16 cores, with that setup you can run multiple instances of the android simulation (I only test 4 at once). It works like a charm. But it will be nice to implement the login feature.

markbookk commented 3 years ago

@mv-debug Nice! Do you use cloud or local hosting?

mv-debug commented 3 years ago

@mv-debug Nice! Do you use cloud or local hosting?

I tried in a cloud, but you have got manual steps for setup the environment. At the moment I have got a gitlab-runner on my local machine and let it run every hour. Works like charm.

future2back commented 3 years ago

@mv-debug thanks, i will try it here on ubuntu and let you know

mv-debug commented 3 years ago

I think I am going to write an script to setup the environment with uiautomator2.

future2back commented 3 years ago

How to:

1. install docker and adb (**https://docs.docker.com/get-docker/**, **https://developer.android.com/studio/command-line/adb**)

2. Run a container with e.g.  **docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1**

3. Download Instagram (**https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/**) app and install via **adb install path_to_apk**

4. Log in manually and also search one time to access the permission pop up. These step have to be done manually and these have to be automated - if implemented the whole execution of the remote handling could be done in a cloud and in continuous deployment

I could also provide a video if you are interested.

Hello @mv-debug and @markbookk after installing docker (step 1) and added my user to docker group , followed step 2 , after acessing http://myip:6080 i can access it and see a page that has a whale Android Docker, could you describe the steps i should follow to make it works? I m new on Docker, i m sorry!

Thanks a lot.

mv-debug commented 3 years ago

How to:

1. install docker and adb (**https://docs.docker.com/get-docker/**, **https://developer.android.com/studio/command-line/adb**)

2. Run a container with e.g.  **docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1**

3. Download Instagram (**https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/**) app and install via **adb install path_to_apk**

4. Log in manually and also search one time to access the permission pop up. These step have to be done manually and these have to be automated - if implemented the whole execution of the remote handling could be done in a cloud and in continuous deployment

I could also provide a video if you are interested.

Hello @mv-debug and @markbookk after installing docker (step 1) and added my user to docker group , followed step 2 , after acessing http://myip:6080 i can access it and see a page that has a whale Android Docker, could you describe the steps i should follow to make it works? I m new on Docker, i m sorry!

Thanks a lot.

Try in a console adb devices and check if you see something like this emulator-5554. If yes, you could install the downloaded app via adb install path_to_apk. The use the browser to log in. That's all.

future2back commented 3 years ago

How to:

1. install docker and adb (**https://docs.docker.com/get-docker/**, **https://developer.android.com/studio/command-line/adb**)

2. Run a container with e.g.  **docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1**

3. Download Instagram (**https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-139-0-0-33-121-release/instagram-139-0-0-33-121-12-android-apk-download/**) app and install via **adb install path_to_apk**

4. Log in manually and also search one time to access the permission pop up. These step have to be done manually and these have to be automated - if implemented the whole execution of the remote handling could be done in a cloud and in continuous deployment

I could also provide a video if you are interested.

Hello @mv-debug and @markbookk after installing docker (step 1) and added my user to docker group , followed step 2 , after acessing http://myip:6080 i can access it and see a page that has a whale Android Docker, could you describe the steps i should follow to make it works? I m new on Docker, i m sorry! Thanks a lot.

Try in a console adb devices and check if you see something like this emulator-5554. If yes, you could install the downloaded app via adb install path_to_apk. The use the browser to log in. That's all.

Hey @mv-debug thanks for replying, there is no emulator listed on my adb, i runned docker with the same line you listed on step 2! Is it ok?

Thanks

markbookk commented 3 years ago

@future2back are you using virtualization for the host OS of Docker?

future2back commented 3 years ago

@future2back are you using virtualization for the host OS of Docker?

No, I m using ubuntu on a physical computer to run docker.... I tried rebooting my computer, after it

i had to remove --name android-container from this line:

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

so i started docker image with this line:

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" budtmo/docker-android-x86-8.1

is it ok? I m sorry, thanks for for taking your time.

markbookk commented 3 years ago

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

I use this line and it works for me.

Why do you say you had to remove --name android-container? Any error occurred or anything pops up that you can share?

future2back commented 3 years ago

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

I use this line and it works for me.

Why do you say you had to remove --name android-container? Any error occurred or anything pops up that you can share?

heyy @markbookk i had no problem using this line at first time, as the emulator did not appear in the list of devices i restarted the computer, so, do i have to open it again? then if i try

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

i get this error message:

docker: Error response from daemon: Conflict. The container name "/android-container" is already in use by container "e8c40ee99723e797c3e36b1cebc3fa330705de25bca47fff153b8a3032eacfd8". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

thats why i removed --name android-container to "reopen" the image. So i could reopen it but still not appear in the list of devices when i use adb devices

markbookk commented 3 years ago

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/

You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container.

In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

mv-debug commented 3 years ago

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/

You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container.

In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

@future2back Do you see an device under localhost:6080? Something like this. Screenshot_20201111-191718

If you Plug in an real device to the pc, do you see this one via adb? Maybe some udev rules cause problems. Try to use the original ubuntu package (sudo apt install adb), within this package the correct udev rules are rolled out..

future2back commented 3 years ago

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/

You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container.

In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

Thanks for explain me that!

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/ You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container. In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

@future2back Do you see an device under localhost:6080? Something like this. Screenshot_20201111-191718

If you Plug in an real device to the pc, do you see this one via adb? Maybe some udev rules cause problems. Try to use the original ubuntu package (sudo apt install adb), within this package the correct udev rules are rolled out..

dock

There is no android phone like yours. Thats why i asked if the line on step 2 is correct.

If i right click on it:

dock2

Yes i can see device to the pc on using adb.

Any idea? Thanks @markbookk

mv-debug commented 3 years ago

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/ You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container. In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

Thanks for explain me that!

That error means that you already have a container running. You can do docker ps -a to list all containers (not just the ones that are running). More information here: https://docs.docker.com/engine/reference/commandline/ps/ You don't have to create a new docker container every time. You just need to start the container you already created with docker start {name} or in your case docker start android-container. In regards to the device not showing on adb devices, I am not sure what the problem may be but it doesn't seem to be a problem with the "docker-android" as it works fine for me. I think your docker container isn't fully running, as you said you only see the "whale android docker" page and you are supposed to be seeing the android emulator.

@future2back Do you see an device under localhost:6080? Something like this. Screenshot_20201111-191718 If you Plug in an real device to the pc, do you see this one via adb? Maybe some udev rules cause problems. Try to use the original ubuntu package (sudo apt install adb), within this package the correct udev rules are rolled out..

dock

There is no android phone like yours. Thats why i asked if the line on step 2 is correct.

If i right click on it:

dock2

Yes i can see device to the pc on using adb.

Any idea? Thanks @markbookk

What kind of pc or laptop do you have? Sometime a start of an stopped container end in your situation. But a fresh container looks like my pic. Maybe some virtualization setting are not enabled or you do not have enough power for emulation.

future2back commented 3 years ago
Kernel: 5.4.0-52-generic x86_64 bits: 64 Desktop: Gnome 3.36.4 
           Distro: Ubuntu 20.04.1 LTS (Focal Fossa) 
Machine:   Type: Laptop System: LENOVO product: VIUS3 v: Lenovo IdeaPad S400 serial: <superuser/root required> 
           Mobo: LENOVO  STD SGL serial: <superuser/root required> UEFI [Legacy]: LENOVO 
           date: 02/21/2013 

CPU:  Topology: Dual Core model: Intel Celeron 1007U bits: 64 type: MCP L2 cache: 2048 KiB 
Speed: 798 MHz min/max: 800/1500 MHz Core speeds (MHz): 1: 798 2: 798 
Graphics:  Device-1: Intel 3rd Gen Core processor Graphics driver: i915 v: kernel 

Memory: 1.75 GiB

I m trying it on an old computer, @markbookk is it enought? How can i delete all images and try start again? Is there anyway to show logs of this container to check is there any problem with it?

mv-debug commented 3 years ago
Kernel: 5.4.0-52-generic x86_64 bits: 64 Desktop: Gnome 3.36.4 
           Distro: Ubuntu 20.04.1 LTS (Focal Fossa) 
Machine:   Type: Laptop System: LENOVO product: VIUS3 v: Lenovo IdeaPad S400 serial: <superuser/root required> 
           Mobo: LENOVO  STD SGL serial: <superuser/root required> UEFI [Legacy]: LENOVO 
           date: 02/21/2013 

CPU:  Topology: Dual Core model: Intel Celeron 1007U bits: 64 type: MCP L2 cache: 2048 KiB 
Speed: 798 MHz min/max: 800/1500 MHz Core speeds (MHz): 1: 798 2: 798 
Graphics:  Device-1: Intel 3rd Gen Core processor Graphics driver: i915 v: kernel 

Memory: 1.75 GiB

I m trying it on an old computer, @markbookk is it enought? How can i delete all images and try start again? Is there anyway to show logs of this container to check is there any problem with it?

I thing this is simply not enough power.

markbookk commented 3 years ago

@future2back I think it doesn't have to do with the resources of your computer. If it were the resources, I think it would at least start up and be very slow or give you an error message accordingly. I think it has to do with the virtualization. I suggest looking up online how you can enable virtualization in your BIOS and try that. If that isn't the case, honestly I am not sure how I could help you.

To delete a container or any similar docker related commands, I suggest you just read the same website I had sent previously and search for what you want there. Example, you mentioned you wanted to remove a container so that would be https://docs.docker.com/engine/reference/commandline/rm/ .

mv-debug commented 3 years ago

@future2back Maybe you take a look at this site https://2nwiki.2n.cz/pages/viewpage.action?pageId=75202968

future2back commented 3 years ago

@mv-debug @markbookk thanks! You both are correct. After enabling virtualization in my BIOS i m able to see the android phone, but seems like that this computer dont have enought resources to run it. as you can see:

dock3

I will try on better computer and let you know! Do you think that is it possible on Macbook or Windows?

For creating different containers do i have to change ports and name? Is there any matrix to this ports or any can be used? on this line for example:

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

have to change:

-p 6080:6080 What ports can be used here?

--name android-container Here any name can be used

then start the container by

docker start {name}

By the way, what is the gain using the docker instead of an emulator? I see that container resources should be lighter then emulators, but is it very significant? For example, i can run 4 emulators at same time using Windows and ldplayer, memu or any kind of android emulator, but if i start the 5 one my computer get unworkable. If i use the same computer resources but on Ubuntu with containers, could I have more emulators then 4? If yes, could you say in numbers of devices? What are the other benefits of using Insomniac on a container?

Thank you a lot guys!!!

mv-debug commented 3 years ago

@mv-debug @markbookk thanks! You both are correct. After enabling virtualization in my BIOS i m able to see the android phone, but seems like that this computer dont have enought resources to run it. as you can see:

dock3

I will try on better computer and let you know! Do you think that is it possible on Macbook or Windows?

For creating different containers do i have to change ports and name? Is there any matrix to this ports or any can be used? on this line for example:

docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

have to change:

-p 6080:6080 What ports can be used here?

--name android-container Here any name can be used

then start the container by

docker start {name}

By the way, what is the gain using the docker instead of an emulator? I see that container resources should be lighter then emulators, but is it very significant? For example, i can run 4 emulators at same time using Windows and ldplayer, memu or any kind of android emulator, but if i start the 5 one my computer get unworkable. If i use the same computer resources but on Ubuntu with containers, could I have more emulators then 4? If yes, could you say in numbers of devices? What are the other benefits of using Insomniac on a container?

Thank you a lot guys!!!

It depends on your power of the pc. The advantage is you do not have to install anything - except docker. If the login feature is implemented it can be run everywhere.