Morsmalleo / AhMyth

Cross-Platform Android Remote Administration Tool | Official maintained repository for the AhMyth R.A.T Project | A dedicated revival of the original repository at https://GitHub.com/AhMyth/AhMyth-Android-RAT
GNU General Public License v3.0
714 stars 177 forks source link

Victim disconnects when in sleep mode #152

Open timingobituary opened 1 year ago

timingobituary commented 1 year ago

This is an issue with the

Describe the bug

I have a victim connected to the victims lab, however whenever the victim puts its device in sleep mode(i.e. phone is still on but screen off) then after 30 seconds of idle waiting the victim disconnects. The victim doesn't disconnect if I keep using the victims lab, doing stuff like getting files or call logs, etc. This happens on 2 different devices (android 11 & 12)

To Reproduce

Steps to reproduce the behavior:

  1. Install standalone payload
  2. Connect victim
  3. Turn off the victim's screen
  4. Wait for ~30 seconds
  5. Victim disconnects

Expected behavior

I would've expected the connection to remain even after putting the device in sleep mode.

Client Issue

please complete the following information:

Checklist

Morsmalleo commented 1 year ago

Wow this is a new one, I'm glad you brought this to my attention because we can't have this happening, so this is actually a Client issue, so can you tell me what sort of Payload you built, was it a standalone payload 🐞 or a Bound Payload 🪲 (Payload templated with an original APK) ?

timingobituary commented 1 year ago

Yeah I was wondering whether or not this was a client or server side problem. I have updated the issue description.

The payload I used was the standalone payload

Morsmalleo commented 1 year ago

Yeah I was wondering whether or not this was a client or server side problem. I have updated the issue description.

The payload I used was the standalone payload

Yes I seem to be getting the same thing, I will do some research on this, and I will post back here ASAP.

timingobituary commented 1 year ago

Great! Thanks for the quick response, at the very least it is good that the bug is reproducible. Let me know if you need something else

Morsmalleo commented 1 year ago

Great! Thanks for the quick response, at the very least it is good that the bug is reproducible. Let me know if you need something else

Ok I'm back, so sorry it took me so long, but I think I've figured out the problem.... so with socket.io client java which is what the AhMyth client uses for connections back to the AhMyth Server, the connections are known to drop when the android device idles and goes to sleep or when put on sleep mode by the user. I've seen this happen in a few devices but not many, namely Samsung and Vivo devices, but even then only some.

I am currently working on a fix I've found and will get back to you once again once it's done and tested

timingobituary commented 1 year ago

Great! Thanks for the quick response, at the very least it is good that the bug is reproducible. Let me know if you need something else

Ok I'm back, so sorry it took me so long, but I think I've figured out the problem.... so with socket.io client java which is what the AhMyth client uses for connections back to the AhMyth Server, the connections are known to drop when the android device idles and goes to sleep or when put on sleep mode by the user. I've seen this happen in a few devices but not many, namely Samsung and Vivo devices, but even then only some.

I am currently working on a fix I've found and will get back to you once again once it's done and tested

No problem, take your time! Thanks for updating

airwilb commented 1 year ago

Had the exact same issue, really appreciate that you're still working on this and updating things accordingly!

Morsmalleo commented 1 year ago

Had the exact same issue, really appreciate that you're still working on this and updating things accordingly!

You're most welcome, if anyone has an issue, I work hard to resolve it, and if the issue is caused by bugs, I'll fix it no matter how long it takes

airwilb commented 1 year ago

I wonder if this bug is specific to certain devices. I was testing out the connection on a tablet I have Xiaomi pad 5 Android 11 and I'm not disconnecting in sleep mode. Could be because I'm connected over wifi but thought I should mention this in case it helps @Morsmalleo

Edit: never mind it just lasted a lot longer before disconnecting unlike other devices I've tried in sleep mode. Probably has to do with certain devices entering sleep mode quicker. Disregard my comment lol

Morsmalleo commented 1 year ago

I think I've figured out the problem, from my research things like this happen due to battery optimisation, if we ignore battery optimisation then we shouldn't experience this problem!

We can't keep a socket app, or for that matter, any app that requires large amounts of power, alive forever on a battery-powered mobile device, doing so would kill the phone's battery!

This is why battery optimisation was officially implemented for Android 6.0 Marshmallow and above, simply because it would only take 1 poorly misbehaved app to completely drain an android phones battery.

Battery optimisation is supposedly at its highest when the phone is in sleep mode according to my research, so ignoring battery optimisation for the client should solve the problem, I'll get to work on this ASAP

airwilb commented 1 year ago

I think I've figured out the problem, from my research things like this happen due to battery optimisation, if we ignore battery optimisation then we shouldn't experience this problem!

We can't keep a socket app, or for that matter, any app that requires large amounts of power, alive forever on a battery-powered mobile device, doing so would kill the phone's battery!

This is why battery optimisation was officially implemented for Android 6.0 Marshmallow and above, simply because it would only take 1 poorly misbehaved app to completely drain an android phones battery.

Battery optimisation is supposedly at its highest when the phone is in sleep mode according to my research, so ignoring battery optimisation for the client should solve the problem, I'll get to work on this ASAP

I thought battery optimization might be the issue here, so on the target device after the APK is installed I've gone into the app settings and turned off battery optimization for that app. Connections will remain for longer periods but eventually they still disconnect at a certain point once the phone is in sleep mode

timingobituary commented 1 year ago

Yeah I can confirm that disabling battery optimization allows the connection to last much longer! I have tried 1 hour for now and that seems to work on my android 11 device.

Morsmalleo commented 1 year ago

This is good I will implement something that will hopefully allow full ignorance of battery optimisation

Morsmalleo commented 1 year ago

I'll let everyone know once this is done

SubUrban23 commented 1 year ago

Any update on this topic?

Morsmalleo commented 1 year ago

Any update on this topic?

Updates for this one will begin soon

nyctophiliac0 commented 1 year ago

It also occur in oppo mobile phone

Morsmalleo commented 1 year ago

It will occur on every device until it's fixed.

On Tue, 2 May 2023, 2:24 am N Y C T O P H I L I A C, < @.***> wrote:

It also occur in oppo mobile phone

— Reply to this email directly, view it on GitHub https://github.com/Morsmalleo/AhMyth/issues/152#issuecomment-1530044735, or unsubscribe https://github.com/notifications/unsubscribe-auth/APK5A2AJBQ7CYSYOX4HF4C3XD75U5ANCNFSM576NCWBQ . You are receiving this because you were mentioned.Message ID: @.***>

nyctophiliac0 commented 1 year ago

Please try to fix it

Morsmalleo commented 1 year ago

Please try to fix it

I'll fix it when I have the time, I'm not superman, I'm only one person doing all these updates, so be patient please

timingobituary commented 1 year ago

I'll fix it when I have the time, I'm not superman, I'm only one person doing all these updates, so be patient please Please take your time! I'm more than happy to see that you're keeping this project alive

Morsmalleo commented 11 months ago

could not implement the fixes for this in beta.5, but I'm jumping on to this issue in the next few weeks.

timingobituary commented 1 month ago

Hi, has there been any update on this issue?

HermesThemes commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

SubUrban23 commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

sorry friend, this project is already dead

Morsmalleo commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

sorry friend, this project is already dead

The project is not dead actually, so don't be salty.

Why don't you head on over to the development branch and then navigate to .github/Dev and you'll see the progress I'm making as well as why shit takes so long on this repo!!

Morsmalleo commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

Setup AhMyth using the source code the binaries do not contain any of the recent fixes I made a few months ago.

Disabling Battery Optimisation helps as well, and this is already an open issue as well.

I'm working on it, just give me time.

Morsmalleo commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

sorry friend, this project is already dead

Why don't you try maintaining a project like this by yourself then tell me what a dead repo looks like again.

Get salty on my repo like this again @SubUrban23 and you will be banned for 72 hours

HermesThemes commented 3 weeks ago

hi i have the same issue, any news on this ?, it disconnect when i take a pic or access files or put phone on sleep, and it reconnect again after a while, sometimes it works and get some files but is disconnect

Setup AhMyth using the source code the binaries do not contain any of the recent fixes I made a few months ago.

Disabling Battery Optimisation helps as well, and this is already an open issue as well.

I'm working on it, just give me time.

exactly, i disabled power saving mode and gives the app permission over battery optimization and now it disconnect sometimes but reconnect after a bit of time, I think asking for user permission to ignore battery optimization would really be helpful

HermesThemes commented 3 weeks ago

and also the the permission to stay alive on the background because i also noticed that after a 30 minute it stops reconnecting

Morsmalleo commented 3 weeks ago

Disable battery optimisations for the app to stop it from disconnecting and reconnecting

On Wed, 12 June 2024, 5:24 pm hermesthemes, @.***> wrote:

and also the the permission to stay alive on the background because i also noticed that after a 30 minute it stops reconnecting

— Reply to this email directly, view it on GitHub https://github.com/Morsmalleo/AhMyth/issues/152#issuecomment-2162534411, or unsubscribe https://github.com/notifications/unsubscribe-auth/APK5A2ARAE5SGGHDZ3JC633ZHAHUHAVCNFSM576NCWB2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJWGI2TGNBUGEYQ . You are receiving this because you were mentioned.Message ID: @.***>

HermesThemes commented 3 weeks ago

yes I disabled it but it still disconnect and reconnect, i guess this depend on my phone, because i only have the these options , i will try on another phone and i will return Screenshot_20240612-103200

HermesThemes commented 3 weeks ago

i tried to add this <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> to the manifest file but it seems that the app dont ask for the permission, im not a mobile dev lol, im just a full stack web dev, but i think as the original payload is for older versions of android this permission wont work, so i guess you will have a lot of work on this one, and good luck, and if u ever needed help ask me for it and ill try to do my best to help :3

Morsmalleo commented 3 weeks ago

i tried to add this <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> to the manifest file but it seems that the app dont ask for the permission, im not a mobile dev lol, im just a full stack web dev, but i think as the original payload is for older versions of android this permission wont work, so i guess you will have a lot of work on this one, and good luck, and if u ever needed help ask me for it and ill try to do my best to help :3

Disabling Battery Optimisations should do the trick however if you're testing on any android version higher than 5.1 you'll be greeted with problems, this will happen until I've finished building the new modern payload

HermesThemes commented 3 weeks ago

i tried to add this <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> to the manifest file but it seems that the app dont ask for the permission, im not a mobile dev lol, im just a full stack web dev, but i think as the original payload is for older versions of android this permission wont work, so i guess you will have a lot of work on this one, and good luck, and if u ever needed help ask me for it and ill try to do my best to help :3

Disabling Battery Optimisations should do the trick however if you're testing on any android version higher than 5.1 you'll be greeted with problems, this will happen until I've finished building the new modern payload

good luck man