Skip to content

Commit

Permalink
🚑️ fix potential bricking issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NahidaBuer committed Dec 7, 2023
1 parent a5fdbea commit 5c58995
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 268 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This is a basic workflow to help you get started with Actions

name: Archive the Magisk Module

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Archive
run: 7z a -xr'!*LICENSE*|.git*' -tzip ./HttpCanary-SSL-Magisk-A14.zip ./*
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: latest
files: ./HttpCanary-SSL-Magisk-A14.zip
171 changes: 4 additions & 167 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.0+! "
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}
Expand All @@ -27,170 +27,7 @@ mount /data 2>/dev/null

[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20000 ] && require_new_magisk
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk

if [ $MAGISK_VER_CODE -ge 20400 ]; then
# New Magisk have complete installation logic within util_functions.sh
install_module
exit 0
fi

#################
# Legacy Support
#################

TMPDIR=/dev/tmp
PERSISTDIR=/sbin/.magisk/mirror/persist

is_legacy_script() {
unzip -l "$ZIPFILE" install.sh | grep -q install.sh
return $?
}

print_modname() {
local authlen len namelen pounds
namelen=`echo -n $MODNAME | wc -c`
authlen=$((`echo -n $MODAUTH | wc -c` + 3))
[ $namelen -gt $authlen ] && len=$namelen || len=$authlen
len=$((len + 2))
pounds=$(printf "%${len}s" | tr ' ' '*')
ui_print "$pounds"
ui_print " $MODNAME "
ui_print " by $MODAUTH "
ui_print "$pounds"
ui_print "*******************"
ui_print " Powered by Magisk "
ui_print "*******************"
}

# Override abort as old scripts have some issues
abort() {
ui_print "$1"
$BOOTMODE || recovery_cleanup
[ -n $MODPATH ] && rm -rf $MODPATH
rm -rf $TMPDIR
exit 1
}

rm -rf $TMPDIR 2>/dev/null
mkdir -p $TMPDIR

# Preperation for flashable zips
setup_flashable

# Mount partitions
mount_partitions

# Detect version and architecture
api_level_arch_detect

# Setup busybox and binaries
$BOOTMODE && boot_actions || recovery_actions

##############
# Preparation
##############

# Extract prop file
unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!"

$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
MODULEROOT=$NVBASE/$MODDIRNAME
MODID=`grep_prop id $TMPDIR/module.prop`
MODNAME=`grep_prop name $TMPDIR/module.prop`
MODAUTH=`grep_prop author $TMPDIR/module.prop`
MODPATH=$MODULEROOT/$MODID

# Create mod paths
rm -rf $MODPATH 2>/dev/null
mkdir -p $MODPATH

##########
# Install
##########

if is_legacy_script; then
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2

# Load install script
. $TMPDIR/install.sh

# Callbacks
print_modname
on_install

# Custom uninstaller
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh

# Skip mount
$SKIPMOUNT && touch $MODPATH/skip_mount

# prop file
$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop

# Module info
cp -af $TMPDIR/module.prop $MODPATH/module.prop

# post-fs-data scripts
$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh

# service scripts
$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh

ui_print "- Setting permissions"
set_permissions
else
print_modname

unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2

if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then
ui_print "- Extracting module files"
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2

# Default permissions
set_perm_recursive $MODPATH 0 0 0755 0644
fi

# Load customization script
[ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh
fi

# Handle replace folders
for TARGET in $REPLACE; do
ui_print "- Replace target: $TARGET"
mktouch $MODPATH$TARGET/.replace
done

if $BOOTMODE; then
# Update info for Magisk Manager
mktouch $NVBASE/modules/$MODID/update
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
fi

# Copy over custom sepolicy rules
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
ui_print "- Installing custom sepolicy patch"
# Remove old recovery logs (which may be filling partition) to make room
rm -f $PERSISTDIR/cache/recovery/*
PERSISTMOD=$PERSISTDIR/magisk/$MODID
mkdir -p $PERSISTMOD
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule || abort "! Insufficient partition size"
fi

# Remove stuffs that don't belong to modules
rm -rf \
$MODPATH/system/placeholder $MODPATH/customize.sh \
$MODPATH/README.md $MODPATH/.git* 2>/dev/null

#############
# Finalizing
#############

cd /
$BOOTMODE || recovery_cleanup
rm -rf $TMPDIR

ui_print "- Done"
exit 0
install_module
exit 0
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

HttpCanary bundled with the certificate, which works out of the box.

### 更新日志

2023.12.07 微调了挂载证书目录的方式,丢弃屎山代码,现在应该更加不容易变砖了。

2023.12.07 Fine-tuned the method of mounting certificate directories, discarded unnecessary code. It should now be less prone to bricking.

### 使用方法 / Usage

直接在原版 Magisk 中刷入即可,模块中已包含 HttpCanary 安装包。
只在原版中测试通过,其他版本自行尝试。
先手动安装 HttpCanary。Android 12+ 用户必须使用 3.3.5 版本。安装完毕后,使用 Magisk 刷入即可。

Just install zip module in original Magisk, HttpCanary apks included.
Only tested on original Magisk, try yourself on other versions.
First, install HttpCanary manually. Note: Android 12+ users MUST use 3.3.5 version. After installation, flash this module using Magisk.

### Tested on
|Android Version|HttpCanary Version|
|-|-|
Android 11|3.3.6 Premium
Android 12.1|3.3.5
Android 13|3.3.5
Android 14|3.3.5
|Android Version|HttpCanary Version|Magisk Version|
|-|-|-|
Android 14|3.3.5|Magisk (Official)
Android 14|3.3.5|Magisk (Delta)
21 changes: 21 additions & 0 deletions certs/87bc3517.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDczCCAlugAwIBAgIHANaU/IC4ZzANBgkqhkiG9w0BAQ0FADBHMRswGQYDVQQD
DBJIdHRwQ2FuYXJ5IFJvb3QgQ0ExEzARBgNVBAoMCkh0dHBDYW5hcnkxEzARBgNV
BAsMCkh0dHBDYW5hcnkwHhcNMjAwNzMwMTAxMTAyWhcNMzEwNzI4MTAxMTAyWjBH
MRswGQYDVQQDDBJIdHRwQ2FuYXJ5IFJvb3QgQ0ExEzARBgNVBAoMCkh0dHBDYW5h
cnkxEzARBgNVBAsMCkh0dHBDYW5hcnkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQC35mP15BusTN5ThWp01nsWzldv3L176rdPUL7hJgBgr4orcuYRUfzg
GAJgioxCx5TWvnSgE2GQPJxEVOqQaEb3oDr+Crn525sgpyh1wfajSlTz6pUkvfuU
n1p5+4biTNmqjllSa7dTBs1z9FdLgMYhxo9FBdee3KG0K0tgwejr8n1obfP6fCg7
hepMgO+hJAdqYn2LTKjnAgH0IeXVW8tS8H37P5FAW1eCOqL75ZhD2Ly4j0xxmzUc
YDJ7xewXTu37U/9ieVEvmwicuMsEHOHUBaLJ3jkIBK4cdB0H0dXCuXSEEMrPp5XV
Vkrg/T9pzqWdiplvL3raKtfp7oeEv8CVAgMBAAGjZDBiMB0GA1UdDgQWBBSnBzwC
f28/ZASyS8n0ShqunZJUmDAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBtjAj
BgNVHSUEHDAaBggrBgEFBQcDAQYIKwYBBQUHAwIGBFUdJQAwDQYJKoZIhvcNAQEN
BQADggEBAC03n4n5/xbJfvitDCeTKP1K4hetEYE9Aqzz/EbWHiLMBbVK0cjs6P7W
NSAMa4dlkXXwChcjUTDJmnEnBQFkxr4mzu3598U1PzRxxUMnkfitKjt5ITsxmwSq
gR2/cvDy5yMYFEwtV2o7wqdXPc9/jmwmrIl1mqZtV0vZ+o83lC1uYmnbDJQS03+C
5HkGYYzhaGik/RoxI+nDhcIne0tSyrlL76Y0YQgiRykOeYJPJqEGqq6ahgbpdOms
CKhgJ7yLlzvCAyX5xR8YduZoWU7G8beKbV1+pyXpOfO06IcFrthnh1PGT+AoTufW
C6gcx5vvG4w48BkI0QRLOQkUzUKiQws=
-----END CERTIFICATE-----
Empty file added certs/HttpCanary.jks
Empty file.
Binary file added certs/HttpCanary.p12
Binary file not shown.
21 changes: 21 additions & 0 deletions certs/HttpCanary.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDcjCCAlqgAwIBAgIGJNNl58gVMA0GCSqGSIb3DQEBDQUAMEcxGzAZBgNVBAMM
Ekh0dHBDYW5hcnkgUm9vdCBDQTETMBEGA1UECgwKSHR0cENhbmFyeTETMBEGA1UE
CwwKSHR0cENhbmFyeTAeFw0yMDA3MjYxNDA0MjdaFw0zMTA3MjQxNDA0MjdaMEcx
GzAZBgNVBAMMEkh0dHBDYW5hcnkgUm9vdCBDQTETMBEGA1UECgwKSHR0cENhbmFy
eTETMBEGA1UECwwKSHR0cENhbmFyeTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAM7ObxiIXUfvLzh8GjG/clik1SdWD1e6L4B4xpSedNN9+weZW94tvNLX
LXc/3//0klhcUb+T5T+xifNEipp5ku+FLrv/QJyF3WEF85mT1pgdoBq9u/t1VxyR
4ViwVqqw1/9XCJdAwuLGEgYyGMt4vjtuUNJ5AF16QvWXdzJGxxvWaKs5rLNGBYqy
p0bZ6LmwJcU9Pid7EuxaeGmAWfk9Z/zeXiLzTB28WVqYi/TvgrbFFjaxJDM6ILBw
arutV/MJ6joTBU6ZC+O8UjPTLNXbZJDsq2dQYoN1N6d3Wl239theJP22ro9gma/6
575iigFZ35q6pvudSg9UTNfKBLrmickCAwEAAaNkMGIwHQYDVR0OBBYEFLe3jQNN
m/WGmQY2llu1iKEqdq9UMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgG2MCMG
A1UdJQQcMBoGCCsGAQUFBwMBBggrBgEFBQcDAgYEVR0lADANBgkqhkiG9w0BAQ0F
AAOCAQEAVxJKLDYLjUuiqgw8iY1se3TDqfD8GRms4RN0miw/wIPT3jMeRLAN/IOQ
r6XR8WYqPmmlxzKc7W3CvS0Ud7XtOmljo2gT4yR5pjC41HnHgLbL9zAZ53Ye9o1O
2gK910bRoCPhiuC9u1mudDV9U7zJuzu73zVWGa/qcskwCHUNjmONNyPho9HQmb05
knMD3+i8gFgoY5JN/jjiikLgQ0IO4ltjNHsbhWJtiA+1+nxjIlwWDqopOgwfaRqg
nLkVSaYMupb1udf9xPmlfWq4XPg1CVBZo47gJCSuSjayaxjIhgU5Mybs6QoRK6ez
qNK7SCZRnSxux+iF3WxkBl5fr+IG9A==
-----END CERTIFICATE-----
87 changes: 19 additions & 68 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -1,68 +1,19 @@
##########################################################################################
#
# MMT Extended Config Script
#
##########################################################################################

##########################################################################################
# Config Flags
##########################################################################################

# Uncomment and change 'MINAPI' and 'MAXAPI' to the minimum and maximum android version for your mod
# Uncomment DYNLIB if you want libs installed to vendor for oreo+ and system for anything older
# Uncomment DEBUG if you want full debug logs (saved to /sdcard)
#MINAPI=21
#MAXAPI=25
#DYNLIB=true
#DEBUG=true

##########################################################################################
# Replace list
##########################################################################################

# List all directories you want to directly replace in the system
# Check the documentations for more info why you would need this

# Construct your list in the following format
# This is an example
REPLACE_EXAMPLE="
/system/app/Youtube
/system/priv-app/SystemUI
/system/priv-app/Settings
/system/framework
"

# Construct your own list here
REPLACE="
"

##########################################################################################
# Permissions
##########################################################################################

set_permissions() {
: # Remove this if adding to this function

# Note that all files/folders in magisk module directory have the $MODPATH prefix - keep this prefix on all of your files/folders
# Some examples:

# For directories (includes files in them):
# set_perm_recursive <dirname> <owner> <group> <dirpermission> <filepermission> <contexts> (default: u:object_r:system_file:s0)

# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
# set_perm_recursive $MODPATH/system/vendor/lib/soundfx 0 0 0755 0644

# For files (not in directories taken care of above)
# set_perm <filename> <owner> <group> <permission> <contexts> (default: u:object_r:system_file:s0)

# set_perm $MODPATH/system/lib/libart.so 0 0 0644
# set_perm /data/local/tmp/file.txt 0 0 644
}

##########################################################################################
# MMT Extended Logic - Don't modify anything after this
##########################################################################################

SKIPUNZIP=1
unzip -qjo "$ZIPFILE" 'common/functions.sh' -d $TMPDIR >&2
. $TMPDIR/functions.sh
#!/system/bin/sh

CERTS_DIR=${MODPATH}/certs
APP_VER_335=/data/data/com.guoshi.httpcanary
APP_VER_336=/data/data/com.guoshi.httpcanary.premium

if [ -d ${APP_VER_335} ]; then
echo "HttpCanary 3.3.5 detected, copying certs..."
cp $CERTS_DIR/* $APP_VER_335/cache/
fi
if [ -d ${APP_VER_336} ]; then
echo "HttpCanary 3.3.6 detected, copying certs..."
cp $CERTS_DIR/* $APP_VER_336/cache/
fi

ui_print $MODPATH
ui_print "安装成功, 重启手机后去系统证书查看证书是否生效。"
ui_print "问题反馈: "
ui_print "https://github.com/NahidaBuer/HttpCanary-SSL-Magisk-A14/issues"
8 changes: 4 additions & 4 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=HttpCanaryBundle
name=HttpCanary
version=v3.3.6.1
versionCode=9
author=FeliciaWen&Nahida
version=v3.3.6.3
versionCode=15
author=Nahida
description=HttpCanary Certificate Bundle
support=https://github.com/wmyfelix
support=https://github.com/NahidaBuer/HttpCanary-SSL-Magisk-A14
Loading

0 comments on commit 5c58995

Please sign in to comment.