ray's Notes

Read The Fucking Source Code.

0%

Line Chat 使用 conscrypt 做 SSL,按照导出 SSL KEY 的方法,可以获取到用于 WireShark 解密 SSL 流量。

1
2
3
4
5
6
7
8
9
10
11
blueline:/ $ su
blueline:/ # ps -ef | grep line
root 3491 1 0 13:59:46 ? 00:02:30 thermal-engine -c /vendor/etc/thermal-engine-blueline-novr-prod.conf
u0_a273 15116 1274 3 15:52:50 ? 00:06:30 jp.naver.line.android
root 31788 31563 23 19:34:19 8ex/.magisk/pts/0 00:00:00 grep line
blueline:/ # cat /proc/15116/maps | grep ssl
795e0c2000-795e0de000 r--p 00000000 fd:11 31 /apex/com.android.conscrypt/lib64/libssl.so
795e0de000-795e11a000 r-xp 0001c000 fd:11 31 /apex/com.android.conscrypt/lib64/libssl.so
795e11a000-795e11d000 r--p 00058000 fd:11 31 /apex/com.android.conscrypt/lib64/libssl.so
795e11d000-795e11e000 rw-p 0005a000 fd:11 31 /apex/com.android.conscrypt/lib64/libssl.so
blueline:/ #

  1. 如下代码中的字符串可以定位 CodedOutputStream 类。

    1
    2
    3
    4
    5
    6
    7
    8
    public static class OutOfSpaceException extends IOException {
    private static final long serialVersionUID = -6947486886997889499L;

    OutOfSpaceException() {
    super("CodedOutputStream was writing to a flat byte array and ran " +
    "out of space.");
    }
    }
  2. CodedInputStream 的定位如下,依然根据字符串。然后可以从其 readString 的方法交叉引用查找生成的类,或者hook此方法也能看到实际相关生成类。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    // Here we should refill the buffer as many bytes as possible.
    int bytesRead =
    read(
    input,
    buffer,
    bufferSize,
    Math.min(
    // the size of allocated but unused bytes in the buffer
    buffer.length - bufferSize,
    // do not exceed the total bytes limit
    sizeLimit - totalBytesRetired - bufferSize));
    if (bytesRead == 0 || bytesRead < -1 || bytesRead > buffer.length) {
    throw new IllegalStateException(
    input.getClass()
    + "#read(byte[]) returned invalid result: "
    + bytesRead
    + "\nThe InputStream implementation is buggy.");
    }
    1
    2
    3
    4
    if (bytesRead == 0 || bytesRead < -1 || bytesRead > this.buffer.length) {
    throw new IllegalStateException("InputStream#read(byte[]) returned invalid result: " + bytesRead + "\nThe InputStream implementation is buggy.");
    }

  3. 如下代码中的字符串 "byte array" 定位 toByteArray 方法

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    @Override
    public byte[] toByteArray() {
    try {
    final byte[] result = new byte[getSerializedSize()];
    final CodedOutputStream output = CodedOutputStream.newInstance(result);
    writeTo(output);
    output.checkNoSpaceLeft();
    return result;
    } catch (IOException e) {
    throw new RuntimeException(getSerializingExceptionMessage("byte array"), e);
    }
    }

获取动态注册函数方法信息

1
jnitrace -l libwxxx.so com.xxxx.yyyyy -i RegisterNatives -o /path/to/json_file

自从用了 AltStore 之后就不能自拔,想着所有ipa都要通过它安装上去,不过没有付费的apple id是有数量限制的,sideload ipa也是有个数限制,思来想去发现自己是掉坑里面了,这才突然想起 AppSync 来。既然已经越狱,找到最新版 AppSync发现已经支持到了自己越狱版本13.5。那装上用 ifunbox 装个 ipa 还不是分分钟的事情。果然事情并没有想象中的简单。

装完后爱思助手显示我没有安装AppSync,然后查看了AppSync包内容,发现有个服务进程 asu_inject ,但是高版本并不需要这个进程了,最终打包文件里也没有启动这个服务的plist文件。

问题出现在注入的 installd 这个进程没有重启,使 AppSync 的 hook 代码生效,自己手动 killall -9 installd 使其加载 hook 代码后就可以解决惹。

使用:

1
./strace -p 16998 -f -x -y -e read=all -e write=all -o trace.txt

output(部分):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
17046 openat(AT_FDCWD, "/proc/interrupts", O_RDONLY|O_LARGEFILE) = -1 EACCES (Permission denied)
17046 read(-1, 0xba60f7b8, 4095) = -1 EBADF (Bad file descriptor)
17046 openat(AT_FDCWD, "/proc/diskstats", O_RDONLY|O_LARGEFILE) = -1 EACCES (Permission denied)
17033 <... ioctl resumed> , 0xc3fc2118) = 0
17031 <... ioctl resumed> , 0xbc2c6118) = 0
17046 read(-1, <unfinished ...>
17033 futex(0xe831c514, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
17046 <... read resumed> 0xba60f7b8, 4095) = -1 EBADF (Bad file descriptor)
17033 <... futex resumed> ) = 0
17046 openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_LARGEFILE <unfinished ...>
17033 futex(0xe831c510, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
17031 futex(0xe831c510, FUTEX_WAIT_BITSET_PRIVATE, 2, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
17033 <... futex resumed> ) = 0
17031 <... futex resumed> ) = -1 EAGAIN (Try again)
17046 <... openat resumed> ) = -1 EACCES (Permission denied)
17031 futex(0xe831c510, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
17046 read(-1, <unfinished ...>
17033 getpid( <unfinished ...>
17046 <... read resumed> 0xba60f7b8, 4095) = -1 EBADF (Bad file descriptor)
17033 <... getpid resumed> ) = 16998
17046 faccessat(AT_FDCWD, "/proc/sys/fs/binfmt_misc/arm", F_OK <unfinished ...>
17033 getuid32( <unfinished ...>
17031 <... futex resumed> ) = 0
17046 <... faccessat resumed> ) = -1 ENOENT (No such file or directory)
17033 <... getuid32 resumed> ) = 10217
17046 openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_LARGEFILE <unfinished ...>
17031 futex(0xe831c514, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
17033 futex(0xe831c510, FUTEX_WAIT_BITSET_PRIVATE, 2, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
17031 <... futex resumed> ) = 0
17046 <... openat resumed> ) = 139</proc/16998/maps>
17031 futex(0xe831c510, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
17046 read(139</proc/16998/maps>, <unfinished ...>
17031 <... futex resumed> ) = 1
17033 <... futex resumed> ) = 0
17033 futex(0xe831c514, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
17046 <... read resumed> "12c00000-13180000 rw-p 00000000 "..., 4095) = 3992
| 00000 31 32 63 30 30 30 30 30 2d 31 33 31 38 30 30 30 12c00000-1318000 |
| 00010 30 20 72 77 2d 70 20 30 30 30 30 30 30 30 30 20 0 rw-p 00000000 |
| 00020 30 30 3a 30 30 20 30 20 20 20 20 20 20 20 20 20 00:00 0 |
| 00030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |
| 00040 20 20 20 20 20 20 20 20 20 5b 61 6e 6f 6e 3a 64 [anon:d |
| 00050 61 6c 76 69 6b 2d 6d 61 69 6e 20 73 70 61 63 65 alvik-main space |
| 00060 20 28 72 65 67 69 6f 6e 20 73 70 61 63 65 29 5d (region space)] |
| 00070 0a 31 33 31 38 30 30 30 30 2d 31 33 33 30 30 30 .13180000-133000 |
| 00080 30 30 20 72 77 2d 70 20 30 30 30 30 30 30 30 30 00 rw-p 00000000 |
| 00090 20 30 30 3a 30 30 20 30 20 20 20 20 20 20 20 20 00:00 0 |
| 000a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |
...

主要 -e 选项可以把读写数据以 hexadecimal and ASCII Dump出来并记录。

窦唯的<高级动物>写的真好。

作曲 : 窦唯,
作词 : 窦唯,

矛盾 虚伪 贪婪 欺骗,
幻想 疑惑 简单 善变,
好强 无奈 孤独 脆弱,
忍让 气愤 复杂 讨厌,
嫉妒 阴险 争夺 埋怨,
自私 无聊 变态 冒险,
好色 善良 博爱 诡辩,
能说 空虚 真诚 金钱,
噢~~我的天 高级动物,
地狱 天堂 皆在人间,
伟大 渺小 中庸 可怜,
欢乐 痛苦 战争 贫寒,
辉煌 暗淡 得意 伤感,
怀恨 报复 专横 责难,
幸福在哪里,
幸福在哪里,
幸福在哪里。

感觉自己还是冷漠,北京大多时候是个冷漠的城市,面对陌生人不想提供更多帮助,因为骗子太多,或者人间不值得。但是还是向往那种无条件的善良,不管对方是不是骗子,都会给予帮助,这是自己的意愿,万一呢,是需要帮助的人。而且大多数时候对方也只是问个路而已,自己帮助他们用手机地图搜一下告诉大概怎么走也是温暖的。
写这个是某天晚上跑步碰到一个外卖小哥要问路而我跑掉了吧,感觉挺内疚。一般只要不是明显要钱的,问路我还是会用手机帮助他们查的,希望世界美好。希望人们都会用智能手机。

新年给自己买的新礼物,就是本站用的域名thepapaya.me的域名了,首年24元续费100多。是不是超级便宜的礼物,最近想买ikbc的无线87键机械键盘,大概不到400能拿下还是舍不得,舍不得原因也是想买其他好玩的设备,不知道要花多少没用的钱。。。

而能毫不犹豫的买个 .me 域名是想继续更新本站,本来只想写些技术文章,结果毕业以来5、6年写了10多篇技术文章,还不算抄人家的,摸着良心会痛。所以想不如写些比较杂的东西,脑子里每天重复的东西或者是想的一些没用的、没意义的东西。把这些空间从脑子里释放出来。

另一方面:之所以觉的自己每天脑子里会有各种乱七八糟的东西,也可能是自己体会到,并没人倾诉,也没人倾听,更不敢发到朋友圈微博,还不如索性写到这。也不晓得朋友圈或者微博能活多少年,然后又像当年的QQ被冷落。全然把这当个记事本也挺好。就算买一些现成的笔记类的应用一年也花不少钱不是,还不知道开发者能坚持做几年到时候又得折腾。而博客的迁移就相对简单多了。

EOF

1
2
3
4
5
6
7
8
9
10
11
12
aapt dump badging /path/xxx.apk
adb shell am start -D -n 包名/类名
adb forward tcp:23946 tcp:23946
adb forward tcp:8700 jdwp:pid
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8700

eg:

adb shell am start -D -n com.tencent.mm/com.tencent.mm.ui.LauncherUI
adb forward tcp:23946 tcp:23946
adb forward tcp:8700 jdwp:pid
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8700