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

Dr yak mods #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[submodule "haystack"]
path = haystack
url = https://github.com/Lanchon/haystack
[submodule "simple-deodexer"]
path = simple-deodexer
url = https://github.com/aureljared/simple-deodexer
[submodule "vdexExtractor"]
path = vdexExtractor
url = https://github.com/anestisb/vdexExtractor
[submodule "haystack"]
path = haystack
url = https://github.com/yeoldegrove/haystack
branch = unifiednlp
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM openjdk:8-slim

RUN apt update && apt -y install git rsync zip libc++-dev squashfs-tools make gcc zlib1g-dev
RUN apt update && apt -y install git rsync wget zip libc++-dev squashfs-tools make gcc zlib1g-dev

WORKDIR /
COPY haystack /haystack
COPY simple-deodexer /simple-deodexer
COPY vdexExtractor /vdexExtractor
RUN cd /vdexExtractor && ./make.sh
RUN wget -O/mapsv1.flashable.zip https://github.com/microg/android_frameworks_mapsv1/releases/download/v0.1.0/mapsv1.flashable.zip

ADD *.sh ./
RUN mkdir /sailfish

ENV SAILFISH 172.28.172.1
ENV SAILFISH 192.168.2.15
# DEBUG
# CMD ["bash", "-x", "./run.sh"]
CMD ["bash", "./run.sh"]
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Overview of the steps performed by the scripts:
* deodex using [vdexExtractor](https://github.com/anestisb/vdexExtractor)
* apply `hook` and `core` patches from [haystack](https://github.com/Lanchon/haystack)
* push back changed files, saving backups in `/home/nemo/system.img.pre.haystack`
* This now includes installing the "microG maps API" from https://github.com/microg/android_frameworks_mapsv1. If you don't want this, pass `--env NOMAPS=1`


Instructions
Expand All @@ -31,8 +32,9 @@ Instructions
**Starting Rsync daemon on Sailfish**

* Make sure Android subsystem is stopped
* Make sure you PC is in connected to the same WiFi network as your phone
* Connect your PC to the phone (either with USB or both connected to the same WiFi network)
* Figure out your phone's IP address. It's shown in "Developer mode". We will use it later
* For USB that would usually be 192.168.2.15
* Enable [developer mode](https://jolla.zendesk.com/hc/en-us/articles/202011863-How-to-enable-Developer-Mode)
* Open terminal app or connect via SSH
* Become root by executing `devel-su`
Expand All @@ -58,6 +60,8 @@ rsync --daemon --no-detach --verbose --config=/root/rsyncd-alien.conf --log-file
```bash
iptables -A connman-INPUT -i wlan0 -p tcp -m tcp --dport 873 -j ACCEPT
```
* OR use an `ssh` firewall (see `--env SSH=1` parameter below)


**Execute docker image**

Expand All @@ -73,17 +77,32 @@ Make sure you checked out all the code from the gut submodules, e.g.:
git submodule update --init --recursive
```

Make sure to pass `--env SAILFISH=` with the IP of the phone
Make sure to pass `--env SAILFISH=` with the IP of the phone. `192.168.2.15` aka the USB device IP is set as a default.
You can pass `--env SSH=1` to use the ssh tunnel mode (no firewall exception needed in SailfishOS)

```bash
docker run --rm -ti --env SAILFISH=<PHONE_IP_ADDRESS> yeoldegrove/sailfish-signature-spoofing-lxc

or

docker run --rm -ti --env SAILFISH=<PHONE_IP_ADDRESS> --env SSH=1 yeoldegrove/sailfish-signature-spoofing-lxc

```

**Final steps**
* kill running rsync by pressing Ctrl-C
* start Android subsystem (or just run some app). *This will take time, depending on number of apps you have*
* From that point you can install [microG](https://microg.org/download.html) (nightly) [F-Droid](https://f-droid.org).
Don't forget to enable "Unstable updates" from "Expert mode"
* From that point you can install [microG](https://microg.org/download.html) (nightly) [F-Droid](https://f-droid.org). Don't forget to enable "Unstable updates" from "Expert mode"


**Before Sailfish X upgrades with android 8.1 LXC**

There is not enough free space in `/opt`partition to hold the current (patched) *system.img*, the upgrades and the backup all at the same time.

Either delete the backup from `/opt/alien/system.img.pre_haystack` or move this file to your SD card.

Then don't forget to re-run the patch to patch your new upgraded Android *system.img*.



Reverting the changes (if needed)
Expand Down Expand Up @@ -116,3 +135,5 @@ Kudos
===
The code is based on a fork from the excelent work of [rfvermut](https://github.com/rfvermut) here:
* [sailfish-signature-spoofing](https://github.com/vermut/sailfish-signature-spoofing)
Also kudos to Lanchon for maintaining haystack:
* https://github.com/Lanchon/haystack
2 changes: 1 addition & 1 deletion haystack
Submodule haystack updated 86 files
+35 −32 README.md
+5 −2 build-patch
+77 −21 bulk-patch-builder/build-all
+3 −3 patch-fileset
+107 −0 patches-src-gen/generate-patch-sources
+90 −0 patches-src-gen/sigspoof-core/services.jar/GeneratePackageInfoHook.java
+42 −0 patches-src-gen/sigspoof-hook/services.jar/GeneratePackageInfoHook.java
+12 −3 patches-src-gen/sigspoof-hook/services.jar/GeneratePackageInfoHookAccessor.java(<4.0)
+57 −0 patches-src-gen/sigspoof-hook/services.jar/PackageManagerService.java
+170 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(<9.0)/DevelopmentSettings.java
+69 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(>9.0)/DevelopmentSettingsDashboardFragment.java
+150 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(>9.0)/FakeSignatureGlobalPreferenceController.java
+71 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(>9.0)/FakeSignatureGlobalWarningDialog.java
+41 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src-gen/sigspoof-ui-global/Settings.apk(common)/FakeSignatureGlobalUI.java
+4 −7 patches-src-gen/sigspoof-ui-global/services.jar/GeneratePackageInfoHook.java
+2 −2 patches-src/sigspoof-core/services.jar/GeneratePackageInfoHook.java
+10 −1 patches-src/sigspoof-hook-1.5-2.3/services.jar/GeneratePackageInfoHook.java
+7 −1 patches-src/sigspoof-hook-1.5-2.3/services.jar/GeneratePackageInfoHookAccessor.java
+25 −8 patches-src/sigspoof-hook-1.5-2.3/services.jar/PackageManagerService.java
+10 −1 patches-src/sigspoof-hook-4.0/services.jar/GeneratePackageInfoHook.java
+39 −0 patches-src/sigspoof-hook-4.0/services.jar/GeneratePackageInfoHookAccessor.java(<4.0)
+26 −7 patches-src/sigspoof-hook-4.0/services.jar/PackageManagerService.java
+9 −4 patches-src/sigspoof-hook-4.1-6.0/services.jar/GeneratePackageInfoHook.java
+39 −0 patches-src/sigspoof-hook-4.1-6.0/services.jar/GeneratePackageInfoHookAccessor.java(<4.0)
+26 −15 patches-src/sigspoof-hook-4.1-6.0/services.jar/PackageManagerService.java
+9 −2 patches-src/sigspoof-hook-7.0-9.0/services.jar/GeneratePackageInfoHook.java
+39 −0 patches-src/sigspoof-hook-7.0-9.0/services.jar/GeneratePackageInfoHookAccessor.java(<4.0)
+24 −10 patches-src/sigspoof-hook-7.0-9.0/services.jar/PackageManagerService.java
+41 −0 patches-src/sigspoof-ui-global-4.0/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-4.0/Settings.apk(common)/FakeSignatureGlobalUI.java
+170 −0 patches-src/sigspoof-ui-global-4.0/Settings.apk/DevelopmentSettings.java
+43 −0 patches-src/sigspoof-ui-global-4.0/services.jar/GeneratePackageInfoHook.java
+0 −224 patches-src/sigspoof-ui-global-4.1-6.0/Settings.apk/DevelopmentSettings.java
+41 −0 patches-src/sigspoof-ui-global-4.1/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-4.1/Settings.apk(common)/FakeSignatureGlobalUI.java
+170 −0 patches-src/sigspoof-ui-global-4.1/Settings.apk/DevelopmentSettings.java
+43 −0 patches-src/sigspoof-ui-global-4.1/services.jar/GeneratePackageInfoHook.java
+41 −0 patches-src/sigspoof-ui-global-4.2-5.0/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-4.2-5.0/Settings.apk(common)/FakeSignatureGlobalUI.java
+170 −0 patches-src/sigspoof-ui-global-4.2-5.0/Settings.apk/DevelopmentSettings.java
+43 −0 patches-src/sigspoof-ui-global-4.2-5.0/services.jar/GeneratePackageInfoHook.java
+41 −0 patches-src/sigspoof-ui-global-5.1-6.0/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-5.1-6.0/Settings.apk(common)/FakeSignatureGlobalUI.java
+170 −0 patches-src/sigspoof-ui-global-5.1-6.0/Settings.apk/DevelopmentSettings.java
+43 −0 patches-src/sigspoof-ui-global-5.1-6.0/services.jar/GeneratePackageInfoHook.java
+41 −0 patches-src/sigspoof-ui-global-7.0-7.1/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-7.0-7.1/Settings.apk(common)/FakeSignatureGlobalUI.java
+102 −117 patches-src/sigspoof-ui-global-7.0-7.1/Settings.apk/DevelopmentSettings.java
+4 −7 patches-src/sigspoof-ui-global-7.0-7.1/services.jar/GeneratePackageInfoHook.java
+41 −0 patches-src/sigspoof-ui-global-8.0-8.1/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-8.0-8.1/Settings.apk(common)/FakeSignatureGlobalUI.java
+101 −118 patches-src/sigspoof-ui-global-8.0-8.1/Settings.apk/DevelopmentSettings.java
+4 −7 patches-src/sigspoof-ui-global-8.0-8.1/services.jar/GeneratePackageInfoHook.java
+170 −0 patches-src/sigspoof-ui-global-9.0/Settings.apk(<9.0)/DevelopmentSettings.java
+41 −0 patches-src/sigspoof-ui-global-9.0/Settings.apk(common)/FakeSignatureGlobalSetting.java
+90 −0 patches-src/sigspoof-ui-global-9.0/Settings.apk(common)/FakeSignatureGlobalUI.java
+1 −1 patches-src/sigspoof-ui-global-9.0/Settings.apk/DevelopmentSettingsDashboardFragment.java
+16 −49 patches-src/sigspoof-ui-global-9.0/Settings.apk/FakeSignatureGlobalPreferenceController.java
+0 −48 patches-src/sigspoof-ui-global-9.0/Settings.apk/FakeSignatureGlobalUI.java
+1 −8 patches-src/sigspoof-ui-global-9.0/Settings.apk/FakeSignatureGlobalWarningDialog.java
+4 −1 patches-src/sigspoof-ui-global-9.0/services.jar/GeneratePackageInfoHook.java
+80 −0 patches-src/unifiednlp-7.0/services.jar/ServiceWatcher.java
+188 −140 patches/bulk-patch-builder.log
+ patches/sigspoof-core/services.jar.dex
+ patches/sigspoof-hook-1.5-2.3/services.jar.dex
+ patches/sigspoof-hook-4.0/services.jar.dex
+ patches/sigspoof-hook-4.1-6.0/services.jar.dex
+ patches/sigspoof-hook-7.0-9.0/services.jar.dex
+ patches/sigspoof-ui-global-4.0/Settings.apk.dex
+ patches/sigspoof-ui-global-4.0/services.jar.dex
+ patches/sigspoof-ui-global-4.1-6.0/Settings.apk.dex
+ patches/sigspoof-ui-global-4.1-6.0/services.jar.dex
+ patches/sigspoof-ui-global-4.1/Settings.apk.dex
+ patches/sigspoof-ui-global-4.1/services.jar.dex
+ patches/sigspoof-ui-global-4.2-5.0/Settings.apk.dex
+ patches/sigspoof-ui-global-4.2-5.0/services.jar.dex
+ patches/sigspoof-ui-global-5.1-6.0/Settings.apk.dex
+ patches/sigspoof-ui-global-5.1-6.0/services.jar.dex
+ patches/sigspoof-ui-global-7.0-7.1/Settings.apk.dex
+ patches/sigspoof-ui-global-7.0-7.1/services.jar.dex
+ patches/sigspoof-ui-global-8.0-8.1/Settings.apk.dex
+ patches/sigspoof-ui-global-8.0-8.1/services.jar.dex
+ patches/sigspoof-ui-global-9.0/Settings.apk.dex
+ patches/sigspoof-ui-global-9.0/services.jar.dex
+ patches/unifiednlp-7.0/services.jar.dex
113 changes: 97 additions & 16 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,133 @@
#!/bin/bash

if [ -z "${SAILFISH}" ]; then
SAILFISH=192.168.2.15
echo -e "\e[33;1mWARNING:\e[0m no address specified, falling back to USB: ${SAILFISH}"
else
echo Looking for Sailfish device at address: ${SAILFISH}
fi

if (( $SSH )); then
echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 0. Establish SSH tunnel
echo -e "\e[34;1m=================================\e[0m"
if ! ssh -L 127.0.0.1:873:127.0.0.1:873 nemo@${SAILFISH} -Nf; then
echo -e "\e[31;1mERROR:\e[0m couldn't start tunnel. falling back to direct connection"
else
echo "SSH Tunnel established"
SSHTUNNELACTIVE=1
SAILFISH=127.0.0.1
fi
fi

set -e
SYSTEM_PATH=system

rsync_error () {
echo -e "\e[31;1mERROR:\e[0m cannot download from rsync daemon"
echo "- Did you remember to start the daemon with option '--address=${SAILFISH}'"
case "${SAILFISH}" in
127.0.0.1)
echo "- Did the tunnel setup abov fail?"
echo "- Alternatively use this docker on a direct connection with '--env SSH=0' instead"
;;
192.168.2.15)
## USB isn't actually blocked by firewall on current versions of Sailfish OS
#echo "- If connected over USB, did you remember to open the firewall port:"
#echo " iptables -A connman-INPUT -i rndis0 -p tcp -m tcp --dport 873 -j ACCEPT"
echo "- Or alternatively use this docker on a SSH tunnel with '--env SSH=1' instead"
;;
*)
echo "- If connected over Wifi, did you remember to open the firewall port:"
echo " iptables -A connman-INPUT -i wlan0 -p tcp -m tcp --dport 873 -j ACCEPT"
echo "- Or alternatively use this docker on a SSH tunnel with '--env SSH=1' instead"
;;
esac
exit 1
}


echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 1. Fetch files via RSYNC
rsync -va \
echo -e "\e[34;1m=================================\e[0m"
rsync -vaP \
rsync://${SAILFISH}/alien/system.img \
/tmp/system.img
/tmp/system.img || rsync_error

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 1.1 unpack the squashfs
echo -e "\e[34;1m=================================\e[0m"
cd /tmp && unsquashfs system.img

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 1.2 get files to patch
mkdir /sailfish
echo -e "\e[34;1m=================================\e[0m"
mkdir -p /sailfish
rsync -va /tmp/squashfs-root/${SYSTEM_PATH}/{framework,app,priv-app} \
/sailfish

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 2. Deodex the vdex and dex files
cd /vdexExtractor/bin && ./vdexExtractor -i /sailfish --ignore-crc-error
echo -e "\e[34;1m=================================\e[0m"
#cd /vdexExtractor/bin && ./vdexExtractor -i /sailfish --ignore-crc-error
cd /vdexExtractor/bin && ./vdexExtractor -i /sailfish/framework/oat/arm/services.vdex --ignore-crc-error
echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 2. add classes.dex to services.jar
echo -e "\e[34;1m=================================\e[0m"
cp /sailfish/framework/oat/arm/services_classes.dex /tmp/classes.dex
zip -j /sailfish/framework/services.jar /tmp/classes.dex

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 3. Apply the patch
echo -e "\e[34;1m=================================\e[0m"
API_VERSION=27
rm -rf /hook
/haystack/patch-fileset /haystack/patches/sigspoof-hook-7.0-9.0 ${API_VERSION} /sailfish/framework /hook
rm -rf /hook_core
/haystack/patch-fileset /haystack/patches/sigspoof-core ${API_VERSION} /hook /hook_core
rm -rf /sailfish/hook
/haystack/patch-fileset /haystack/patches/sigspoof-hook-7.0-9.0 ${API_VERSION} /sailfish/framework /sailfish/hook
rm -rf /sailfish/hook_core
/haystack/patch-fileset /haystack/patches/sigspoof-core ${API_VERSION} /sailfish/hook /sailfish/hook_core
rm -rf /sailfish/hook_unifiednlp
/haystack/patch-fileset /haystack/patches/unifiednlp-7.0 ${API_VERSION} /sailfish/hook_core /sailfish/hook_unifiednlp

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 4. Merge back the results
mv -v /hook_core/* /sailfish/framework/
echo -e "\e[34;1m=================================\e[0m"
mv -v /sailfish/hook_unifiednlp/* /sailfish/framework/

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 5.1 Merge results back
echo -e "\e[34;1m=================================\e[0m"
rsync -va \
/sailfish/framework/ \
/sailfish/framework/services.jar \
/tmp/squashfs-root/${SYSTEM_PATH}/framework/
# rsync -va \
# /sailfish/framework/ \
# /tmp/squashfs-root/${SYSTEM_PATH}/framework/
# rsync -va \
# /sailfish/app/ \
# /tmp/squashfs-root/${SYSTEM_PATH}/app/
# rsync -va \
# /sailfish/priv-app/ \
# /tmp/squashfs-root/${SYSTEM_PATH}/priv-app/

echo [**] 5.2 rebuild squashfs
cd /tmp && mksquashfs squashfs-root system.img.haystack -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments
if [[ "$NOMAPS" != "1" ]]; then
echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 5.1.1 Install MicroG Maps API -- mapsv1
echo -e "\e[34;1m=================================\e[0m"
unzip -d /tmp/squashfs-root/ /mapsv1.flashable.zip 'system/framework/*'
fi

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 5.2 rebuild squashfs
echo -e "\e[34;1m=================================\e[0m"
cd /tmp && mksquashfs squashfs-root system.img.haystack -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments

echo -e "\e[34;1m=================================\e[37;1m"
echo [**] 5. Upload results back
echo -e "\e[34;1m=================================\e[0m"
rsync -vaP --delete-after -b --suffix=".pre_haystack" \
/tmp/system.img.haystack \
rsync://${SAILFISH}/alien/system.img

echo [**] 5. Upload results back
rsync -va --delete-after -b --suffix=".pre_haystack" \
/tmp/system.img.haystack \
rsync://${SAILFISH}/alien/system.img
if (( $SSHTUNNELACTIVE )); then
: #killall -2 ssh
fi