BetterZip For macOS 破解实战(Patch公钥、黑名单检测、签名校验、KeyGen等) // 适用于目前最新4.x版
所需工具:
- IDA Pro/Hopper Disassembler
- lldb
- 010 Editor
- openssl
- 最爱的Go
寻找切入点:
- lldb下断、在注册界面随便输入注册码,如期断下:
算法分析:
这里可以看到RSA公钥的base64解码过程、以及确定使用了OpenSSL库
这里可以看到用了RSA公钥解密注册码,从mov edi, 80h 可以推断出使用了RSA1024
★★★ 注册码开头必须为:__MAS_BetterZp2_、__MIB_BZ-Friend_、__MIB_BetterZip_ ★★★
这里看到从第0x10字节开始取了7字节,然后转换为int值,黑名单检测稍后分析
这里看到从第0x23字节开始取了4字节,然后转换为int值
这里看到从第0x29字节开始,取得剩下的字符串,根据后面分析可知,是用户名
显示注册码部分,有3处分支,我们选取了显示参数最多的一处,略显逼格,哈!!
第一部分 __MAS_BetterZp2_、__MIB_BZ-Friend_、__MIB_BetterZip_ 占0x10字节
留空1字节
第二部分 [0x10, 7] 7字节整数 随机生成(需要避免黑名单)
留空1字节
第三部分 [0x23, 4] 4字节整数 随机生成即可
留空1字节
第四部分 [0x29, …] 用户名 自己看着办
因为下标从0开始,根据取值区间来看,需要留空一个字节
样本注册内容:__MIB_BetterZip_0999999 2017-08-19 9999 www.chinapyg.com
黑名单检测:
可以看到这里取了算法第二部分的7位整数,进行黑名单检测
Patch公钥:
私钥:openssl genrsa -out rsa_private_key.pem 1024-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDB7kiHY0omkKpzU9sDnaNwLQ6llxGbz+4mr1SIVVJtEA5YEQi+
SVD1ALS2hZkpOjHUtLfiirz5sA+fhN0ngln12NjPc0z8u3FuZ2aH4ffMlrWr9ysW
0uvnkBlNXVF/g21l0H/Lt1HSVZmTBDMELeVlWIHLHPRxEbVkjFhGliq13QIDAQAB
AoGBAKCKTtZtVpwYVFKGj58tp3gchKyGI9iVyDOUH2mBIGwSx50V9OP5s6Auxmr2
q/UaLNhGBpfufERDAJvwlFe5rBfKv4H9tWiR82KFHZPQK+Cd3mlre0c2jB5aimIu
fiAmNZmlyudBm0eN45c/t8jcbeK2UXvseN5d9fdqnPs8XKjBAkEA+sej2nyG5YAJ
dUa5fLE1H45j9FikpXqIWZi/aVe9vwSUoXbzYqv/DssaZt5HejKzqYkf3f86O65u
wVN5sjmqzQJBAMX3tH9jb1nCF69tCB6tUTrTWX+wHVsvCHs3VQJXp5iaU2DewmL4
k0Dddis6xcBThywfbAMA/1Thn+DOubxgV1ECQEcCUo4iJpxDdeokPY9mKhGmYv0k
QHKu0H72NnTgqFS3OlLB+MaexxjsP6yTEhAy3RaLQl+8zkNp7+iD93iUxZ0CQQDF
mJbax98u0iJeARAnvorjkm00nA7RIsLuaa46Jk+sa+1pNS8FJmOkTOhUAde8PiMf
kUV4QhiZGpNAClcthWPhAkAa1L9X9J9ng8MaIDXMpjNAlFlnEuJ25wXbgiDWrfJY
QAMiDzc8qm0iB/9i86rCGnwFf1sO53L9gjiq13VjjLQg
-----END RSA PRIVATE KEY-----
公钥:openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDB7kiHY0omkKpzU9sDnaNwLQ6l
lxGbz+4mr1SIVVJtEA5YEQi+SVD1ALS2hZkpOjHUtLfiirz5sA+fhN0ngln12NjP
c0z8u3FuZ2aH4ffMlrWr9ysW0uvnkBlNXVF/g21l0H/Lt1HSVZmTBDMELeVlWIHL
HPRxEbVkjFhGliq13QIDAQAB
-----END PUBLIC KEY-----
LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FEQjdraUhZMG9ta0twelU5c0RuYU53TFE2bApseEdieis0bXIxU0lWVkp0RUE1WUVRaStTVkQxQUxTMmhaa3BPakhVdExmaWlyejVzQStmaE4wbmdsbjEyTmpQCmMwejh1M0Z1WjJhSDRmZk1scldyOXlzVzB1dm5rQmxOWFZGL2cyMWwwSC9MdDFIU1ZabVRCRE1FTGVWbFdJSEwKSFBSeEViVmtqRmhHbGlxMTNRSURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==
签名校验:
非常简单的验证公钥的第0x40字节,如果不等于0x55 则over!
经@creantan版主分析,此处不为0x55的概率非常低 ,所以几乎可以忽略此签名校验
KeyGen:
[Golang] 纯文本查看 复制代码 package main
import (
"log"
"keygen/codec"
)
const (
g_PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDB7kiHY0omkKpzU9sDnaNwLQ6llxGbz+4mr1SIVVJtEA5YEQi+
SVD1ALS2hZkpOjHUtLfiirz5sA+fhN0ngln12NjPc0z8u3FuZ2aH4ffMlrWr9ysW
0uvnkBlNXVF/g21l0H/Lt1HSVZmTBDMELeVlWIHLHPRxEbVkjFhGliq13QIDAQAB
AoGBAKCKTtZtVpwYVFKGj58tp3gchKyGI9iVyDOUH2mBIGwSx50V9OP5s6Auxmr2
q/UaLNhGBpfufERDAJvwlFe5rBfKv4H9tWiR82KFHZPQK+Cd3mlre0c2jB5aimIu
fiAmNZmlyudBm0eN45c/t8jcbeK2UXvseN5d9fdqnPs8XKjBAkEA+sej2nyG5YAJ
dUa5fLE1H45j9FikpXqIWZi/aVe9vwSUoXbzYqv/DssaZt5HejKzqYkf3f86O65u
wVN5sjmqzQJBAMX3tH9jb1nCF69tCB6tUTrTWX+wHVsvCHs3VQJXp5iaU2DewmL4
k0Dddis6xcBThywfbAMA/1Thn+DOubxgV1ECQEcCUo4iJpxDdeokPY9mKhGmYv0k
QHKu0H72NnTgqFS3OlLB+MaexxjsP6yTEhAy3RaLQl+8zkNp7+iD93iUxZ0CQQDF
mJbax98u0iJeARAnvorjkm00nA7RIsLuaa46Jk+sa+1pNS8FJmOkTOhUAde8PiMf
kUV4QhiZGpNAClcthWPhAkAa1L9X9J9ng8MaIDXMpjNAlFlnEuJ25wXbgiDWrfJY
QAMiDzc8qm0iB/9i86rCGnwFf1sO53L9gjiq13VjjLQg
-----END RSA PRIVATE KEY-----`
g_PUBLICK_KEY = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDB7kiHY0omkKpzU9sDnaNwLQ6l
lxGbz+4mr1SIVVJtEA5YEQi+SVD1ALS2hZkpOjHUtLfiirz5sA+fhN0ngln12NjP
c0z8u3FuZ2aH4ffMlrWr9ysW0uvnkBlNXVF/g21l0H/Lt1HSVZmTBDMELeVlWIHL
HPRxEbVkjFhGliq13QIDAQAB
-----END PUBLIC KEY-----
`
)
func main() {
pubErr, priErr := codec.RSA.Init(g_PUBLICK_KEY, g_PRIVATE_KEY)
log.Println("init error:", pubErr, priErr)
str, _ := codec.RSA.String("__MIB_BetterZip_0999999 2999-12-31 9999 [url=https://www.chinapyg.com]www.chinapyg.com[/url]", codec.MODE_PRIKEY_ENCRYPT)
log.Println("prikey encrypt:", str)
str, _ = codec.RSA.String(str, codec.MODE_PUBKEY_DECRYPT)
log.Println("pubkey decrypt:", str)
}
对应注册码: vAMODxE4yMO3fDmddGCXqdLsFdf5tt1yJWXxT4YuZ9Tfcr1TrfcNtFgNT0xg3VFuMIqFXiZCO3/j6siQo4p2frWFt2Ph/LK1BMqmq7gzS/aLGoKi+Sw3+VjJSFxLRTOeArZnyRqy+FWSZ8OdsP1LfWXsLaoOtpiNcObbko9bsNE=
|