背景:
在一次渗透测试中,一个APP的传输存在加密,且存在反hook防护,fridahook无法hook住,并存在360加固,无法直接分析,尝试frida-dexdump后依然找不到加解密方法和密钥,此时发现可以用浏览器调试模拟器APP的webview的方法进行调试,定位加密方法断点出密钥,从而实现解密数据,进而顺利挖掘漏洞
渗透某APP发现数据为加密传输:

尝试逆向分析加解密算法,发现存在360加固:

尝试脱壳分析,Frida-dexdump出classes

修复dex

Jadx载入,尝试搜索相关加密方法关键字

但无法找到
此时寻找了其他方法:
参考链接:
https://blog.csdn.net/smile_pp123/article/details/142649944
模拟器打开APP后:
在物理机edge浏览器输入:
edge://inspect/#devices

查看此处可调试了,相当于开启了浏览器开发者工具

定位到加密方法和密钥

从而编写python加解密脚本还原加密方法


成功实现加解密
脚本代码
from gmssl import sm4 import binascii import base64 # 默认密钥(需与Java代码中的密钥处理逻辑一致) DEFAULT_KEY = "xxxxxxxxxxxxxxxx".encode('utf-8') KEY_HEX = binascii.hexlify(DEFAULT_KEY).decode('utf-8') def sm4_encrypt(data: str, key_hex: str) -> str: cryptor = sm4.CryptSM4() cryptor.set_key(binascii.unhexlify(key_hex), sm4.SM4_ENCRYPT) encrypted = cryptor.crypt_ecb(data.encode('utf-8')) return binascii.hexlify(encrypted).decode('utf-8') def sm4_decrypt(data_hex: str, key_hex: str) -> str: cryptor = sm4.CryptSM4() cryptor.set_key(binascii.unhexlify(key_hex), sm4.SM4_DECRYPT) decrypted = cryptor.crypt_ecb(binascii.unhexlify(data_hex)) return decrypted.decode('utf-8', errors='ignore') def main_loop(): while True: # 用户选择操作 [4]()[6]() choice = input("\n==== SM4加解密工具 ====\n" "1. 加密\n2. 解密\n3. 退出\n请选择操作:") if choice == '1': plaintext = input("请输入明文:") ciphertext = sm4_encrypt(plaintext, KEY_HEX) print(f"加密结果:{ciphertext}") elif choice == '2': ciphertext = input("请输入密文:") try: plaintext = sm4_decrypt(ciphertext, KEY_HEX) print(f"解密结果:{plaintext}") except Exception as e: print(f"解密失败:{str(e)}") elif choice == '3': print("程序已退出") break # 退出循环 [7]() else: print("无效输入,请重新选择") if __name__ == "__main__": main_loop()
|
开始渗透测试:


此处有对应的每个用户下的信息

获取到列表中其中一位用户的信息
尝试改成其他不属于自己的ID,将明文加密回去发送:


成功越权获取其他用户信息,理论可遍历所有ID获取所有用户信息
