AhMyth icon indicating copy to clipboard operation
AhMyth copied to clipboard

Victim disconnects when in sleep mode

Open timingobituary opened this issue 1 year ago • 23 comments

This is an issue with the

  • [x] AhMyth Client

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:

  • Android Version: Android 11 & 12

Checklist

  • [x] Is this really an issue?
  • [x] Have I looked at previous issues to see if this has already been addressed?
  • [ ] Have I used some initiative to try and solve the issue myself?

timingobituary avatar Aug 29 '22 16:08 timingobituary

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) ?

Morsmalleo avatar Aug 29 '22 23:08 Morsmalleo

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

timingobituary avatar Aug 30 '22 16:08 timingobituary

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.

Morsmalleo avatar Aug 30 '22 16:08 Morsmalleo

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

timingobituary avatar Aug 30 '22 17:08 timingobituary

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

Morsmalleo avatar Sep 16 '22 01:09 Morsmalleo

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

timingobituary avatar Sep 23 '22 20:09 timingobituary

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

airwilb avatar Sep 28 '22 21:09 airwilb

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

Morsmalleo avatar Sep 28 '22 22:09 Morsmalleo

I have another possible issue similar to the sleep mode issue but I'm trying to make sure it's not specific to the device before I go ahead and post about it. But it's reassuring to know you monitor the issues here diligently

airwilb avatar Sep 28 '22 22:09 airwilb

I have another possible issue similar to the sleep mode issue but I'm trying to make sure it's not specific to the device before I go ahead and post about it. But it's reassuring to know you monitor the issues here diligently

Let's hear about your issue 🙂

Morsmalleo avatar Sep 28 '22 22:09 Morsmalleo

Well along the same lines as this sleep mode issue, there are times I'm getting no response even though I'm listening on the correct port. I've tried even having the app open to see if having it in the background is the problem and even with the app open I get no connection. I'm not positive but I think the problem fixes itself if the phone is restarted but I'd have to test that theory. I also adjusted the app settings to make sure battery optimization wasn't interfering with background data usage and I still have this issue sometimes, and it seems to happen randomly I'll have connection all day no problem (other than the sleep mode issue) and then at the end of the day it'll just stop connecting altogether.

Other than that I've had no real issues, there are times the connection will keep dropping and the victim will disappear and re-appear on the victim panel using different ports each time but I think that might just be due to sub-par mobile data connectivity.

airwilb avatar Sep 28 '22 23:09 airwilb

Well along the same lines as this sleep mode issue, there are times I'm getting no response even though I'm listening on the correct port. I've tried even having the app open to see if having it in the background is the problem and even with the app open I get no connection. I'm not positive but I think the problem fixes itself if the phone is restarted but I'd have to test that theory. I also adjusted the app settings to make sure battery optimization wasn't interfering with background data usage and I still have this issue sometimes, and it seems to happen randomly I'll have connection all day no problem (other than the sleep mode issue) and then at the end of the day it'll just stop connecting altogether.

Other than that I've had no real issues, there are times the connection will keep dropping and the victim will disappear and re-appear on the victim panel using different ports each time but I think that might just be due to sub-par mobile data connectivity.

Did you use an APK bound with the AhMyth payload when experiencing this issue weren't you or did you use a standalone APK payload?

Morsmalleo avatar Sep 28 '22 23:09 Morsmalleo

Well along the same lines as this sleep mode issue, there are times I'm getting no response even though I'm listening on the correct port. I've tried even having the app open to see if having it in the background is the problem and even with the app open I get no connection. I'm not positive but I think the problem fixes itself if the phone is restarted but I'd have to test that theory. I also adjusted the app settings to make sure battery optimization wasn't interfering with background data usage and I still have this issue sometimes, and it seems to happen randomly I'll have connection all day no problem (other than the sleep mode issue) and then at the end of the day it'll just stop connecting altogether. Other than that I've had no real issues, there are times the connection will keep dropping and the victim will disappear and re-appear on the victim panel using different ports each time but I think that might just be due to sub-par mobile data connectivity.

You were Binding when experiencing this issue weren't you?

No, I haven't tested the Binding function yet. Only using standalone APK that the builder creates

airwilb avatar Sep 28 '22 23:09 airwilb

Well along the same lines as this sleep mode issue, there are times I'm getting no response even though I'm listening on the correct port. I've tried even having the app open to see if having it in the background is the problem and even with the app open I get no connection. I'm not positive but I think the problem fixes itself if the phone is restarted but I'd have to test that theory. I also adjusted the app settings to make sure battery optimization wasn't interfering with background data usage and I still have this issue sometimes, and it seems to happen randomly I'll have connection all day no problem (other than the sleep mode issue) and then at the end of the day it'll just stop connecting altogether. Other than that I've had no real issues, there are times the connection will keep dropping and the victim will disappear and re-appear on the victim panel using different ports each time but I think that might just be due to sub-par mobile data connectivity.

You were Binding when experiencing this issue weren't you?

No, I haven't tested the Binding function yet. Only using standalone APK that the builder creates

What device are you experiencing this on, because I think I know what the problem could be with this one

Morsmalleo avatar Sep 28 '22 23:09 Morsmalleo

Well along the same lines as this sleep mode issue, there are times I'm getting no response even though I'm listening on the correct port. I've tried even having the app open to see if having it in the background is the problem and even with the app open I get no connection. I'm not positive but I think the problem fixes itself if the phone is restarted but I'd have to test that theory. I also adjusted the app settings to make sure battery optimization wasn't interfering with background data usage and I still have this issue sometimes, and it seems to happen randomly I'll have connection all day no problem (other than the sleep mode issue) and then at the end of the day it'll just stop connecting altogether. Other than that I've had no real issues, there are times the connection will keep dropping and the victim will disappear and re-appear on the victim panel using different ports each time but I think that might just be due to sub-par mobile data connectivity.

You were Binding when experiencing this issue weren't you?

No, I haven't tested the Binding function yet. Only using standalone APK that the builder creates

What device are you experiencing this on, because I think I know what the problem could be with this one

OnePlus7Pro running Android 10 (I think, I'll have to check but 80 percent sure it's running Android 10)

airwilb avatar Sep 28 '22 23:09 airwilb

Yeah I think I know the problem, this should work flawless almost on OnePlus devices so this looks like a conflict between the Socket.io Client Java version the AhMyth Client Payload APK uses, and the Socket.io Server version the AhMyth Server uses, I had this problem back when I updated socket.io for AhMyth, never had the space on my computer to upgrade the client version, but I do now, so I'll get Android Studio up and running and I'll take care of this, once I've made the update I'll post back here and let you know about it, and I'll get you to test on your end

Morsmalleo avatar Sep 28 '22 23:09 Morsmalleo

Awesome well I'm glad you know the issue already looking forward to the update

airwilb avatar Sep 28 '22 23:09 airwilb

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

comodoro64 avatar Oct 01 '22 18:10 comodoro64

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

airwilb avatar Oct 01 '22 22:10 airwilb

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

I've had the same issue on both, virtual device with Genymotion and an actual Android cellphone. If the files are small they are usually saved, but if their size are close to the limit I stated above, a disconnection may happen before the file is actually saved, although, in this case, the disconnection does not happen as soon as I click on the diskette icon, which happens for larger files.

comodoro64 avatar Oct 02 '22 00:10 comodoro64

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

I've had the same issue on both, virtual device with Genymotion and an actual Android cellphone. If the files are small they are usually saved, but if their size are close to the limit I stated above, a disconnection may happen before the file is actually saved, although, in this case, the disconnection does not happen as soon as I click on the diskette icon, which happens for larger files.

Could you open up your issues in a new issue please, and I'll look into it IMMEDIATELY!

Morsmalleo avatar Oct 02 '22 00:10 Morsmalleo

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

The SMS bug, could you please open it in a new issue just so I can keep track of the bugs that are present

Morsmalleo avatar Oct 02 '22 00:10 Morsmalleo

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

I've had the same issue on both, virtual device with Genymotion and an actual Android cellphone. If the files are small they are usually saved, but if their size are close to the limit I stated above, a disconnection may happen before the file is actually saved, although, in this case, the disconnection does not happen as soon as I click on the diskette icon, which happens for larger files.

Could you open up your issues in a new issue please, and I'll look into it IMMEDIATELY!

Done, thank you.

comodoro64 avatar Oct 02 '22 00:10 comodoro64

I am getting instant disconnections when trying to save files larger than 16.7 megabytes, from the file manager. I am using the standalone APK payload on Android 9. Any ideas to overcome this issue?

I've experienced this as well. Wasn't sure if it was a bug or if the target device simply had inconsistent mobile data connection

The SMS bug, could you please open it in a new issue just so I can keep track of the bugs that are present

Will do right now!

airwilb avatar Oct 02 '22 01:10 airwilb

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

airwilb avatar Oct 07 '22 20:10 airwilb

So I was testing this bug on a bunch of different devices and the time it takes for almost all connected devices I tested to enter sleep mode and disconnect was consistently approximately 6 minutes.

Do you think this is an IOSocket issue or an Android firmware issue?

airwilb avatar Oct 14 '22 03:10 airwilb

Not sure but I just tested it, and connections stay alive on my device

Morsmalleo avatar Oct 14 '22 04:10 Morsmalleo

Sleep mode on or off they stay alive, this must be a firmware limitation with some devices, I'll have to look into this

Morsmalleo avatar Oct 14 '22 04:10 Morsmalleo

Scratch that, just timed it with my own phone and it disconnected after 1:18, however it reconnected back after a couple of seconds in some instances, other times it requires opening the payload application again, so this bug is definitely confirmed

Morsmalleo avatar Oct 14 '22 04:10 Morsmalleo

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

Morsmalleo avatar Oct 17 '22 03:10 Morsmalleo