https://ask.csdn.net/questions/7817406

问题

使用burpsuite的burpcrypto插件存在疑问

报错信息

环境

https://ask.csdn.net/questions/7817406

在帖子里描述下你的问题吧 :joy:

简单来说,就是想使用burpcrypto插件,对burpsuite得到结果执行JS脚本解密。但是像在帖子里那样,我就单纯一个函数,传参数,然后就return,我选中了一串字符串,然后使用这个脚本;得到的却不是我选中的字符串?是我这个插件的使用有问题吗?老师能请教一下,我该怎么写这个JS脚本,才能成功解密字符串呢?加密方式帖子里也有,我的使用方法,JS函数,帖子都有

如果是你们公司的业务,你可以咨询下对应的开发,加密解密的规则是什么;
或者你先按照这种规则去加密一段内容,检查下加密出来的内容是否一致,然后反推

加密解密规则我都贴上去了。。。主要是burpsuite用鼠标框起来的,难道不是作为参数传到js函数里吗?

这一点你验证了吗

加密: 返回数据为format_res,然后将其base64encode,再均分成2分A和B,再分别将A和B均分为
     A1、A2、B1、B2,然后拼接字符串A2+A1+B2+B1即为返回结果res
解密: 将res按逆过程还原即可

用python去写也不难呀,burpsuite 这个工具没用过。。。

我知道Python不难,但是不想每次抓包都复制出来再去解码。想在抓包的时候,一边抓包,一边看解码后的数据。Charles不支持自定义解码需要反编译jar包;burpsuite这个插用不好;mitmproxy倒是实现了。就是看着没burpsuite这个好看

python也可以抓包呀,mitmproxy

是的。我说了mitmproxy实现了。只是没有burpsuite好看。
顺带问一下老师,mitmproxy,我怎么设置不展示其他域名的数据,还有像client disconnect,server disconnect这样的数据呢?只展示我想要的域名的接口数据

# time:2022 /10 /24
# author: SZR


import base64
import json
import time

from mitmproxy import ctx

# dic = {}
key = []
value = []
with open('奇数行.txt','r',encoding='utf-8') as f:
    lines = f.readlines()
    for line in lines:
        key.append(line.rstrip('\n'))
    with open('偶数行.txt','r',encoding='utf-8') as f2:
        lines2 = f2.readlines()
        for line2 in lines2 :
            value.append('https://testapi.zkkynrbx.com' + line2.rstrip('\n'))

# for i in range(len(key)):
#     dic[key[i]] = value[i]

class GL_Decode:

    def request(self,flow):
        request_url = flow.request.url
        # 去掉get请求中的参数,使得url能和文档中的匹配
        if '?' in request_url:
            p1 = request_url.index('?')
            request_url = request_url[0:p1]

        if request_url in value:
            position = value.index(request_url)
            ctx.log.info(key[position])

    def response(self, flow):
        ctx.log.info('raw data:')
        ctx.log.info(flow.response.content)
        ctx.log.info("\n")

        text = flow.response.content
        le = len(text)
        l1_2 = int(le / 2)
        l2_left = int(l1_2 / 2)
        l2_right = int((le + l1_2) / 2)
        # res = text.slice(l2_left, l1_2) + text.slice(0, l2_left) + text.slice(l2_right, ) + text.slice(l1_2, l2_right)
        res = text[l2_left:l1_2] + text[0:l2_left] + text[l2_right:] + text[l1_2:l2_right]
        res = base64.b64decode(res).decode()


        ctx.log.info("decode response:")
        ctx.log.info(res)
        ctx.log.info('\n')

addons = [
    GL_Decode()
]

还有一个问题,我想在每个请求前判断打印出对应的中文名。但结果好像有问题,有得打印了2个,有得没有打印。是我代码哪里有问题吗?写的位置不对?