Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support KernelSU / Apatch & fix broken Frida server launch #46

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

enovella
Copy link
Contributor

Screenshot 2024-01-27 at 23 15 36 Screenshot 2024-01-27 at 23 08 46

@enovella
Copy link
Contributor Author

@ViRb3 for viz

@ViRb3
Copy link
Owner

ViRb3 commented Feb 12, 2024

Will take a look the next few days, sorry been very busy.

@ys1231
Copy link

ys1231 commented Feb 12, 2024

Understand, the Chinese New Year is busy.

@ViRb3
Copy link
Owner

ViRb3 commented Feb 14, 2024

@enovella Why does the auto restart loop not work for you? I see no reason why it wouldn't work.

@enovella
Copy link
Contributor Author

@enovella Why does the auto restart loop not work for you? I see no reason why it wouldn't work.

It doesn't work in any of my devices (7-8 laying around). Frida is simply not available after boot with the while-true loop.

@enovella
Copy link
Contributor Author

@ViRb3 Any plans to review this PR? Otherwise, I can create a fork and continue adding changes over there. Let me know.

@ViRb3
Copy link
Owner

ViRb3 commented Apr 10, 2024

@enovella Sorry, meant to test myself but got side tracked. I just pulled out my OnePlus 5T running Elixir OS 2.1 (Android 12L), Magisk 27.0, MagiskFrida 16.2.1. It works perfectly as I can debug applications from my computer over USB, and I can also see the process inside a shell in the phone:

$ adb shell
OnePlus5T:/ $ pgrep -l frida
3938 frida-server

What exact setup did you test across your devices? I honestly find it very strange for the daemonization to work and regular blocking mode not.

@liangjaden
Copy link

这个PR会继续跟进不?期待能支持kernelsu

@sha3rawi33
Copy link

bump

@nEdAy
Copy link

nEdAy commented May 24, 2024

looking forward to it supporting KernelSU.

@ViRb3
Copy link
Owner

ViRb3 commented May 24, 2024

Can all of you please let me know whether the current MagiskFrida with auto restart loop works for you, and you are able to debug apps on your phone using Frida on your PC? I am happy to merge this PR but I want to figure out the problem @enovella is experiencing.

@enovella
Copy link
Contributor Author

Can all of you please let me know whether the current MagiskFrida with auto restart loop works for you, and you are able to debug apps on your phone using Frida on your PC? I am happy to merge this PR but I want to figure out the problem @enovella is experiencing.

I already mentioned several times that this auto-restart loop didn't work for me. The phone didn't respond to Frida upon booting and this was tested in so many devices. The idea is to use the flag to daemonize Frida (-D) instead of blindly restarting Frida.

@ViRb3
Copy link
Owner

ViRb3 commented May 24, 2024

Yeah, I know it doesn't work for you, but it works for me this is the confusing part. So I am asking other people, apart from you and me, to test as well and we can get a better picture. I don't want to make changes without fully understanding them. There's no reason why daemonizing or not should make a difference. If you have a theory, I am happy to hear it.

@liangjaden
Copy link

liangjaden commented May 24, 2024 via email

@ViRb3
Copy link
Owner

ViRb3 commented May 24, 2024

@liangjaden can you test the latest official magisk-frida release, not this PR? Link: https://github.com/ViRb3/magisk-frida/releases/download/16.2.5-1/MagiskFrida-16.2.5-1.zip

@liangjaden
Copy link

liangjaden commented May 24, 2024 via email

@ys1231
Copy link

ys1231 commented May 27, 2024

@enovella His problem can be solved by ending the server process once, and the loop can also work normally

@liangjaden
Copy link

@ViRb3 After testing, the latest version is working on my phone

@enovella
Copy link
Contributor Author

@ys1231 "his" problem? Do you mean the current loop? I don't have problems with the PR in so many devices (many running Pixel OS or Experience).

@ViRb3 Have you tried your loop in more devices and ROMs?

@enovella
Copy link
Contributor Author

@enovella His problem can be solved by ending the server process once, and the loop can also work normally

But this would be ugly, wouldn't it?

@ys1231
Copy link

ys1231 commented May 28, 2024

This is a probability problem. Sometimes it won't happen, as long as it works,My mobile phone models are pixel3xl and pixel6.

@ViRb3
Copy link
Owner

ViRb3 commented May 28, 2024

@enovel unfortunately I only have one device at hand. The stable version of this package has used the loop for over a year and you're the first person to say it doesn't work, so I am just very confused why. I really want to get to the bottom of this before making any changes. I will try to run a different ROM over the next few days, also I'll also try an emulator.

For anyone reading this ticket, please also test and let me know.

@enovella
Copy link
Contributor Author

@ViRb3 In this case, you can merge the PR with changes and leave your loop until we find a working 100% solution for everyone. Is my PR working on your device?

@enovella
Copy link
Contributor Author

@ViRb3 any news?

@0xE0-rng
Copy link
Contributor

0xE0-rng commented Jul 2, 2024

@enovella I tried your module but does not seem to work on my Pixel 7 (Android 14, Kernel Patch 0.10.7, Apatch 10763)
I am still debugging, but one first issue seems to be that $KSU does not seems to be set which leads to the module not recognizing that its a KernelSU install.
I cannot attach screenshots, but the install does seem to work except the $KSU var not being set.

Following that the extraction just seems to fail for me... The zip file contains the frida server

~/projects/magisk-frida-edu/build  ksufrida ± > unzip -l MagiskFrida-16.3.3-1.zip
Archive:  MagiskFrida-16.3.3-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      215  07-02-2024 12:30   module.prop
     7325  07-02-2024 11:44   install.sh
      557  06-28-2024 17:11   README.md
        8  06-28-2024 17:11   META-INF/com/google/android/updater-script
     3794  06-28-2024 17:11   META-INF/com/google/android/update-binary
      318  06-28-2024 17:11   common/post-fs-data.sh
       84  06-28-2024 17:11   common/system.prop
      503  07-02-2024 11:44   common/service.sh
 56466624  07-02-2024 12:30   files/frida-server-arm64
 56532312  07-02-2024 12:30   files/frida-server-x86
113371768  07-02-2024 12:30   files/frida-server-x86_64
 27129236  07-02-2024 12:30   files/frida-server-arm
---------                     -------
253512744                     12 files

but its not extracted into the correct folder:

 ~ adb logcat | grep -i frida
- waiting for device -
07-02 15:32:34.246   864   864 I APatchD : apd::mount: mount overlayfs on "/system", lowerdir=/data/adb/modules/magisk-frida/system:/system, upperdir=None, workdir=None
panther:/data/adb/modules/magisk-frida # ls -lah system/bin
total 4
drwxr-xr-x 2 root root 1.0K 2024-07-02 15:24 .
drwxr-xr-x 3 root root 1.0K 2024-07-02 15:24 ..
panther:/data/adb/modules/magisk-frida # ls /system/bin/fr*
/system/bin/free

Apologies if thats an obious error, by magisk / Ksu expiriece is limited.... Let me know if I can help somehow

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

@enovella I tried your module but does not seem to work on my Pixel 7 (Android 14, Kernel Patch 0.10.7, Apatch 10763) I am still debugging, but one first issue seems to be that $KSU does not seems to be set which leads to the module not recognizing that its a KernelSU install. I cannot attach screenshots, but the install does seem to work except the $KSU var not being set.

Following that the extraction just seems to fail for me... The zip file contains the frida server

~/projects/magisk-frida-edu/build  ksufrida ± > unzip -l MagiskFrida-16.3.3-1.zip
Archive:  MagiskFrida-16.3.3-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      215  07-02-2024 12:30   module.prop
     7325  07-02-2024 11:44   install.sh
      557  06-28-2024 17:11   README.md
        8  06-28-2024 17:11   META-INF/com/google/android/updater-script
     3794  06-28-2024 17:11   META-INF/com/google/android/update-binary
      318  06-28-2024 17:11   common/post-fs-data.sh
       84  06-28-2024 17:11   common/system.prop
      503  07-02-2024 11:44   common/service.sh
 56466624  07-02-2024 12:30   files/frida-server-arm64
 56532312  07-02-2024 12:30   files/frida-server-x86
113371768  07-02-2024 12:30   files/frida-server-x86_64
 27129236  07-02-2024 12:30   files/frida-server-arm
---------                     -------
253512744                     12 files

but its not extracted into the correct folder:

 ~ adb logcat | grep -i frida
- waiting for device -
07-02 15:32:34.246   864   864 I APatchD : apd::mount: mount overlayfs on "/system", lowerdir=/data/adb/modules/magisk-frida/system:/system, upperdir=None, workdir=None
panther:/data/adb/modules/magisk-frida # ls -lah system/bin
total 4
drwxr-xr-x 2 root root 1.0K 2024-07-02 15:24 .
drwxr-xr-x 3 root root 1.0K 2024-07-02 15:24 ..
panther:/data/adb/modules/magisk-frida # ls /system/bin/fr*
/system/bin/free

Apologies if thats an obious error, by magisk / Ksu expiriece is limited.... Let me know if I can help somehow

Does it work Frida and KSU in your device without using this module?

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

@enovella I tried your module but does not seem to work on my Pixel 7 (Android 14, Kernel Patch 0.10.7, Apatch 10763) I am still debugging, but one first issue seems to be that $KSU does not seems to be set which leads to the module not recognizing that its a KernelSU install. I cannot attach screenshots, but the install does seem to work except the $KSU var not being set.

Following that the extraction just seems to fail for me... The zip file contains the frida server

~/projects/magisk-frida-edu/build  ksufrida ± > unzip -l MagiskFrida-16.3.3-1.zip
Archive:  MagiskFrida-16.3.3-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      215  07-02-2024 12:30   module.prop
     7325  07-02-2024 11:44   install.sh
      557  06-28-2024 17:11   README.md
        8  06-28-2024 17:11   META-INF/com/google/android/updater-script
     3794  06-28-2024 17:11   META-INF/com/google/android/update-binary
      318  06-28-2024 17:11   common/post-fs-data.sh
       84  06-28-2024 17:11   common/system.prop
      503  07-02-2024 11:44   common/service.sh
 56466624  07-02-2024 12:30   files/frida-server-arm64
 56532312  07-02-2024 12:30   files/frida-server-x86
113371768  07-02-2024 12:30   files/frida-server-x86_64
 27129236  07-02-2024 12:30   files/frida-server-arm
---------                     -------
253512744                     12 files

but its not extracted into the correct folder:

 ~ adb logcat | grep -i frida
- waiting for device -
07-02 15:32:34.246   864   864 I APatchD : apd::mount: mount overlayfs on "/system", lowerdir=/data/adb/modules/magisk-frida/system:/system, upperdir=None, workdir=None
panther:/data/adb/modules/magisk-frida # ls -lah system/bin
total 4
drwxr-xr-x 2 root root 1.0K 2024-07-02 15:24 .
drwxr-xr-x 3 root root 1.0K 2024-07-02 15:24 ..
panther:/data/adb/modules/magisk-frida # ls /system/bin/fr*
/system/bin/free

Apologies if thats an obious error, by magisk / Ksu expiriece is limited.... Let me know if I can help somehow

I didn't test Apatch or Android 14/15 btw

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

@enovella I tried your module but does not seem to work on my Pixel 7 (Android 14, Kernel Patch 0.10.7, Apatch 10763) I am still debugging, but one first issue seems to be that $KSU does not seems to be set which leads to the module not recognizing that its a KernelSU install. I cannot attach screenshots, but the install does seem to work except the $KSU var not being set.

Following that the extraction just seems to fail for me... The zip file contains the frida server

~/projects/magisk-frida-edu/build  ksufrida ± > unzip -l MagiskFrida-16.3.3-1.zip
Archive:  MagiskFrida-16.3.3-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      215  07-02-2024 12:30   module.prop
     7325  07-02-2024 11:44   install.sh
      557  06-28-2024 17:11   README.md
        8  06-28-2024 17:11   META-INF/com/google/android/updater-script
     3794  06-28-2024 17:11   META-INF/com/google/android/update-binary
      318  06-28-2024 17:11   common/post-fs-data.sh
       84  06-28-2024 17:11   common/system.prop
      503  07-02-2024 11:44   common/service.sh
 56466624  07-02-2024 12:30   files/frida-server-arm64
 56532312  07-02-2024 12:30   files/frida-server-x86
113371768  07-02-2024 12:30   files/frida-server-x86_64
 27129236  07-02-2024 12:30   files/frida-server-arm
---------                     -------
253512744                     12 files

but its not extracted into the correct folder:

 ~ adb logcat | grep -i frida
- waiting for device -
07-02 15:32:34.246   864   864 I APatchD : apd::mount: mount overlayfs on "/system", lowerdir=/data/adb/modules/magisk-frida/system:/system, upperdir=None, workdir=None
panther:/data/adb/modules/magisk-frida # ls -lah system/bin
total 4
drwxr-xr-x 2 root root 1.0K 2024-07-02 15:24 .
drwxr-xr-x 3 root root 1.0K 2024-07-02 15:24 ..
panther:/data/adb/modules/magisk-frida # ls /system/bin/fr*
/system/bin/free

Apologies if thats an obious error, by magisk / Ksu expiriece is limited.... Let me know if I can help somehow

Can you describe which is the env variable and busybox PATH to have the case?

@0xE0-rng
Copy link
Contributor

0xE0-rng commented Jul 2, 2024

Ah, that makes alot of sense, I just read the docs on APatch and ajusted your script and it all works. I will create a PR later today to your repo :)

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

Ah, that makes alot of sense, I just read the docs on APatch and ajusted your script and it all works. I will create a PR later today to your repo :)

https://github.com/bmax121/APatch/blob/main/scripts/update_script.sh#L31

############
# Detection
############

if echo $APATCH_VER | grep -q '\.'; then
  PRETTY_VER=$APATCH_VER
else
  PRETTY_VER="$APATCH_VER($APATCH_VER_CODE)"
fi
print_title "APATCH $PRETTY_VER Installer"

is_mounted /data || mount /data || is_mounted /cache || mount /cache
mount_partitions
check_data
get_flags
find_boot_image

[ -z $BOOTIMAGE ] && abort "! Unable to detect target image"
ui_print "- Target image: $BOOTIMAGE"

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

Ah, that makes alot of sense, I just read the docs on APatch and ajusted your script and it all works. I will create a PR later today to your repo :)

@ViRb3 and it all works!

@0xE0-rng
Copy link
Contributor

0xE0-rng commented Jul 2, 2024

enovella#1

If you want to merge this into your branch we can make an effort getting this all merged :)

@enovella
Copy link
Contributor Author

enovella commented Jul 2, 2024

@0xE0-rng

panther:/sdcard/Download $ cat APatch_install_log_2024-07-02-17-33-29.log
    _    ____       _       _
   / \  |  _ \ __ _| |_ ___| |__
  / _ \ | |_) / _` | __/ __| '_ \
 / ___ \|  __/ (_| | || (__| | | |
/_/   \_\_|   \__,_|\__\___|_| |_|

- Preparing image
- Module size: 253.51 MB
e2fsck 1.46.6 (1-Feb-2023)
- Estimated minimum size of the filesystem: 75214
e2fsck 1.46.6 (1-Feb-2023)
- Target image size: 598.97 MB
resize2fs 1.46.6 (1-Feb-2023)
The filesystem is already 585953 (1k) blocks long.  Nothing to do!

e2fsck 1.46.6 (1-Feb-2023)
- Mounting image
Source path is not read-only
- Current boot slot: _a
- Device is system-as-root
Archive:  /data/user/0/me.bmax.apatch/cache/module.zip
  inflating: module.prop
Archive:  /data/user/0/me.bmax.apatch/cache/module.zip
  inflating: module.prop
  inflating: install.sh
  inflating: post-fs-data.sh
  inflating: system.prop
  inflating: service.sh

    ********************************************
    *          Magisk-/KernelSU-Frida          *
    ********************************************

- Detected architecture: arm64
- Installing from APatch app
- APatch version: 10763. Magisk version: 27000
- Extracting module files
- Setting permissions
- Done

Added Apatch support
else
ui_print "*********************************************************"
ui_print "! Install from recovery is not supported"
ui_print "! Please install from KernelSU or Magisk app"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xE0-rng Do you want to specify something about Apatch?

@@ -124,7 +124,7 @@ REPLACE="
print_modname() {
ui_print " "
ui_print " ********************************************"
ui_print " * MagiskFrida *"
ui_print " * Magisk-/KernelSU-Frida *"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xE0-rng something about Apatch

@enovella enovella changed the title Support KernelSU & fix broken Frida server launch Support KernelSU / Apatch & fix broken Frida server launch Jul 2, 2024
UNZIP="/data/adb/ksu/bin/busybox unzip"
elif [ "$BOOTMODE" ] && [ "$APATCH" ]; then
ui_print "- Installing from APatch app"
ui_print "- APatch version: $APATCH_VER_CODE. Magisk version: $MAGISK_VER_CODE"
Copy link
Contributor Author

@enovella enovella Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xE0-rng this line isn't right, is it?

  1. Does $MAGISK_VER_CODE exist on Apatch?
  2. Could we use this combo? "$APATCH_VER($APATCH_VER_CODE)"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's available (as seen on the output above). Thanks for the feedback, I will give it a look when I have some free time :)

@enovella enovella requested a review from 0xE0-rng July 9, 2024 08:39
@enovella
Copy link
Contributor Author

Ah, that makes alot of sense, I just read the docs on APatch and ajusted your script and it all works. I will create a PR later today to your repo :)

@ViRb3 and it all works!

@ViRb3 Thinking of closing this PR and creating my own fork with my changes to support KernelSU, APatch and proper boot on more devices. Is this what you want too? This PR is taking ages to be verified.

@ViRb3
Copy link
Owner

ViRb3 commented Jul 17, 2024

Sorry @enovella, I didn't mean to drag this for so long, just thought I'd have free time to dig into it but still haven't. I'd be happy to archive this repo in favor of yours, but it has a build hook set up with Frida and apparently very good Google SEO, so it would be a pain to migrate.

Let's do this - from now on I will merge your PRs with just a code review, and if users report any issues, we can always revert.

Apologies again for dragging this so long, let's hope this new approach works out for the best!

@ViRb3 ViRb3 merged commit 4b4cc98 into ViRb3:master Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants