Please enable Javascript to view the contents

WeChat 官方 Linux 版本实现初探 - 珍惜不知情权

 ·  ☕ 5 分钟

还记得多年前,我是我认识的同龄同行业的人中,最后一个开始使用 WeChat 的。或者说,是最不情愿使用的。究其原因,我当年最 “反感” 的有以下几点:

  • 这么即时方便的通讯工具,进一步严重模糊了工作和生活的边界
  • 这种社交方法,明显是更有利于会展示、更重视展示的人,而不是实干而沉默者。
  • 让有控制话语权的人,或更喜欢利用话语权的人有更多无时无刻都可以全面入侵到生活的可能
  • 没有了说 “不知道” 的空间。手机社交后,什么信息都是假设你已经知道了,很多时间,我更想得到一个不知情权。

不幸的是,我似乎别无选择,除非不再打算在江湖走了。或者,有一些人和我一样不喜欢这种 “社交”。但我未曾在现实中听过多少不满的声音。或者,我们已经习惯于所谓的 “存在即合理”。又或者,合理值多少钱。

有句话叫,如果你改变不了,那么只能好好 “享受”。作为一个长期以 Linux 为日常操作系统的程序员。我对没有 WeChat 官方 Linux 版本 一直 耿耿于怀。Tencent 作为一个商业公司,当然不做亏钱的生意。

因为现在风向变了。Tencent 不得不出了 WeChat 官方 Linux 版本。我不是反向工程的高手,但我的确对这个版本的实现有一些好奇心。所以做了点非常浅的探路。

以 WeChat 的地位,其实有责任去让用户自己导出自己的所有数据,包括通讯录和聊天记录。但……

中华人民共和国个人信息保护法

第四十五条 个人有权向个人信息处理者查阅、复制其个人信息;有本法第十八条第一款、第三十五条规定情形的除外。

个人请求查阅、复制其个人信息的,个人信息处理者应当及时提供。

个人请求将个人信息转移至其指定的个人信息处理者,符合国家网信部门规定条件的,个人信息处理者应当提供转移的途径。

GDPR - Right to data portability

  1. The data subject shall have the right to receive the personal data concerning him or her, which he or she has provided to a controller, in a structured, commonly used and machine-readable format and have the right to transmit those data to another controller without hindrance from the controller to which the personal data have been provided, where:
    1. the processing is based on consent pursuant to point (a) of Article 6(1) or point (a) of Article 9(2) or on a contract pursuant to point (b) of Article 6(1); and
    2. the processing is carried out by automated means.
  2. In exercising his or her right to data portability pursuant to paragraph 1, the data subject shall have the right to have the personal data transmitted directly from one controller to another, where technically feasible.
  3. 1The exercise of the right referred to in paragraph 1 of this Article shall be without prejudice to Article 17. 2That right shall not apply to processing necessary for the performance of a task carried out in the public interest or in the exercise of official authority vested in the controller.
  4. The right referred to in paragraph 1 shall not adversely affect the rights and freedoms of others.

下载地址

static

版本: 4.0.0.30

$ md5sum ~/Downloads/WeChatLinux_x86_64.deb
e01f6a26de588192f238ed7d2a413f05  /home/labile/Downloads/WeChatLinux_x86_64.deb


$ md5sum /usr/bin/wechat
ad94a2986e11efdbed631b0d474a8dae  /usr/bin/wechat

ELF

readelf -a --wide /usr/bin/wechat | less

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  ...
  [13] .qtmetadata       PROGBITS        00000000027e8ce0 27e8ce0 000596 00   A  0   0 32
  [14] .qtmimedatabase   PROGBITS        00000000027ea000 27ea000 0523c6 00   A  0   0 4096
readelf -a --wide /opt/wechat/RadiumWMPF/runtime/WeChatAppEx | less

Runtime

Process

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
ps -e --forest | less

 297437 ?        00:00:17          |   |   \_ wechat
 297484 ?        00:00:00          |   |       \_ WeChatAppEx
 297492 ?        00:00:00          |   |       |   \_ WeChatAppEx
 297576 ?        00:00:26          |   |       |   |   \_ WeChatAppEx
 298989 ?        00:00:39          |   |       |   |   \_ WeChatAppEx
 298995 ?        00:00:00          |   |       |   |       \_ WeChatAppEx
 297493 ?        00:00:00          |   |       |   \_ WeChatAppEx
 297498 ?        00:00:00          |   |       |   |   \_ WeChatAppEx
 298988 ?        00:00:00          |   |       |   |       \_ WeChatAppEx
 297519 ?        00:00:00          |   |       |   \_ WeChatAppEx
 298920 ?        00:00:00          |   |       |   \_ WeChatAppEx
 298878 ?        00:00:00          |   |       \_ wxocr
 298921 ?        00:00:00          |   |       \_ wxplayer
 298929 ?        00:00:00          |   |       \_ wxplayer
ps -ef --forest | less

labile    297437    6036  1 16:45 ?        00:00:16          |   |   \_ /usr/bin/wechat
labile    297484  297437  0 16:45 ?        00:00:00          |   |       \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --log-level=2 --wechat-files-path=/home/labile/Documents/xwechat_files --product-id=1002 --wechat-sub-user-agent=MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63090a13) UnifiedPCLinuxWechat(0xf274001e) --web-translate --client_version=4067688478 --wmpf_root_dir=/home/labile/.xwechat/radium --enable-applet-v3 --no-preload --mojo-platform-channel-handle=3
labile    297492  297484  0 16:45 ?        00:00:00          |   |       |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=zygote --no-zygote-sandbox --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002
labile    297576  297492  1 16:45 ?        00:00:23          |   |       |   |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=gpu-process --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002 --gpu-preferences=******== --use-gl=angle --use-angle=swiftshader-webgl --log-level=2 --disable-mojo-broker --shared-files --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    298989  297492  2 16:46 ?        00:00:35          |   |       |   |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=renderer --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --is-subscription-disorder --wmpf-render-type=0 --product-id=1002 --disable-notifications --log-level=2 --disable-gpu-compositing --lang=zh-CN --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1731024804799846 --disable-mojo-broker --launch-time-ticks=30781799752 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    298995  298989  0 16:46 ?        00:00:00          |   |       |   |       \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=renderer --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --is-subscription-disorder --wmpf-render-type=0 --product-id=1002 --disable-notifications --log-level=2 --disable-gpu-compositing --lang=zh-CN --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1731024804799846 --disable-mojo-broker --launch-time-ticks=30781799752 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    297493  297484  0 16:45 ?        00:00:00          |   |       |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=zygote --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002
labile    297498  297493  0 16:45 ?        00:00:00          |   |       |   |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=zygote --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002
labile    298988  297498  0 16:46 ?        00:00:00          |   |       |   |       \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=renderer --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --wmpf-render-type=7 --product-id=1002 --disable-notifications --log-level=2 --disable-gpu-compositing --lang=zh-CN --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=7 --time-ticks-at-unix-epoch=-1731024804799846 --disable-mojo-broker --launch-time-ticks=30781797948 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    297519  297484  0 16:45 ?        00:00:00          |   |       |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=utility --utility-sub-type=network.mojom.NetworkService --lang=zh-CN --service-sandbox-type=none --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002 --log-level=2 --disable-mojo-broker --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    298920  297484  0 16:46 ?        00:00:00          |   |       |   \_ /opt/wechat/RadiumWMPF/runtime/WeChatAppEx --type=utility --utility-sub-type=flue.mojom.ILinkServiceHost --lang=zh-CN --service-sandbox-type=none --log-level=2 --client_version=4067688478 --enable-crash-reporter --wmpf_root_dir=/home/labile/.xwechat/radium --crashpad-handler-pid=297486 --product-id=1002 --log-level=2 --disable-mojo-broker --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,13416587944454710696,16488867258085082357,262144 --enable-features=NetworkServiceMemoryCache,OverlayScrollbar,WebPredictor,XWorker --disable-features=AudioServiceOutOfProcess,AutoupgradeMixedContent,BackForwardCache,DigitalGoodsApi,HardwareMediaKeyHandling,NotificationTriggers,PeriodicBackgroundSync,TFLiteLanguageDetectionEnabled,Vulkan,WebOTP --variations-seed-version
labile    298878  297437  0 16:46 ?        00:00:00          |   |       \_ /opt/wechat/wxocr --mojo-platform-channel-handle=5 --shared-files --field-trial-handle=0,i,996804859505807634,10597515040161967020,131072
labile    298921  297437  0 16:46 ?        00:00:00          |   |       \_ /opt/wechat/wxplayer --mojo-platform-channel-handle=5 --shared-files --field-trial-handle=0,i,996804859505807634,10597515040161967020,131072
labile    298929  297437  0 16:46 ?        00:00:00          |   |       \_ /opt/wechat/wxplayer --mojo-platform-channel-handle=5 --shared-files --field-trial-handle=0,i,996804859505807634,10597515040161967020,131072

Threads

ps -T -p 297437 | less

    PID    SPID TTY          TIME CMD
 297437  297437 ?        00:00:44 wechat
 297437  297439 ?        00:00:00 wechat
 297437  297440 ?        00:00:00 TracingMuxer
 297437  297442 ?        00:00:00 wechat
 297437  297443 ?        00:00:00 MMMojo IO Threa
 297437  297444 ?        00:00:00 ThreadPoolServi
 297437  297445 ?        00:00:00 ThreadPoolForeg
 297437  297446 ?        00:00:00 MMMojo IPC Thre
 297437  297447 ?        00:00:00 ThreadPoolServi
 297437  297449 ?        00:00:00 Msg Db Writer
 297437  297450 ?        00:00:00 ThreadPoolSingl
 297437  297451 ?        00:00:00 wechat
 297437  297452 ?        00:00:32 coroutine
 297437  297453 ?        00:00:00 wechat
 297437  297454 ?        00:00:00 wechat
 297437  297455 ?        00:00:00 wechat
 297437  297456 ?        00:00:02 wechat
 297437  297457 ?        00:00:00 wechat
 297437  297458 ?        00:00:00 wechat
 297437  297460 ?        00:00:00 wechat
 297437  297461 ?        00:00:00 andromeda::quic
 297437  297462 ?        00:00:00 andromeda::quic
 297437  297463 ?        00:00:00 andromeda::quic
 297437  297466 ?        00:00:00 TaskSchedulerSe
 297437  297467 ?        00:00:00 TaskSchedulerFo
 297437  297469 ?        00:00:00 TaskSchedulerSi
 297437  297470 ?        00:00:00 NetworkChangeNo
 297437  297473 ?        00:00:00 inotify_reader
 297437  297475 ?        00:00:00 TaskSchedulerFo
 297437  297477 ?        00:00:01 QXcbEventQueue
 297437  297478 ?        00:00:00 QDBusConnection
 297437  297479 ?        00:00:00 task_thread
 297437  297481 ?        00:00:00 xlog_thread
 297437  297482 ?        00:00:00 webview_io_thre
 297437  297483 ?        00:00:00 wechat_browser_
 297437  297495 ?        00:00:00 mmui::utility::
 297437  297514 ?        00:00:00 xplugin_logic
 297437  297821 ?        00:00:00 coroutine
 297437  298565 ?        00:00:00 WCDB.Operation
 297437  298853 ?        00:00:00 AudioDeviceBuff
 297437  298854 ?        00:00:00 threaded-ml
 297437  298855 ?        00:00:00 webrtc_audio_mo
 297437  298856 ?        00:00:00 webrtc_audio_mo
 297437  298857 ?        00:00:00 AudioDeviceBuff
 297437  298858 ?        00:00:00 threaded-ml
 297437  298859 ?        00:00:00 webrtc_audio_mo
 297437  298860 ?        00:00:00 webrtc_audio_mo
 297437  298861 ?        00:00:00 AudioDeviceBuff
 297437  298862 ?        00:00:00 threaded-ml
 297437  298863 ?        00:00:00 webrtc_audio_mo
 297437  298864 ?        00:00:00 webrtc_audio_mo
 297437  298865 ?        00:00:00 AudioDeviceBuff
 297437  298866 ?        00:00:00 threaded-ml
 297437  298867 ?        00:00:00 webrtc_audio_mo
 297437  298868 ?        00:00:00 webrtc_audio_mo
 297437  298871 ?        00:00:00 wechat
 297437  298872 ?        00:00:00 ilink2_cloud_lp
 297437  298874 ?        00:00:00 MMMojo RW Threa
 297437  298875 ?        00:00:00 MMMojo RW Sync 
 297437  298877 ?        00:00:00 ThreadPoolSingl
 297437  298909 ?        00:00:00 ui Watchdog
 297437  298910 ?        00:00:00 ThreadPoolSingl
 297437  298911 ?        00:00:00 coroutine Watch
 297437  298914 ?        00:00:00 MMMojo RW Threa
 297437  298915 ?        00:00:00 MMMojo RW Sync 
 297437  298916 ?        00:00:00 MMMojo RW Set T
 297437  298917 ?        00:00:00 MMMojo RW Threa
 297437  298918 ?        00:00:00 MMMojo RW Sync 
 297437  298919 ?        00:00:00 MMMojo RW Set T
 297437  298951 ?        00:00:00 AudioDeviceBuff
 297437  298952 ?        00:00:00 threaded-ml
 297437  298970 ?        00:00:00 webrtc_audio_mo
 297437  298971 ?        00:00:00 webrtc_audio_mo
 297437  299006 ?        00:00:00 AudioDeviceBuff
 297437  299007 ?        00:00:00 threaded-ml
 297437  299008 ?        00:00:00 webrtc_audio_mo
 297437  299009 ?        00:00:00 webrtc_audio_mo
 297437  298970 ?        00:00:00 webrtc_audio_mo
 297437  298971 ?        00:00:00 webrtc_audio_mo
 297437  299006 ?        00:00:00 AudioDeviceBuff
 297437  299007 ?        00:00:00 threaded-ml
 297437  299008 ?        00:00:00 webrtc_audio_mo
 297437  299009 ?        00:00:00 webrtc_audio_mo
 297437  299328 ?        00:00:00 andromeda::quic
 297437  332107 ?        00:00:01 Emoticon Logic 
 297437  332108 ?        00:00:00 Emoticon Common
 297437  376789 ?        00:00:00 coroutine
 297437  537099 ?        00:00:00 wechat
 297437  590038 ?        00:00:00 ThreadPoolForeg
 297437  593795 ?        00:00:00 xplugin_io_thre

Memory maps

/opt/wechat/libwxtrans.so
lrw------- 1 labile labile 64 Nov  8 21:19 73cdc827d000-73cdc829d000 -> '/dev/shm/.org.chromium.Chromium.0yxAVT (deleted)'
lrw------- 1 labile labile 64 Nov  8 21:19 73cdc829d000-73cdc82bd000 -> '/dev/shm/.org.chromium.Chromium.QRTdfR (deleted)'
lrw------- 1 labile labile 64 Nov  8 21:19 73cdc82bd000-73cdc82dd000 -> '/dev/shm/.org.chromium.Chromium.f3Kzdk (deleted)'
lrw------- 1 labile labile 64 Nov  8 21:19 73cdc82dd000-73cdc82fd000 -> '/dev/shm/.org.chromium.Chromium.p0rIXR (deleted)'
lr-------- 1 labile labile 64 Nov  8 21:19 73cdcd8d9000-73cdcd965000 -> /usr/lib/x86_64-linux-gnu/libX11.so.6.4.0

GDB

Thread 1 "wechat" received signal SIGINT, Interrupt.
0x000073cdc4518bcf in __GI___poll (fds=0x19a4011988c0, nfds=3, timeout=100) at ../sysdeps/unix/sysv/linux/poll.c:29
29	in ../sysdeps/unix/sysv/linux/poll.c
(gdb) thread
[Current thread is 1 (Thread 0x73cdccb9e1c0 (LWP 297437))]
(gdb) bt
#0  0x000073cdc4518bcf in __GI___poll (fds=0x19a4011988c0, nfds=3, timeout=100) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x000073cdce471256 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x000073cdce4193e3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x0000590aadcc4267 in ?? ()
#4  0x0000590aace7a270 in ?? ()
#5  0x0000590aace8b747 in ?? ()
#6  0x0000590aacf38af9 in ?? ()
#7  0x000073cdc4429d90 in __libc_start_call_main (main=main@entry=0x590aacd62170, argc=argc@entry=1, argv=argv@entry=0x7fff10400228)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#8  0x000073cdc4429e40 in __libc_start_main_impl (main=0x590aacd62170, argc=1, argv=0x7fff10400228, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fff10400218) at ../csu/libc-start.c:392
#9  0x0000590aacd6002a in ?? ()


p (pollfd*)0x19a4011988c0
p *((int*)0x19a4011988c0)
(gdb) p *((int*)0x19a4011988c0)
$2 = 6

$ ll /proc/297437/fd
lrwx------ 1 labile labile 64 Nov  8 16:46 6 -> 'anon_inode:[eventfd]'
         Address Perm   Offset Device    Inode     Size    Rss    Pss Pss_Dirty Referenced Anonymous KSM LazyFree ShmemPmdMapped FilePmdMapped Shared_Hugetlb Private_Hugetlb Swap SwapPss Locked THPeligible ProtectionKey Mapping

    590aa98e3000 r--p 00000000 103:07  7440092    53744  28404  28174         0      28404         0   0        0              0             0              0               0    0       0      0           0             0 wechat
    590aacd60000 r-xp 0347c000 103:07  7440092    94940  87260  87260         0      87260         0   0        0              0             0              0               0    0       0      0           0             0 wechat
    590ab2a17000 r--p 09132000 103:07  7440092     2100   2100   2100      2100       2100      2100   0        0              0             0              0               0    0       0      0           0             0 wechat
    590ab2c24000 rw-p 0933e000 103:07  7440092     1116    872    872       476        872       476   0        0              0             0              0               0    0       0      0           0             0 wechat

lr-------- 1 labile labile 64 Nov  8 21:19 590aa98e3000-590aacd5f000 -> /opt/wechat/wechat
lr-------- 1 labile labile 64 Nov  8 21:19 590aacd60000-590ab2a17000 -> /opt/wechat/wechat
lr-------- 1 labile labile 64 Nov  8 21:19 590ab2a17000-590ab2c24000 -> /opt/wechat/wechat
lr-------- 1 labile labile 64 Nov  8 21:19 590ab2c24000-590ab2d3b000 -> /opt/wechat/wechat



find 0x590aa98e3000, 0x590aacd5efff, "sqlite"
0x590aaf561d8a

参考

分享

Mark Zhu
作者
Mark Zhu
An old developer