feat: Telegram 双通道抓取、PC 调试台与 Hook 后台转发修复
v2.2.1 更新说明: - 新增 xposed-module(Telegram/微信/SQLite Hook),双 APK + LSPosed 作用域 - HookMessageReceiver 后台直接 DebugForwarder + goAsync,修复 notiMessage 退后台丢消息 - MessageLogStore 日志持久化;AppConfig 调试/上传开关;PC 调试台 debug-server - 健康检查去掉联网限制;通知/Hook 通道增加诊断日志 - 安装脚本 install-full/configure-lsposed/start-debug-server;文档 CHANGELOG + HOOK_GUIDE
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Build debug APK for notiMessage
|
||||
# Build debug APKs for notiMessage (app + xposed-module)
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $ProjectRoot
|
||||
@@ -6,14 +6,21 @@ Set-Location $ProjectRoot
|
||||
$env:JAVA_HOME = "C:\Program Files\Java\jdk-17"
|
||||
$javaHomeArg = "-Dorg.gradle.java.home=C:\Program Files\Java\jdk-17"
|
||||
Write-Host "JAVA_HOME=$env:JAVA_HOME"
|
||||
Write-Host "Building debug APK..."
|
||||
& "$ProjectRoot\gradlew.bat" $javaHomeArg assembleDebug
|
||||
Write-Host "Building debug APKs..."
|
||||
& "$ProjectRoot\gradlew.bat" $javaHomeArg :app:assembleDebug :xposed-module:assembleDebug
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
$apk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
|
||||
if (Test-Path $apk) {
|
||||
Write-Host ""
|
||||
Write-Host "Build OK: $apk"
|
||||
$appApk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
|
||||
$xposedApk = Join-Path $ProjectRoot "xposed-module\build\outputs\apk\debug\xposed-module-debug.apk"
|
||||
|
||||
Write-Host ""
|
||||
if (Test-Path $appApk) {
|
||||
Write-Host "App OK: $appApk"
|
||||
} else {
|
||||
Write-Host "Build finished but APK not found at expected path." -ForegroundColor Yellow
|
||||
Write-Host "App APK not found." -ForegroundColor Yellow
|
||||
}
|
||||
if (Test-Path $xposedApk) {
|
||||
Write-Host "Xposed OK: $xposedApk"
|
||||
} else {
|
||||
Write-Host "Xposed APK not found." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
31
scripts/configure-lsposed.py
Normal file
31
scripts/configure-lsposed.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
db_path = sys.argv[1]
|
||||
apk_path = sys.argv[2]
|
||||
hook_pkg = "com.miraclegarden.smsmessage.xposed"
|
||||
scopes = [
|
||||
"org.telegram.messenger.web",
|
||||
"org.telegram.messenger",
|
||||
"com.miraclegarden.smsmessage",
|
||||
]
|
||||
|
||||
shutil.copy2(db_path, db_path + ".bak")
|
||||
conn = sqlite3.connect(db_path)
|
||||
c = conn.cursor()
|
||||
|
||||
c.execute(
|
||||
"INSERT OR REPLACE INTO modules (mid, module_pkg_name, apk_path, enabled, auto_include) "
|
||||
"VALUES (?, ?, ?, ?, ?)",
|
||||
(2, hook_pkg, apk_path, 1, 0),
|
||||
)
|
||||
c.execute("DELETE FROM scope WHERE mid = 2")
|
||||
for pkg in scopes:
|
||||
c.execute(
|
||||
"INSERT OR REPLACE INTO scope (mid, app_pkg_name, user_id) VALUES (?, ?, ?)",
|
||||
(2, pkg, 0),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
print("configured", hook_pkg, "scopes=", scopes)
|
||||
@@ -1,10 +1,11 @@
|
||||
# Install debug APK to connected Android device via adb
|
||||
# Install debug APKs to connected Android device via adb
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
$apk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
|
||||
$appApk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
|
||||
$xposedApk = Join-Path $ProjectRoot "xposed-module\build\outputs\apk\debug\xposed-module-debug.apk"
|
||||
|
||||
if (-not (Test-Path $apk)) {
|
||||
Write-Host "APK not found. Run scripts\build-debug.ps1 first." -ForegroundColor Red
|
||||
if (-not (Test-Path $appApk)) {
|
||||
Write-Host "App APK not found. Run scripts\build-debug.ps1 first." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -16,8 +17,25 @@ if (-not (Test-Path $adb)) {
|
||||
}
|
||||
|
||||
& $adb devices
|
||||
Write-Host "Installing $apk ..."
|
||||
& $adb install -r $apk
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Install OK." -ForegroundColor Green
|
||||
Write-Host "Installing app: $appApk ..."
|
||||
& $adb shell settings put global verifier_verify_adb_installs 0 2>$null
|
||||
& $adb install -r -t -g $appApk
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Retry install with --bypass-low-target-sdk-block ..."
|
||||
& $adb install -r -t -g --bypass-low-target-sdk-block $appApk
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
if (Test-Path $xposedApk) {
|
||||
Write-Host "Installing xposed module: $xposedApk ..."
|
||||
& $adb install -r -t -g $xposedApk
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
& $adb install -r -t -g --bypass-low-target-sdk-block $xposedApk
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
} else {
|
||||
Write-Host "Xposed APK not found, skipped." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host "Install OK." -ForegroundColor Green
|
||||
Write-Host "Remember to enable the module in LSPosed and scope Telegram + notiMessage."
|
||||
|
||||
5
scripts/install-from-studio.ps1
Normal file
5
scripts/install-from-studio.ps1
Normal file
@@ -0,0 +1,5 @@
|
||||
# 在 Android Studio 中安装完整版(主 App + Xposed 模块)
|
||||
# 用法: Run 选 app 只会装主包;完整版请运行此脚本或 install-full.ps1
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
& "$PSScriptRoot\install-full.ps1"
|
||||
72
scripts/install-full.ps1
Normal file
72
scripts/install-full.ps1
Normal file
@@ -0,0 +1,72 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $ProjectRoot
|
||||
|
||||
$sdk = "C:\Users\Administrator\AppData\Local\Android\Sdk"
|
||||
$adb = Join-Path $sdk "platform-tools\adb.exe"
|
||||
if (-not (Test-Path $adb)) {
|
||||
Write-Host "adb not found: $adb" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "=== Step 1/5 Build ===" -ForegroundColor Cyan
|
||||
& "$ProjectRoot\scripts\build-debug.ps1"
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
$appApk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
|
||||
$xposedApk = Join-Path $ProjectRoot "xposed-module\build\outputs\apk\debug\xposed-module-debug.apk"
|
||||
|
||||
Write-Host "`n=== Step 2/5 Device ===" -ForegroundColor Cyan
|
||||
& $adb devices
|
||||
$device = (& $adb devices | Select-String "device$" | Select-Object -First 1)
|
||||
if (-not $device) {
|
||||
Write-Host "No authorized adb device" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "`n=== Step 3/5 Install APKs ===" -ForegroundColor Cyan
|
||||
& $adb shell settings put global verifier_verify_adb_installs 0 2>$null
|
||||
& $adb install -r -t -g $appApk
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
& $adb install -r -t -g --bypass-low-target-sdk-block $appApk
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
& $adb install -r -t -g $xposedApk
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
& $adb install -r -t -g --bypass-low-target-sdk-block $xposedApk
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Host "`n=== Step 4/5 LSPosed scope ===" -ForegroundColor Cyan
|
||||
$apkPath = (& $adb shell pm path com.miraclegarden.smsmessage.xposed 2>$null) -replace '^package:', ''
|
||||
$apkPath = $apkPath.Trim()
|
||||
if (-not $apkPath) {
|
||||
Write-Host "Failed to get xposed module path" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "xposed apk: $apkPath"
|
||||
|
||||
& $adb shell "su -c 'cp /data/adb/lspd/config/modules_config.db /sdcard/Download/modules_config.db; cp /data/adb/lspd/config/modules_config.db-wal /sdcard/Download/modules_config.db-wal 2>/dev/null; cp /data/adb/lspd/config/modules_config.db-shm /sdcard/Download/modules_config.db-shm 2>/dev/null; chmod 644 /sdcard/Download/modules_config.db*'"
|
||||
$db = Join-Path $env:TEMP "modules_config_full.db"
|
||||
$prevEap = $ErrorActionPreference
|
||||
$ErrorActionPreference = "Continue"
|
||||
& $adb pull /sdcard/Download/modules_config.db $db 2>&1 | Out-Null
|
||||
& $adb pull /sdcard/Download/modules_config.db-wal "$db-wal" 2>&1 | Out-Null
|
||||
& $adb pull /sdcard/Download/modules_config.db-shm "$db-shm" 2>&1 | Out-Null
|
||||
$ErrorActionPreference = $prevEap
|
||||
python "$ProjectRoot\scripts\configure-lsposed.py" $db $apkPath
|
||||
& $adb push $db /sdcard/Download/modules_config.db | Out-Null
|
||||
& $adb shell "su -c 'cp /sdcard/Download/modules_config.db /data/adb/lspd/config/modules_config.db; rm -f /data/adb/lspd/config/modules_config.db-wal /data/adb/lspd/config/modules_config.db-shm; chmod 660 /data/adb/lspd/config/modules_config.db'"
|
||||
|
||||
Write-Host "`n=== Step 5/5 System tweaks ===" -ForegroundColor Cyan
|
||||
& $adb reverse tcp:8765 tcp:8765 2>$null
|
||||
& $adb shell "su -c 'dumpsys deviceidle whitelist +com.miraclegarden.smsmessage'" 2>$null
|
||||
& $adb shell "cmd notification allow_listener com.miraclegarden.smsmessage/com.miraclegarden.smsmessage.service.NotificationService" 2>$null
|
||||
& $adb shell "am force-stop org.telegram.messenger.web"
|
||||
& $adb shell "am force-stop com.miraclegarden.smsmessage"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Full install done." -ForegroundColor Green
|
||||
Write-Host "Installed: app + xposed module"
|
||||
Write-Host "Configured: LSPosed scope, adb reverse, battery whitelist, notification listener"
|
||||
Write-Host "Next: open notiMessage -> start monitoring -> reopen Telegram"
|
||||
18
scripts/start-debug-server.ps1
Normal file
18
scripts/start-debug-server.ps1
Normal file
@@ -0,0 +1,18 @@
|
||||
# 启动 PC 调试转发服务
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
$Server = Join-Path $ProjectRoot "debug-server\server.py"
|
||||
|
||||
$sdk = "C:\Users\Administrator\AppData\Local\Android\Sdk"
|
||||
$adb = Join-Path $sdk "platform-tools\adb.exe"
|
||||
if (Test-Path $adb) {
|
||||
Write-Host "Setting adb reverse tcp:8765 ..."
|
||||
& $adb reverse tcp:8765 tcp:8765 2>$null
|
||||
}
|
||||
|
||||
Write-Host "Starting debug server on http://127.0.0.1:8765"
|
||||
if (Get-Command py -ErrorAction SilentlyContinue) {
|
||||
py -3 $Server
|
||||
} else {
|
||||
python $Server
|
||||
}
|
||||
Reference in New Issue
Block a user