Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

方案三可用 抓包替换js的一些正则,可实现0.001秒,取消匹配动画,全自动答题 #113

Open
liqiang-xxfy opened this issue Oct 16, 2024 · 3 comments

Comments

@liqiang-xxfy
Copy link

liqiang-xxfy commented Oct 16, 2024

项目里有写好导出的rules文件(.farx格式): xiaoyuankousuan-fiddler-autojs

  • 抓包正则匹配到PK页面的js文件的请求
 ^https:\/\/leo\.fbcontent\.cn\/bh5\/leo-web-oral-pk\/exercise_.*\.js$
  • 使用正则替换请求响应体中的js内容,正则忽略了函数名,所以不受js文件函数名变化影响,不容易失效
//取消匹配动画、readyGo动画:
     case 0:if(.{0,14})\.challengeCode(.{200,300})([a-zA-Z]{1,2})\("startExercise"\); 正则替换为 case 0:$3("startExercise");if$1.challengeCode$2
    "readyGoEnd"\)\}\),.{1,4}\)\}\),.{1,4}\)\}\),.{1,4}\)\}\) 正则替换为 "readyGoEnd")}),20)}),20)}),20)})

//好友挑战PK修改时间为0.001:
     correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode  正则替换为  correctCnt:$1,costTime:$4.challengeCode?1:$2,updatedTime:$3$4.challengeCode

//所有PK场次修改时间为0.001
     correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode   正则替换为  correctCnt:$1,costTime:1,updatedTime:$3$4.challengeCode    

//判断任何答案正确:
     return .{3,5}\)\?1:0\}, 正则替换为 return 1},

//自动触发答题:
     =function\(([a-zA-Z]{1,2}),([a-zA-Z]{1,2})\)\{([a-zA-Z]{1,2})&&\(([a-zA-Z]{1,2})\.value= 正则替换为 =function($1,$2){$2({ recognizeResult: "", pathPoints: [[]], answer: 1, showReductionFraction: 0 });$3&&($4.value=

//直接判断所有答题完成:
     \.value\+1>=[a-zA-Z]{1,2}\.value\.length\?([a-zA-Z]{1,2})\("finishExercise"\) 正则替换为 .value+1>=0?$1("finishExercise")
  • 注意修改后需要清除app缓存才生效

fiddler_20241015181548

@liqiang-xxfy liqiang-xxfy changed the title 方案三 抓包替换js的一些正则,可实现0.001秒,取消匹配动画,全自动答题 方案三可用 抓包替换js的一些正则,可实现0.001秒,取消匹配动画,全自动答题 Oct 16, 2024
@cr4n5
Copy link
Owner

cr4n5 commented Oct 16, 2024

谢谢提供思路!

@wy1348666498
Copy link

def handle_target_response(self, flow, url):
    print(f"匹配到指定的 URL: {url}")
    responsetext = flow.response.text
    self.update_response_text(flow, responsetext)

def update_response_text(self, flow, responsetext):
    # 1. 取消PK准备动画
    text = re.sub(r'"readyGoEnd"\)\}\),.{1,4}\)\}\),.{1,4}\)\}\),.{1,4}\)\}\)',
                  r'"readyGoEnd")}),20)}),20)}),20)})', responsetext)

    # 2. case 0 替换
    text = re.sub(r'case 0:if(.{0,14})\.challengeCode(.{200,300})([a-zA-Z]{1,2})\("startExercise"\);',
                  r'case 0:\3("startExercise");if\1.challengeCode\2', text)

    # 3. 判断任何答案正确
    text = re.sub(r'return .{3,5}\)\?1:0\},', r'return 1},', text)

    # 4. 自动触发答题
    text = re.sub(r'=function\(([a-zA-Z]{1,2}),([a-zA-Z]{1,2})\)\{([a-zA-Z]{1,2})&&\(([a-zA-Z]{1,2})\.value=',
                  r"=function(\1,\2){\2({ recognizeResult: '', pathPoints: [[]], answer: 1, showReductionFraction: 0 });\3&&(\4.value=",
                  text)

    # 5. 直接判断所有答题完成
    text = re.sub(r'\.value\+1>=[a-zA-Z]{1,2}\.value\.length\?([a-zA-Z]{1,2})\("finishExercise"\)',
                  r'.value+1>=0?\1("finishExercise")', text)

    # 6. 好友挑战PK修改时间为0.001
    text = re.sub(r"correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode",
                  r"correctCnt:\1,costTime:\4.challengeCode?1:\2,updatedTime:\3\4.challengeCode", text)

    # 7. 所有PK场次修改时间为0.001
    text = re.sub(r"correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode",
                   r"correctCnt:\1,costTime:1,updatedTime:\3\4.challengeCode", text)

    flow.response.text = text
    print(f"替换后的响应: {text}")
    threading.Thread(target=self.show_message_box, args=("过滤成功", f"替换成功!")).start()

@GalacticDevOps
Copy link
Contributor

GalacticDevOps commented Oct 17, 2024

def handle_target_response(self, flow, url):
    print(f"匹配到指定的 URL: {url}")
    responsetext = flow.response.text
    self.update_response_text(flow, responsetext)

def update_response_text(self, flow, responsetext):
    # 1. 取消PK准备动画
    text = re.sub(r'"readyGoEnd"\)\}\),.{1,4}\)\}\),.{1,4}\)\}\),.{1,4}\)\}\)',
                  r'"readyGoEnd")}),20)}),20)}),20)})', responsetext)

    # 2. case 0 替换
    text = re.sub(r'case 0:if(.{0,14})\.challengeCode(.{200,300})([a-zA-Z]{1,2})\("startExercise"\);',
                  r'case 0:\3("startExercise");if\1.challengeCode\2', text)

    # 3. 判断任何答案正确
    text = re.sub(r'return .{3,5}\)\?1:0\},', r'return 1},', text)

    # 4. 自动触发答题
    text = re.sub(r'=function\(([a-zA-Z]{1,2}),([a-zA-Z]{1,2})\)\{([a-zA-Z]{1,2})&&\(([a-zA-Z]{1,2})\.value=',
                  r"=function(\1,\2){\2({ recognizeResult: '', pathPoints: [[]], answer: 1, showReductionFraction: 0 });\3&&(\4.value=",
                  text)

    # 5. 直接判断所有答题完成
    text = re.sub(r'\.value\+1>=[a-zA-Z]{1,2}\.value\.length\?([a-zA-Z]{1,2})\("finishExercise"\)',
                  r'.value+1>=0?\1("finishExercise")', text)

    # 6. 好友挑战PK修改时间为0.001
    text = re.sub(r"correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode",
                  r"correctCnt:\1,costTime:\4.challengeCode?1:\2,updatedTime:\3\4.challengeCode", text)

    # 7. 所有PK场次修改时间为0.001
    text = re.sub(r"correctCnt:(.{1,5}),costTime:(.{1,15}),updatedTime:(.{1,120})([a-zA-Z]{1,2})\.challengeCode",
                   r"correctCnt:\1,costTime:1,updatedTime:\3\4.challengeCode", text)

    flow.response.text = text
    print(f"替换后的响应: {text}")
    threading.Thread(target=self.show_message_box, args=("过滤成功", f"替换成功!")).start()

已参考修改,修改后的代码
请点击这里

GalacticDevOps added a commit to GalacticDevOps/XiaoYuanKouSuan2 that referenced this issue Oct 17, 2024
cr4n5 added a commit that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants