realdtn2 / zalo-linux-unofficial-2024

Unofficial Zalo Linux Port (x86_64)
3 stars 0 forks source link

Vấn đề đồng bộ mã hóa đầu cuối E2EE từ điện thoại #1

Open danielphan2003 opened 1 month ago

danielphan2003 commented 1 month ago

Cảm ơn repo của bác. Em đã viết file PKGBUILD cho Arch dựa trên repo này và đã bật được native tray của Electron bằng cách unpack asar và vá file app/main-dist/main.js:

File PKGBUILD ``` # Maintainer: Daniel Phan pkgname=zalo pkgver=24.9.1 pkgrel=1 pkgdesc='Zalo Desktop app - Nhắn gửi yêu thương' arch=('any') url='https://zalo.me' license=('custom') _electron=electron22 depends=('bash' "${_electron}" 'p7zip' 'asar' 'hicolor-icon-theme') source=("${pkgname}-${pkgver}.dmg::https://res-download-pc-te-vnso-pt-48.zadn.vn/mac/ZaloSetup-universal-${pkgver}.dmg" "${pkgname}.desktop" "${pkgname}.sh") sha256sums=('818eca970dae44a5d776af0345d07566e80f60bae06fddde6dcbbc45fbbfe2ef' '45c133607d60fc749929bde7d6ab698c0423cafdb620f4d7463104afcd3ba969' '992cda0073c9428384b38eddf5cf3506512ee334b32babd39051bb3dd600e7fd') prepare() { sed -i "s/@ELECTRON@/${_electron}/" "${pkgname}.sh" local archive_path="Zalo ${pkgver}-universal/Zalo.app/Contents/Resources" for f in app-update.yml app.asar app.asar.unpacked; do echo "Extracting ${archive_path}/${f}" 7z x "${pkgname}-${pkgver}.dmg" "${archive_path}/${f}" 2>/dev/null || true mv "${archive_path}/${f}" . done rm -rf "Zalo ${pkgver}-universal" } build() { # unpack app asar asar e app.asar app # enable tray menu sed -i "s/if(J()===W){const t=c.Menu;/if(J()===W||J()===K){const t=c.Menu;/" app/main-dist/main.js || echo "Tray menu is disabled due to patch error." # enable tray menu (no asar repack) # sed -i "s/(J()===W)/(J()===K)/" app.asar || echo "Tray menu (no asar unpack) is disabled due to patch error." # Tray menu icon fix sed -i "s/favicon.ico/favicon-16.ico/" app/main-dist/main.js || echo "Tray menu icon fix disabled due to patch error." # enable devtools in tray menu sed -i "s/re()&&r.unshift({/r.unshift({/g" app/main-dist/main.js || echo "Devtools in tray menu disabled due to patch error." # enable devtools for some browser windows sed -i "s/devTools:!1/devTools:!0/g" app/main-dist/main.js || echo "Devtools for some browser windows disabled due to patch error." # repack app asar asar p app app.asar } package() { install -d "${pkgdir}/usr/lib/${pkgname}" for f in app-update.yml app.asar app.asar.unpacked; do cp -r "${srcdir}/${f}" "${pkgdir}/usr/lib/${pkgname}" chmod -R a+rX "${pkgdir}/usr/lib/${pkgname}/${f}" done # cp -r "${srcdir}/app" "${pkgdir}/usr/lib/${pkgname}" # chmod -R a+rX "${pkgdir}/usr/lib/${pkgname}/app" local i_suffix="" for i in 16 32 96 128 256 512; do i_suffix="x${i}.png" if [[ "$i" == 16 ]]; then i_suffix=".ico" elif [[ "$i" == 96 ]]; then i_suffix="x${i}.v1.png" fi install -Dm644 "${srcdir}/app/pc-dist/favicon-${i}${i_suffix}" "${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps/${pkgname}.png" done install -Dm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}" install -Dm644 "${srcdir}/${pkgname}.desktop" -t "${pkgdir}/usr/share/applications" } ```

Khi bắt đầu đồng bộ tin nhắn thì Zalo bị lỗi như sau:

TypeError: Cannot read properties of undefined (reading 'send')
    at sc.send (main-startup.1778f55a0941d7ea8e7d.js:1:296409)
    at oc.sync (main-startup.1778f55a0941d7ea8e7d.js:1:336105)
    at _h.syncMessagesStartSync (main-startup.1778f55a0941d7ea8e7d.js:1:492572)
    at _h.callTransferMessages (main-startup.1778f55a0941d7ea8e7d.js:1:487488)
    at onStartSync (default-login-startup-main-startup-shared-worker.02126021d4ca68818d77.js:1:9425547)
    at onClick (default-login-startup-main-startup-shared-worker.02126021d4ca68818d77.js:1:11374695)
    at Object.u (vendors-login-main-startup-shared-worker-znotification.71b104815f376be9f133.js:1:166555)
    at p (vendors-login-main-startup-shared-worker-znotification.71b104815f376be9f133.js:1:166698)
    at vendors-login-main-startup-shared-worker-znotification.71b104815f376be9f133.js:1:166844
    at v (vendors-login-main-startup-shared-worker-znotification.71b104815f376be9f133.js:1:166930)

Không biết bác có bị hay không nên em nghĩ mình cứ tạo issue rồi bàn thêm. Lỗi này xảy ra ở v24.9.1 và v24.9.3

danielphan2003 commented 1 month ago

Để xác nhận checksum giữa repo hiện tại với file DMG từ Zalo ta có thể chạy script sau:

#!/bin/bash
toplevel="$1"
repo_path="$HOME/src/github.com/realdtn2/zalo-linux-unofficial/Zalo/Zalo/app/$1" # folder app của repo
dir="app-v24.9.1/$1" # đường dẫn tới folder extract từ asar extract
for f in "$dir"/*; do
    filename="$(basename "$f")"
    repo_file="$repo_path/$filename"
    if [[ $filename == login-startup.*.js ]]; then
        repo_file="$(ls $repo_path/login-startup.*.js)"
    elif [[ $filename == default-login-main-startup-shared-worker-znotification.*.js ]]; then
        repo_file="$(ls $repo_path/default-login-main-startup-shared-worker-znotification.*.js)"
    elif [[ $filename == default-login-render-shared-worker.*.js ]]; then
        repo_file="$(ls $repo_path/default-login-render-shared-worker.*.js)"
    elif [[ $filename == default-login-startup-main-startup.*.js ]]; then
        repo_file="$(ls $repo_path/default-login-startup-main-startup.*.js)"
    elif [[ $filename == default-login-startup-main-startup-shared-worker.*.js ]]; then
        repo_file="$(ls $repo_path/default-login-startup-main-startup-shared-worker.*.js)"
    fi

    checksum_repo_file=$(sha256sum "$repo_file" | awk '{ print $1 }')
    checksum_file=$(sha256sum "$f" | awk '{ print $1 }')

    if [[ "$checksum_repo_file" == "$checksum_file" ]]; then
        echo "$filename .. OK"
    else
        echo "$filename .. DIFF"
        npx @biomejs/biome format --write --files-max-size=20000000 "$repo_file"
        npx @biomejs/biome format --write --files-max-size=20000000 "$f"
        difft "$repo_file" "$f"
    fi
done

Ví dụ:

$ bash cmp.sh pc-dist/lazy
0.10688555776004759ed0.js .. OK
12.fadc7ea85a788f93e7cb.js .. OK
37.58e2286805582e3f980b.js .. OK
38.67f1ec6882c9130825bc.js .. OK
39.a90f165e1ab3329a1d8c.js .. OK
40.fc2bfb61fe00db63c149.js .. OK
41.6db3515e1198bc737305.js .. OK
42.07f7ff1884dba0fc940e.js .. OK
43.8cfd6a6b83837153503a.js .. OK
44.44780d77b5c22a7cf097.js .. OK
45.80baa2902d2f38174b38.js .. OK
46.8a88dd4474733345cbe8.js .. OK
47.3ab15a52f306e83d32a3.js .. OK
48.beef79f849f9f284cc65.js .. OK
49.14ffb09af60f77653334.js .. OK
50.bc28144e5345fd739f24.js .. OK
51.ebd711242da66d5b68fe.js .. OK
countries.932300cf9a36152c5ed9.js .. OK
default-login-main-startup-shared-worker.03d9c4cb35695e444f6e.js .. OK
default-login-main-startup-shared-worker-znotification.70ecd6bb8339a78c58fd.js .. OK
default-login-render.61dd636611e58d9d15f7.js .. OK
default-login-render-shared-worker.7646c6bd3c01ee18deff.js .. OK
default-login-render-shared-worker-znotification.00d3487c319de8744739.js .. OK
default-login-startup-main-startup.838381f3353074e58886.js .. OK
default-login-startup-main-startup-shared-worker.02126021d4ca68818d77.js .. OK
default-login-startup-main-startup-shared-worker-znotification.e437bbccf2b050240f86.js .. OK
default-main-startup-shared-worker.5c91269df319dfa18b53.js .. OK
lang-en.56238718443649810e49.js .. OK
lang-vi.726eb5732efe07d13d77.js .. OK
login-startup.c04ff27579bd5199c122.js .. OK
main-startup.1778f55a0941d7ea8e7d.js .. OK
vendors-login-main-startup-shared-worker-znotification.71b104815f376be9f133.js .. OK
vendors-login-render-shared-worker.4e844d2ef930d2cea8da.js .. OK
vendors-login-render-shared-worker-znotification.46ac60a10b2e96dae10a.js .. OK
vendors-login-startup.8fd4eb4c993f541e473e.js .. OK
vendors-login-startup-main-startup-shared-worker.250d489da6f951ef4e23.js .. OK
vendors-login-startup-main-startup-shared-worker-znotification.ff22f534b3cfdae5371a.js .. OK
vendors-main-startup.14bbb8d73a80dcec3390.js .. OK
vendors-main-startup-shared-worker.de52790c93fa781d175b.js .. OK

Script này cần các tool sau: difftastic, sha256sum (coreutils), npx