import yxr_grpc_pb2 import yxr_grpc_pb2_grpc import grpc import time import re
from frida_rpc import script
defmain(): total = 0 target = "180.76.60.244:9901" for page inrange(1, 101): with grpc.insecure_channel(target) as channel: client = yxr_grpc_pb2_grpc.ChallengeStub(channel=channel) req_data = yxr_grpc_pb2.RequestMessage() req_data.page = page ts = int(time.time()) * 1000 req_data.t = ts req_data.sign = script.exports.main(f"{page}:{ts}", ts) response = client.SayHello(req_data) data = re.findall(r'"(\d+)"', str(response)) nums = list(map(int, data)) total += sum(nums) print(f"前{page}页总和为:", total)
if __name__ == '__main__': main()
这里需要结合frida rpc来调用sign函数,hook代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
var str var j var result functionmain(str, j) { console.log("Script loded successfully") console.log(str) Java.perform(function () { var clazz = Java.use('com.yuanrenxue.match2022.fragment.challenge.ChallengeFourFragment') console.log("调用类成功") var instance = clazz.$new() console.log("创建实例成功") result = instance.sign(str, j) console.log(result) }) return result } rpc.exports = { main: main }